Class: XML_ADAPTER

XML_ADAPTER

XML response adapter class which handles wrapping response data in object with status code and result message and converting into XML string.

Constructor

new XML_ADAPTER(optionsopt)

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}

Configurable options for XML adapter

Properties
Name Type Description
skip_conversion Boolean

If true render will just return data that is passed to it

xml_root string

The value that should be used in generating the root tag of the converted XML document

xml_configuration Object

Options that will be passed to the XML conversion function

Source:

Extends

  • JSON_Adapter

Methods

error(erropt, optionsopt, cbopt) → {*}

Creates a formatted XML error response

Parameters:
Name Type Attributes Default Description
err * <optional>
{}

Any data that should be sent with the error response

options Object <optional>
{}

Configurable options for the XML error response formatting see _ERROR for more details

Properties
Name Type Attributes Default Description
formatError function <optional>
_ERROR

Custom formatting function for XML rendering. It is recommended that the default value for this property is used and only custom options for the XML rendering are passed

req Object <optional>

Express request object. If options.req and options.res are defined the express .render method will be used to render template

res Object <optional>

Express response object. If options.res and options.req are defined the express .render method will be used to render template

skip_response Boolean <optional>

If true function will resolve with the rendered template instead of sending a response

cb function <optional>
false

Optional callback function. If argument is not a function it will be ignored

Source:
Returns:

Returns the formatted XML string if options.sync is true or a Promise if cb arugement is not passed

Type
*

render(data, optionsopt, cbopt) → {*}

Creates a formatted XML response

Parameters:
Name Type Attributes Default Description
data *

Any data that should be sent with the success response

options Object <optional>
{}

Configurable options for the XML success response formatting see _RENDER for more details

Properties
Name Type Attributes Default Description
formatRender function <optional>
_RENDER

Custom formatting function for XML rendering. It is recommended that the default value for this property is used and only custom options for the XML rendering are passed

cb function <optional>
false

Optional callback function. If argument is not a function it will be ignored

options.req Object <optional>

Express request object. If options.req and options.res are defined the express .render method will be used to render template

options.res Object <optional>

Express response object. If options.res and options.req are defined the express .render method will be used to render template

options.skip_response Boolean <optional>

If true function will resolve with the rendered template instead of sending a response

Source:
Returns:

Returns the formatted XML string if options.sync is true or a Promise if cb arugement is not passed

Type
*