How to right use Split EIP by xpath in my case?
Example data:
<bookstore>
<book category="COOKING"/>
<book category="CHILDREN"/>
<book category="WEB"/>
</bookstore>
What is the right way to process in for-loop values of attribute “category” of “book” node?
Why is my route doesn’t work correctly?
<route>
<from uri="..."/>
<split>
<xpath>//book/@category</xpath>
<log message="body = ${body}"/>
</split>
</route>
The log contains an empty body 3 times. The body class is com.sun.org.apache.xerces.internal.dom.DeferredAttrNSImpl.
- Do I miss some dependencies that contain the correct type converter from attribute to String?
- Should I define converter by myself?
- Should I split by //book nodes and inside set body with xpath “/*/@category” (yes, it’s works correctly).
- Is it a bug?
I want to understand why it work like that and what a correct way to solve?
P.S. convertBodyTo doesn’t help
P.P.S. Working, but less readable solutuion (body type com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList)
<route>
<from uri="..."/>
<split>
<xpath>//book</xpath>
<setBody>
<xpath>/*/@category</xpath>
</setBody>
<log message="body = ${body}"/>
</split>
</route>