Available as of Camel 2.9
The StAX component allows messages to be process through a SAX ContentHandler.
Maven users will need to add the following dependency to their pom.xml for this component:
From Camel 2.11.1 onwards you can lookup a org.xml.sax.ContentHandler bean from the Registry using the # syntax as shown:
The message body after the handling is the handler itself.
Here an example:
First we suppose you have JAXB objects.
For instance a list of records in a wrapper object:
Then you get a XML file to process:
The StAX component provides an StAXBuilder which can be used when iterating XML elements with the Camel Splitter
Where stax is a static method on org.apache.camel.component.stax.StAXBuilder which you can static import in the Java code. The stax builder is by default namespace aware on the XMLReader it uses. From Camel 2.11.1 onwards you can turn this off by setting the boolean parameter to false, as shown below:
The example above could be implemented as follows in XML DSL