@IntegrationFeature(clazz=XMLFeature.class, name="xml") public class XMLFeatureImpl extends org.adroitlogic.x.api.AbstractIntegrationFeature implements XMLFeature
XMLFeature
Constructor and Description |
---|
XMLFeatureImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addAttributeToElements(org.adroitlogic.x.api.XMessage msg,
String expression,
String qName,
String nsUri,
String value,
Map<String,String> ns)
Add an attribute to one or more elements selected by an XPath expression
e.g.
|
void |
addElementsAsChild(org.adroitlogic.x.api.XMessage msg,
String expression,
String qualifiedTagName,
String namespace,
Map<String,String> ns)
Inserts Element as a child to the specified elements pointed by an xpath expression
|
void |
addTextElementsAsChild(org.adroitlogic.x.api.XMessage msg,
String expression,
String qualifiedTagName,
String namespace,
String elementContent,
Map<String,String> ns)
Inserts Text Element as a child to the specified elements pointed by an xpath expression
|
void |
convertToDOM(org.adroitlogic.x.api.XMessage m)
Convert the current message into a DOMMessage
|
void |
createAndCacheTransformers(URI xsltFileURI)
Creates and caches a "minTransformerCount" number of XSLT transformers for the given XSLT file URI
|
Document |
createDOMDocument()
Create a new DOM Document object and return
|
void |
deleteAttributes(org.adroitlogic.x.api.XMessage msg,
String expression,
Map<String,String> ns)
Deletes the specified attribute/s
e.g.
|
void |
deleteElements(org.adroitlogic.x.api.XMessage msg,
String expression,
Map<String,String> ns)
Delete Elements pointed by an xpath expression
|
void |
destroy() |
NodeList |
extractAsNodeListUsingXPath(Node n,
String expression,
Map<String,String> ns)
Evaluate the given XPath expression against the DOM node, and return result as a NodeList
|
NodeList |
extractAsNodeListUsingXPath(org.adroitlogic.x.api.XMessage m,
String expression,
Map<String,String> ns)
Evaluate the given XPath expression against the XML payload, and return result as a NodeList
This method converts the current payload into a DOMMessage
|
String |
extractAsStringUsingXPath(Node n,
String expression,
Map<String,String> ns)
Evaluate the given XPath expression against the DOM node, and return result as a String
|
String |
extractAsStringUsingXPath(String s,
String expression,
Map<String,String> ns)
Evaluate the given XPath expression against the XML payload contained in a String, and return result as a String.
|
String |
extractAsStringUsingXPath(org.adroitlogic.x.api.XMessage m,
String expression,
Map<String,String> ns)
Evaluate the given XPath expression against the XML payload, and return result as a String
This method converts the current payload into a DOMMessage
|
boolean |
filter(org.adroitlogic.x.api.XMessage m,
String expression,
Map<String,String> ns)
Evaluate the given boolean XPath expression over the XML payload
|
boolean |
filter(org.adroitlogic.x.api.XMessage m,
String expression,
String regex,
Map<String,String> ns)
Evaluate the given XPath expression over the XML payload and compare the resulting String value with the
regular expression for a match.
|
String |
getAttribute(org.adroitlogic.x.api.XMessage msg,
String expression,
Map<String,String> ns)
Get attribute value
e.g.
|
Document |
getPayloadAsDOM(org.adroitlogic.x.api.XMessage m)
Returns payload of the message as a DOM Document
|
String |
getTextElement(org.adroitlogic.x.api.XMessage msg,
String expression,
Map<String,String> ns)
Get text element value for given XPath
|
void |
init(org.springframework.context.ApplicationContext context) |
void |
insertTextElementsAfter(org.adroitlogic.x.api.XMessage msg,
String expression,
String qualifiedTagName,
String namespace,
String elementContent,
Map<String,String> ns)
Inserts an element/elements after the specified element pointed by the XPATH, to the current message.
|
void |
insertTextElementsBefore(org.adroitlogic.x.api.XMessage msg,
String expression,
String qualifiedTagName,
String namespace,
String elementContent,
Map<String,String> ns)
Inserts an element/elements before the specified element pointed by the XPATH, to the current message.
|
void |
mergeXMLAttachmentsUnderElement(org.adroitlogic.x.api.XMessage msg,
String rootElemName)
Replace the current XML payload with a top level element as specified, and merge the attachments of the message
underneath that
|
void |
mergeXMLAttachmentsUnderElement(org.adroitlogic.x.api.XMessage msg,
String rootElemName,
String rootNS)
Replace the current XML payload with a top level element as specified, and merge the attachments of the message
underneath that
|
boolean |
remove(org.adroitlogic.x.api.XMessage m,
String expression,
Map<String,String> ns)
Remove the XPath expression specified node from the XML payload.
|
void |
replaceAttributes(org.adroitlogic.x.api.XMessage msg,
String expression,
String value,
Map<String,String> ns)
Replaces the specified attribute/s value
|
void |
replaceTextElements(org.adroitlogic.x.api.XMessage msg,
String expression,
String elementContent,
Map<String,String> ns)
Replace Text Elements pointed by an xpath expression
|
void |
retainElementAsPayload(org.adroitlogic.x.api.XMessage m,
String expression,
Map<String,String> ns)
Replace the current XML payload with the resulting element from the XPath expression result
|
void |
serialize(Document document,
OutputStream os)
Serialize the DOM Document into the given OutputStream
|
void |
setPayloadFromDOM(org.adroitlogic.x.api.XMessage m,
Document doc)
Set the payload of the message with the DOM Document
|
void |
transform(org.adroitlogic.x.api.XMessage msg,
URI xsltFileURI)
Transform the message payload by XSLT (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
|
void |
transform(org.adroitlogic.x.api.XMessage msg,
URI xsltFileURI,
String expression,
boolean domResult,
Map<String,Object> parameters,
Map<String,String> ns)
Transform the message payload by XSLT
|
void |
transform(org.adroitlogic.x.api.XMessage msg,
URI xsltFileURI,
String expression,
Map<String,String> ns)
Transform the message payload by XSLT (without any parameters), assuming a non DOM result
|
void |
validate(Node n,
URI... schemaFileURIs)
Validates the given DOM Node against one or more schemas.
|
void |
validate(String s,
URI... schemaFileURIs)
Validates the given String against one or more schemas.
|
void |
validate(org.adroitlogic.x.api.XMessage m,
URI... schemaFileURIs)
Validates the given message against one or more schemas.
|
void |
validate(org.adroitlogic.x.api.XMessage m,
URI[] schemaFileURIs,
String expression,
Map<String,String> ns)
Validates the current message - or an element of it selected via the provided XPath expression - against one or
more schemas.
|
void |
validateAll(org.adroitlogic.x.api.XMessage m,
URI[] schemas,
String expression,
Map<String,String> ns)
Validate the current message - or all elements of it selected via the provided XPath expression - against one or
more schemas.
|
void |
wrapPayload(org.adroitlogic.x.api.XMessage msg,
String elementName,
String namespace)
Wrap the XML payload with an outer element
|
public void init(org.springframework.context.ApplicationContext context)
init
in interface org.adroitlogic.x.api.dec.Initializable
init
in class org.adroitlogic.x.api.AbstractIntegrationFeature
public void destroy()
destroy
in interface org.adroitlogic.x.api.dec.Initializable
destroy
in class org.adroitlogic.x.api.AbstractIntegrationFeature
public Document createDOMDocument()
XMLFeature
createDOMDocument
in interface XMLFeature
public void serialize(Document document, OutputStream os)
XMLFeature
serialize
in interface XMLFeature
document
- the Document to serializeos
- the target OutputStreampublic void setPayloadFromDOM(org.adroitlogic.x.api.XMessage m, Document doc)
XMLFeature
setPayloadFromDOM
in interface XMLFeature
m
- the current message whose payload will be set with the DOM messagedoc
- the DOM document to be inserted as the payloadpublic Document getPayloadAsDOM(org.adroitlogic.x.api.XMessage m)
XMLFeature
getPayloadAsDOM
in interface XMLFeature
m
- the current message to be passedpublic void convertToDOM(org.adroitlogic.x.api.XMessage m)
XMLFeature
convertToDOM
in interface XMLFeature
m
- the current message to be transformedpublic void retainElementAsPayload(org.adroitlogic.x.api.XMessage m, String expression, Map<String,String> ns)
XMLFeature
retainElementAsPayload
in interface XMLFeature
m
- the current messageexpression
- XPath expression selecting the node to retainns
- an optional map with namespace prefixes (as keys) and namespaces (as values) used within the
XPath expressionpublic void mergeXMLAttachmentsUnderElement(org.adroitlogic.x.api.XMessage msg, String rootElemName)
XMLFeature
mergeXMLAttachmentsUnderElement
in interface XMLFeature
msg
- the message to transformrootElemName
- the new root element createdpublic void mergeXMLAttachmentsUnderElement(org.adroitlogic.x.api.XMessage msg, String rootElemName, String rootNS)
XMLFeature
mergeXMLAttachmentsUnderElement
in interface XMLFeature
msg
- the message to transformrootElemName
- the new root element createdrootNS
- optional namespace for the root element, or nullpublic void validate(org.adroitlogic.x.api.XMessage m, URI... schemaFileURIs)
XMLFeature
IntegrationRuntimeException
with details of the XSD validation failuresvalidate
in interface XMLFeature
m
- the message holding the payload for validationschemaFileURIs
- an array of XSD file URIs to validate against
Note: 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.
It is advised to use the AbstractProcessingElement.getResource(String filePath)
method to get the URI from a file path
public void validate(String s, URI... schemaFileURIs)
XMLFeature
IntegrationRuntimeException
with details of the XSD validation failuresvalidate
in interface XMLFeature
s
- the XML stringschemaFileURIs
- an array of XSD file URIs to validate against
Note: 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"
It is advised to use the AbstractProcessingElement.getResource(String filePath)
method to get the URI from a file path
public void validate(Node n, URI... schemaFileURIs)
XMLFeature
IntegrationRuntimeException
with details of the XSD validation failuresvalidate
in interface XMLFeature
n
- the DOM Node containing the XML to be validatedschemaFileURIs
- an array of XSD file URIs to validate against
Note: 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"
It is advised to use the AbstractProcessingElement.getResource(String filePath)
method to get the URI from a file path
public void validate(org.adroitlogic.x.api.XMessage m, URI[] schemaFileURIs, String expression, Map<String,String> ns)
XMLFeature
IntegrationRuntimeException
with details of the
XSD validation failuresvalidate
in interface XMLFeature
m
- the message holding the payload for validationschemaFileURIs
- an array of XSD file URIs to validate against
Note: 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"
It is advised to use the AbstractProcessingElement.getResource(String filePath)
method to get the URI from a file path
expression
- an optional XPath expression selecting the node for validationns
- an optional map with namespace prefixes (as keys) and namespaces (as values) used within
the XPath expressionpublic void validateAll(org.adroitlogic.x.api.XMessage m, URI[] schemas, String expression, Map<String,String> ns)
XMLFeature
IntegrationRuntimeException
with details of the XSD
validation failuresvalidateAll
in interface XMLFeature
m
- the message holding the payload for validationschemas
- an array of XSD file URIs to validate against
Note: 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"
It is advised to use the AbstractProcessingElement.getResource(String filePath)
method to get the URI from a file path
expression
- an optional XPath expression selecting the nodes for validationns
- an optional map with namespace prefixes (as keys) and namespaces (as values) used within
the XPath expressionpublic void createAndCacheTransformers(URI xsltFileURI)
XMLFeature
createAndCacheTransformers
in interface XMLFeature
xsltFileURI
- URI of the XSLT file to be used for the transformationpublic void transform(org.adroitlogic.x.api.XMessage msg, URI xsltFileURI, String expression, boolean domResult, Map<String,Object> parameters, Map<String,String> ns)
XMLFeature
transform
in interface XMLFeature
msg
- current messagexsltFileURI
- the XSLT file URIexpression
- an optional XPath expression to select the source node for XSLT, and node to replace with the
resultdomResult
- is the result desired as a DOM payload? (useful for further XML processing)parameters
- any XSLT parameters to be passed to the transformationns
- an optional map with namespace prefixes (as keys) and namespaces (as values) used within
the XPath expressionpublic void transform(org.adroitlogic.x.api.XMessage msg, URI xsltFileURI, String expression, Map<String,String> ns)
XMLFeature
transform
in interface XMLFeature
msg
- current messagexsltFileURI
- the XSLT filenameexpression
- an optional XPath expression to select the source node for XSLT, and node to replace with the
resultns
- an optional map with namespace prefixes (as keys) and namespaces (as values) used within
the XPath expressionpublic void transform(org.adroitlogic.x.api.XMessage msg, URI xsltFileURI)
XMLFeature
transform
in interface XMLFeature
msg
- current messagexsltFileURI
- the XSLT filenamepublic boolean filter(org.adroitlogic.x.api.XMessage m, String expression, String regex, Map<String,String> ns)
XMLFeature
filter
in interface XMLFeature
m
- the current messageexpression
- the XPath expression to evaluate against the message payloadregex
- an optional regular expression to evaluate the XPath results' String value againstns
- an optional map with namespace prefixes (as keys) and namespaces (as values) used within
the XPath expressionpublic boolean filter(org.adroitlogic.x.api.XMessage m, String expression, Map<String,String> ns)
XMLFeature
filter
in interface XMLFeature
m
- the current messageexpression
- the XPath expression to evaluate against the message payloadns
- an optional map with namespace prefixes (as keys) and namespaces (as values) used within
the XPath expressionpublic void addAttributeToElements(org.adroitlogic.x.api.XMessage msg, String expression, String qName, String nsUri, String value, Map<String,String> ns)
XMLFeature
addAttributeToElements
in interface XMLFeature
msg
- the message where the transformation is performedexpression
- the xpath expression to select the elements where the attribute should be addedqName
- the qualified name for the new attribute. To specify a custom prefix use it here
(e.g. "myns:myqname")nsUri
- the namespace URI for the new attribute, or null (to specify a custom prefix, see qName above)value
- the new value of the attributens
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath
expressionpublic String getAttribute(org.adroitlogic.x.api.XMessage msg, String expression, Map<String,String> ns)
XMLFeature
getAttribute
in interface XMLFeature
msg
- the message to read the attribute fromexpression
- the xpath expression to the element from where the attribute should be retrievedns
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath
expressionpublic void deleteAttributes(org.adroitlogic.x.api.XMessage msg, String expression, Map<String,String> ns)
XMLFeature
deleteAttributes
in interface XMLFeature
msg
- the current message containing the payloadexpression
- the xpath expression to the attributes, which are to be deletedns
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath
expressionpublic void replaceAttributes(org.adroitlogic.x.api.XMessage msg, String expression, String value, Map<String,String> ns)
XMLFeature
replaceAttributes
in interface XMLFeature
msg
- the current message containing the payloadexpression
- the xpath expression to the attribute, which is to be replacedvalue
- the new value of the attributens
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath
expressionpublic void addTextElementsAsChild(org.adroitlogic.x.api.XMessage msg, String expression, String qualifiedTagName, String namespace, String elementContent, Map<String,String> ns)
XMLFeature
addTextElementsAsChild
in interface XMLFeature
msg
- the current message containing the payloadexpression
- the xpath expression to the node/s, which will be the parent for the new node/squalifiedTagName
- the qualified name of the new element to be addednamespace
- an optional String specifying the namespace url of the new elementelementContent
- the text content of the new elementns
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the
XPath expressionpublic void addElementsAsChild(org.adroitlogic.x.api.XMessage msg, String expression, String qualifiedTagName, String namespace, Map<String,String> ns)
XMLFeature
addElementsAsChild
in interface XMLFeature
msg
- the current message containing the payloadexpression
- the xpath expression to the node/s, which will be the parent for the new node/squalifiedTagName
- the qualified name of the new element to be addednamespace
- an optional String specifying the namespace url of the new elementns
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the
XPath expressionpublic String getTextElement(org.adroitlogic.x.api.XMessage msg, String expression, Map<String,String> ns)
XMLFeature
getTextElement
in interface XMLFeature
msg
- the message to read the attribute fromexpression
- the xpath expression to the element where the text content should be readns
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath
expressionpublic void replaceTextElements(org.adroitlogic.x.api.XMessage msg, String expression, String elementContent, Map<String,String> ns)
XMLFeature
replaceTextElements
in interface XMLFeature
msg
- the current message containing the payloadexpression
- the xpath expression to the text elements to be replacedelementContent
- the text content of the new element/sns
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the
XPath expressionpublic void deleteElements(org.adroitlogic.x.api.XMessage msg, String expression, Map<String,String> ns)
XMLFeature
deleteElements
in interface XMLFeature
msg
- the current message containing the payloadexpression
- the xpath expression to the text elements to be replacedns
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the
XPath expressionpublic void insertTextElementsBefore(org.adroitlogic.x.api.XMessage msg, String expression, String qualifiedTagName, String namespace, String elementContent, Map<String,String> ns)
XMLFeature
insertTextElementsBefore
in interface XMLFeature
msg
- the current message containing the payloadexpression
- the xpath expression to the node, where the new element should be added beforequalifiedTagName
- the qualified tag name of the new element to be addednamespace
- namespace uri for the new tagelementContent
- the content of the new elementns
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the
XPath expressionpublic void insertTextElementsAfter(org.adroitlogic.x.api.XMessage msg, String expression, String qualifiedTagName, String namespace, String elementContent, Map<String,String> ns)
XMLFeature
insertTextElementsAfter
in interface XMLFeature
msg
- the current message containing the payloadexpression
- the xpath expression to the node, where the new element should be added afterqualifiedTagName
- the qualified tag name of the new element to be addednamespace
- namespace uri for the new tagelementContent
- the content of the new elementns
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the
XPath expressionpublic boolean remove(org.adroitlogic.x.api.XMessage m, String expression, Map<String,String> ns)
XMLFeature
remove
in interface XMLFeature
m
- the current messageexpression
- the XPath expression to evaluate against the message payloadns
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath
expressionpublic String extractAsStringUsingXPath(org.adroitlogic.x.api.XMessage m, String expression, Map<String,String> ns)
XMLFeature
extractAsStringUsingXPath
in interface XMLFeature
m
- the current messageexpression
- the XPath expression to evaluate against the message payloadns
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath
expressionpublic String extractAsStringUsingXPath(String s, String expression, Map<String,String> ns)
XMLFeature
XMLFeature.extractAsStringUsingXPath(Node, String, Map)
instead of this method as that will be
much more performance friendlyextractAsStringUsingXPath
in interface XMLFeature
s
- a String containing an XML payloadexpression
- the XPath expression to evaluate against the XML payloadns
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath
expressionpublic String extractAsStringUsingXPath(Node n, String expression, Map<String,String> ns)
XMLFeature
extractAsStringUsingXPath
in interface XMLFeature
n
- DOM node to be subjected to the evaluationexpression
- the XPath expression to evaluate against the DOM nodens
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath
expressionpublic NodeList extractAsNodeListUsingXPath(org.adroitlogic.x.api.XMessage m, String expression, Map<String,String> ns)
XMLFeature
extractAsNodeListUsingXPath
in interface XMLFeature
m
- the current messageexpression
- the XPath expression to evaluate against the message payloadns
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath
expressionpublic NodeList extractAsNodeListUsingXPath(Node n, String expression, Map<String,String> ns)
XMLFeature
extractAsNodeListUsingXPath
in interface XMLFeature
n
- DOM node to be subjected to the evaluationexpression
- the XPath expression to evaluate against the message payloadns
- optional map with namespace prefixes (as keys) and namespaces (as values) used within the XPath
expressionpublic void wrapPayload(org.adroitlogic.x.api.XMessage msg, String elementName, String namespace)
XMLFeature
wrapPayload
in interface XMLFeature
msg
- the message containing the payload to be wrappedelementName
- name of the wrapper elementnamespace
- optional namespace or nullCopyright © 2016–2019 AdroitLogic. All rights reserved.