Reputation: 63
I'm using the <base64>
element to unmarshal base64 code that comes as part of an XML. The route looks like this:
<route>
<split streaming="true" strategyRef="myAggregationStaregy">
<xpath>/*/*</xpath>
<choice>
<when>
<xpath>//record</xpath>
<to uri="file:/record.xml" />
</when>
<when>
<xpath>//content</xpath>
<unmarshal>
<base64 />
</unmarshal>
<to uri="file:/content.bin" />
</when>
</choice>
</split>
</route>
While the XML splitting works fine the <unmarshal>
task returns rubbish. The result binary is exacly of the expected size but the bytes themselves are completely wrong.
Attempts:
lineSeparator
and lineLength
options had no effect.<unmarshal>
block in the route and transforming the resulting base64 code by hand (linux base64
command) I receive the correct binary.Any ideas?
Upvotes: 0
Views: 850
Reputation: 63
Meanwhile I found the solution:
I expected the <xpath>//content</xpath>
statement to filter the incoming XML so that the message body containes only the part inside the content
element.
But this was wrong. This "xpath" statement is the "when" statement's predicate and it does no filtering at all.
In order to achieve the intended behaviour I had to explicitly extract my XML's "content" part and write it to the message body (using a "setBody" statement). My route finally looks like this:
<route>
<split>
<xpath>/*/*</xpath>
<choice>
<when>
<xpath>//record</xpath>
<to uri="file:/record.xml" />
</when>
<when>
<xpath>//content</xpath>
<setBody><xpath>//content/text()</xpath></setBody>
<unmarshal>
<base64 />
</unmarshal>
<to uri="file:/content.bin" />
</when>
</choice>
</split>
</route>
Upvotes: 1