Class XpathDocumentCopier
- java.lang.Object
-
- com.adaptris.core.services.splitter.MessageSplitterImp
-
- com.adaptris.core.services.splitter.MessageCopier
-
- com.adaptris.core.services.splitter.XpathDocumentCopier
-
- All Implemented Interfaces:
MessageSplitter
public class XpathDocumentCopier extends MessageCopier
Implementation of
MessageSplitter
which creates multiple instances of the same XML document based on an XPath.The split messages will always contain the entire document, the XPath evaluation simply provides information on how many documents to produce and should always return an integer.
Given the following input document
<envelope> <document>one</document> <document>two</document> <document>three</document> </envelope>
count(/envelope/document)
to split into 3 documents; each of which contains the whole XML document.If the
DocumentBuilderFactoryBuilder
has been explicitly set to be not namespace aware and the document does in fact contain namespaces, then Saxon can cause merry havoc in the sense that//NonNamespaceXpath
doesn't work if the document has namespaces in it. We have included a shim so that behaviour can be toggled based on what you have configured.- See Also:
XPath.newXPathInstance(DocumentBuilderFactoryBuilder, NamespaceContext)
In the adapter configuration file this class is aliased as xpath-document-copier which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.adaptris.core.services.splitter.MessageCopier
MessageCopier.MessageCallback, MessageCopier.MessageCopierIterator
-
Nested classes/interfaces inherited from class com.adaptris.core.services.splitter.MessageSplitterImp
MessageSplitterImp.SplitMessageIterator
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.services.splitter.MessageSplitterImp
logR
-
-
Constructor Summary
Constructors Constructor Description XpathDocumentCopier()
XpathDocumentCopier(java.lang.String xpath)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyValuePairSet
getNamespaceContext()
DocumentBuilderFactoryBuilder
getXmlDocumentFactoryConfig()
java.lang.String
getXpath()
Get the XPath to use to extract the individual messages.void
setNamespaceContext(KeyValuePairSet kvps)
Set the namespace context for resolving namespaces.void
setXmlDocumentFactoryConfig(DocumentBuilderFactoryBuilder xml)
void
setXpath(java.lang.String xp)
Set the XPath to use to extract the individual messagesCloseableIterable<AdaptrisMessage>
splitMessage(AdaptrisMessage msg)
Splits anAdaptrisMessage
into some number of AdaptrisMessage objects.-
Methods inherited from class com.adaptris.core.services.splitter.MessageCopier
duplicateWithPayload, toInteger
-
Methods inherited from class com.adaptris.core.services.splitter.MessageSplitterImp
copyMetadata, getCopyMetadata, getCopyObjectMetadata, getMessageFactory, selectFactory, setCopyMetadata, setCopyObjectMetadata, setMessageFactory
-
-
-
-
Method Detail
-
splitMessage
public CloseableIterable<AdaptrisMessage> splitMessage(AdaptrisMessage msg) throws CoreException
Description copied from interface:MessageSplitter
Splits an
AdaptrisMessage
into some number of AdaptrisMessage objects. Preservation of metadata is down to the implementation.If this method returns a
CloseableIterable
, it must be closed by the caller! This contract cannot be clearly expressed in Java code without breaking the API in uncomfortable ways for things just returning a List, which is why this method is only declared to return Iterable.- Parameters:
msg
- the msg to split- Returns:
- an
Iterable
ofAdaptrisMessage
- Throws:
CoreException
- wrapping any other exception
-
setXpath
public void setXpath(java.lang.String xp)
Set the XPath to use to extract the individual messages- Parameters:
xp
- the XPath
-
getXpath
public java.lang.String getXpath()
Get the XPath to use to extract the individual messages.- Returns:
- the XPath as a String
-
getNamespaceContext
public KeyValuePairSet getNamespaceContext()
- Returns:
- the namespaceContext
-
setNamespaceContext
public void setNamespaceContext(KeyValuePairSet kvps)
Set the namespace context for resolving namespaces.- The key is the namespace prefix
- The value is the namespace uri
- Parameters:
kvps
- the namespace context- See Also:
SimpleNamespaceContext.create(KeyValuePairSet)
-
getXmlDocumentFactoryConfig
public DocumentBuilderFactoryBuilder getXmlDocumentFactoryConfig()
-
setXmlDocumentFactoryConfig
public void setXmlDocumentFactoryConfig(DocumentBuilderFactoryBuilder xml)
-
-