Apama 10.15.0 | Connecting Apama Applications to External Components | Standard IAF Plug-ins | Codec IAF Plug-ins | The XML codec IAF plug-in | About the XML parser
 
About the XML parser
On startup, the XML codec logs the names of the classes it is using for XML parsing and XML generation. For example:
INFO [11808] - XMLCodec: Encoder initialized: using XML Document builder
'org.apache.xerces.jaxp.DocumentBuilderImpl'
INFO [11808] - XMLCodec: Decoder initialized: using Streaming API for XML (StAX)
'com.ctc.wstx.stax.WstxInputFactory'
Apama uses Xerces for encoding (creating XML docs) and Woodstox StAX for decoding (parsing).
XML namespace support
If your application relies on the standard XML parsing/generation behavior (that is, not XPath) there is no concept of "declaring namespaces" in the XML codec nor is it required as long as the XML document is valid (that is, it declares any namespace prefixes it uses) then you can just use namespaceprefix:elementName when referring to elements in your mapping rules. If there is any doubt, you can run your sample message through the XMLCodec property logFlattenedXML=true and it will show you what to specify in your mapping rules, for example, consider the following sample message:
<h:table xmlns:h="http://www.myco.com/apama/test/testnamespace_h/"
xmlns="http://www.myco.com/apama/test/testnamespace_default">
<h:tr>
<h:td>Apples</h:td>
<td>Bananas</td>
</h:tr>
</h:table>
With the above sample message you could use mapping rules such as:
<map type="string" default="" apama="default_namespace"
transport="Body.h:table/@xmlns"/>
<map type="string" default="" apama="prefix_namespace"
transport="Body.h:table/@xmlns:h"/>
<map type="string" default="" apama="prefixed_element_text"
transport="Body.h:table/h:tr/h:td/text()"/>
<map type="string" default="" apama="non_prefixed_element_text"
transport="Body.h:table/h:tr/td/text()"/>
If you use XPath in your application, XPath itself contains operators to access the local (non-namespace) name and namespace URI of any XML content. However it is often convenient to define some global prefixes to make it easier to refer to namespaced elements. Apama supports this by allowing any number of XPathNamespace:myprefix codec properties, whose value is the URN that the specified prefix should point to. For example,
<property name="XPathNamespace:b" value="urn:xmlns:mynamespace"/>
would allow XPath expressions to use "b" to refer to elements in the "mynamespace" namespace:
<property name="XPath:Test.root/b:elementname/text()"/>