xml feature

XML Feature

Version: 17.07

Supported Since: 17.01

XML Feature

XML Feature provides a collection of API methods that can be used to process XML related payloads.

Configuration Properties

Property Name Property Description Possible Values

minTransformerCount

Minimum number of XSLT transformers to be created and cached for each XSLT schema.

Should be a positive value. Default value is 40 for Production mode and 5 for other non-production modes.

maxTransformerCount

Minimum number of XSLT transformers to be created and cached for each XSLT schema.

Should be a positive value. Default value is 300 for Production mode and 20 for other non-production modes.

APIs Java Docs

createDOMDocument

Returns
Document

This API will return a new org.w3c.dom.Document instance.

This API will create and return a new instance of a org.w3c.dom.Document object to build a DOM tree with.

serialize

Parameters
Document document

The org.w3c.dom.Document object to be serialized.

OutputStream os

The OutputStream to which the serialized Document should be written to.

This API will Serialize the provided DOM Document into the given OutputStream with the system character encoding.

setPayloadFromDOM

Parameters
XMessage m

The org.adroitlogic.x.api.XMessage object to which the payload should be set to.

Document doc

The org.w3c.dom.Document object to be set as the message payload.

This API will set the provided Document as the payload of the provided XMessage instance.

getPayloadAsDOM

Parameters
XMessage m

The org.adroitlogic.x.api.XMessage object to retrieve the payload from.

boolean setAsPayload

Whether to set the converted document as the payload of the message, in case the current payload is not of the type org.adroitlogic.x.feature.xml.impl.DOMMessageFormat.

Returns
Document

This API will return the payload as a org.w3c.dom.Document instance.

This API will retrieve and return the payload of the given XMessage as a org.w3c.dom.Document instance. This will throw a org.adroitlogic.x.api.FormatConversionException if the current payload cannot be converted to a DOM object.

convertToDOM

Parameters
XMessage m

The org.adroitlogic.x.api.XMessage object of which the payload should be converted to DOM.

This API will convert the payload of the given XMessage to DOM and set the converted DOM as the current payload. The resulting payload will be of the type org.adroitlogic.x.feature.xml.impl.DOMMessageFormat.

retainElementAsPayload

Parameters
XMessage m

The org.adroitlogic.x.api.XMessage object from which the XML element should be extracted.

String expression

XPath expression selecting the node to retain.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

This API will extract the XML node selected by the provided XPath expression and set it as the payload of the message.

mergeXMLAttachmentsUnderElement

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object to be transformed.

String rootElemName

The name of the new root element to be created.

This API will replace the current XML payload with a root element with the specified name and merge the attachments of the message underneath that.

mergeXMLAttachmentsUnderElement

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object to be transformed.

String rootElemName

The name of the new root element to be created.

String rootNS

The namespace of the new root element to be created.

This API will replace the current XML payload with a root element with the specified name and namespace. Then merges the attachments of the message underneath that.

Schema Validation API methods

validate

Parameters
XMessage m

The org.adroitlogic.x.api.XMessage object to be validated.

URI…​ schemaFileURIs

An array of XSD schema files URIs to be validated against.

The validator is sensitive to the order in which the Schemas are given. Otherwise it may result in an error such as

SAXParseException: cvc-elt.1: Cannot find the declaration of element

This API will validate the payload of the given message against one or more schemas. If validation failed, this will throw an IntegrationRuntimeException with details of the XSD validation failures.

validate

Parameters
String s

The XML String to be validated.

URI…​ schemaFileURIs

An array of XSD schema files URIs to be validated against.

This API will validate the given XML String against one or more schemas. If validation failed, this will throw an IntegrationRuntimeException with details of the XSD validation failures.

validate

Parameters
Node n

The DOM node containing the XML to be validated.

URI…​ schemaFileURIs

An array of XSD schema files URIs to be validated against.

This API will validate the given DOM Node against one or more schemas. If validation failed, this will throw an IntegrationRuntimeException with details of the XSD validation failures.

validate

Parameters
XMessage m

The org.adroitlogic.x.api.XMessage object to be validated.

URI[] schemaFileURIs

An array of XSD schema files URIs to be validated against.

String expression

An optional XPath expression to select the node for validation.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression.

This API will validate the payload of the given message (or an element of it selected via the provided XPath expression) against one or more schemas. If validation failed, this will throw an IntegrationRuntimeException with details of the XSD validation failures.

validateAll

Parameters
XMessage m

The org.adroitlogic.x.api.XMessage object to be validated.

URI[] schemaFileURIs

An array of XSD schema files URIs to be validated against.

String expression

An optional XPath expression to select the nodes for validation.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression.

This API will validate the payload of the given message (or all elements of it selected via the provided XPath expression) against one or more schemas. If validation failed, this will throw an IntegrationRuntimeException with details of the XSD validation failures.

XSLT transformation API methods

createAndCacheTransformers

Parameters
URI xsltFileURI

The URI of the XSLT file to be used by the transformers

This API will create and cache minTransformerCount number of XSLT transformers for the provided XSLT file.

transform

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object to be transformed.

URI xsltFileURI

The URI of the XSLT file to be used for the transformation

String expression

An optional XPath expression to select the source node for XSLT, and node to replace with the result

boolean domResult

Whether the result desired as a DOM payload?

Map<String, Object> parameters

Any XSLT parameters to be passed to the transformation

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression.

This API will transform the payload of the given message (or an element of it selected via the provided XPath expression) using the provided XSLT file and parameters.

transform

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object to be transformed.

URI xsltFileURI

The URI of the XSLT file to be used for the transformation

String expression

An optional XPath expression to select the source node for XSLT, and node to replace with the result

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression.

This API will transform the payload of the given message (or an element of it selected via the provided XPath expression) using the provided XSLT file (but without any parameters), assuming a non DOM result.

transform

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object to be transformed.

URI xsltFileURI

The URI of the XSLT file to be used for the transformation

This API will transform the payload of the given message using the provided XSLT file (but without any parameters), assuming a non DOM result and assuming that the complete message payload will be used as the source of the transformation, and the result will replace the complete message payload.

XPath filtering API methods

filter

Parameters
XMessage m

The org.adroitlogic.x.api.XMessage object to be evaluated.

String expression

An the XPath expression to evaluate against the message payload.

String regex

An optional regular expression to evaluate the XPath results' String value against.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression.

Returns
Boolean

This API will return true if the regular expression matches the String result of the XPath expression, false otherwise.

This API will evaluate the given XPath expression over the XML payload and compare the resulting String value with the provided regular expression for a match. This method converts the current payload into a DOMMessage.

filter

Parameters
XMessage m

The org.adroitlogic.x.api.XMessage object to be evaluated.

String expression

An the XPath expression to evaluate against the message payload.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression.

Returns
Boolean

This API will return true if the XPath expression evaluates to true, false otherwise.

This API will evaluate the given boolean XPath expression over the XML payload.

Attribute Manipulation API methods

addAttributeToElements

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object to be transformed.

String expression

The xpath expression to select the elements where the attribute should be added.

String qName

The qualified name for the new attribute. To specify a custom prefix use it as myns:myqname.

String nsUri

The namespace URI for the new attribute, or null.

String value

The new value of the attribute.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

This API will add an attribute to one or more elements of the message payload selected by an XPath expression.

getAttribute

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object to retrieve the attribute from.

String expression

The xpath expression to select the elements from where the attribute should be retrieved.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

Returns
String

This API will return the value of the selected attribute.

This API will return the value of the attribute selected by the provided XPath expression.

deleteAttributes

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object to delete the attributes from.

String expression

The xpath expression to select the attributes to be deleted.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

This API will delete the attribute/s selected by the provided XPath expression.

replaceAttributes

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object to delete the attributes from.

String expression

The xpath expression to select the attributes to be deleted.

String value

The new value for the attribute.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

This API will replace the value of the attribute/s selected by the provided XPath expression, with the provided new value.

Element Manipulation API methods

addTextElementsAsChild

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object.

String expression

The xpath expression to the node/s, which will be the parent for the new node/s.

String qualifiedTagName

The qualified name of the new element to be added.

String namespace

An optional String specifying the namespace url of the new element.

String elementContent

The text content of the new element.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

This API will insert a Text Element with the provided content as a child to the specified elements pointed by the xpath expression.

addElementsAsChild

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object.

String expression

The xpath expression to the node/s, which will be the parent for the new node/s.

String qualifiedTagName

The qualified name of the new element to be added.

String namespace

An optional String specifying the namespace url of the new element.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

This API will insert a new element as a child to the specified elements pointed by the xpath expression.

getTextElement

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object.

String expression

The xpath expression to the element where the text content should be read.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

Returns
String

This API will return the value of the attribute.

This API will get text element value of the element pointed by the given xpath expression.

replaceTextElements

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object.

String expression

The xpath expression to the text elements to be replaced.

String elementContent

The text content of the new element/s.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

This API will replace the Text Elements pointed by the given xpath expression with the given content.

deleteElements

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object.

String expression

The xpath expression to the elements to be deleted.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

This API will delete the elements pointed by the given xpath expression.

insertTextElementsBefore

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object.

String expression

The xpath expression to the node, before which the new element should be added.

String qualifiedTagName

The qualified name of the new element to be added.

String namespace

An optional String specifying the namespace url of the new element.

String elementContent

The content of the new element.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

This API will insert an element/elements before the specified element pointed by the given XPath, to the current message. If the XPath expression points to multiple elements, new element will be added before all such elements. The content of the new element should be String. No complex types are allowed.

insertTextElementsAfter

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object.

String expression

The xpath expression to the node, after which the new element should be added.

String qualifiedTagName

The qualified name of the new element to be added.

String namespace

An optional String specifying the namespace url of the new element.

String elementContent

The content of the new element.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

This API will insert an element/elements after the specified element pointed by the given XPath, to the current message. If the XPath expression points to multiple elements, new element will be added after all such elements. The content of the new element should be String. No complex types are allowed.

remove

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object.

String expression

The xpath expression to the node to be removed.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

Returns
Boolean

This API will return true if the node was removed, false otherwise.

This API will remove the node specified by XPath expression from the XML payload. This method converts the current payload of the message into a DOMMessageFormat.

extractAsStringUsingXPath

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object to extract the XPath from.

String expression

The xpath expression to evaluate against the message payload.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

Returns
String

This API will return the result of the XPath expression as a String, or empty string if there isn’t any matching elements.

This API will evaluate the given XPath expression against the XML payload, and return result as a String. This method converts the current payload into a DOMMessageFormat.

extractAsStringUsingXPath

Parameters
String s

The String containing an XML payload.

String expression

The xpath expression to evaluate against the XML String.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

Returns
String

This API will return the result of the XPath expression as a String, or empty string if there isn’t any matching elements.

This API will evaluate the given XPath expression against the XML payload contained in a String, and return the result as a String.

This will convert the given string content into a DOM document and if you by any chance already have access to the equivalent DOM, you should call the extractAsStringUsingXPath(Node, String, Map) instead of this method as that will be much more performance friendly.

extractAsStringUsingXPath

Parameters
Node n

The DOM node to be subjected to the evaluation.

String expression

The xpath expression to evaluate against the DOM node.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

Returns
String

This API will return the result of the XPath expression as a String, or empty string if there isn’t any matching elements.

This API will evaluate the given XPath expression against the provided DOM node and return the result as a String.

extractAsNodeListUsingXPath

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object to extract the XPath from.

String expression

The xpath expression to evaluate against the message payload.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

Returns
NodeList

This API will return the result of the XPath expression as an instance of org.w3c.dom.NodeList, or null if there isn’t any matching elements.

This API will evaluate the given XPath expression against the XML payload, and return result as an instance of org.w3c.dom.NodeList. This method converts the current payload into a DOMMessageFormat.

extractAsNodeListUsingXPath

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object to extract the XPath from.

Node n

The DOM node to be subjected to the evaluation.

Map<String, String> ns

An optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath expression

Returns
NodeList

This API will return the result of the XPath expression as an instance of org.w3c.dom.NodeList, or null if there isn’t any matching elements.

This API will evaluate the given XPath expression against the provided DOM node, and return result as an instance of org.w3c.dom.NodeList.

wrapPayload

Parameters
XMessage msg

The org.adroitlogic.x.api.XMessage object containing the payload to be wrapped.

String elementName

The name of the wrapper element.

String namespace

An optional namespace for the wrapper element.

This API will wrap the current XML payload with an outer element.

parseAsDOM

Parameters
InputStream is

The instance of java.io.InputStream to be converted to DOM Document.

This API will convert content of input stream into DOM Document

In this topic
In this topic
Contact Us