You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by David Sharpe <ni...@gmail.com> on 2016/08/18 21:47:59 UTC

JAXB: Marshal class containing String containing XML

Hello fellow Camel users,

(Using Camel 2.15.3)

The legacy system and XML schema I'm working with has a frustrating use
case where the (@XmlValue) String property of a JAXB annotated class
contains XML that should be marshalled as-is without escaping, but what I'm
getting is this:

<someElement>
    <someMoreElements props="values"/>
    <text>
         &lt;evenMoreElements xsi:nil="true"/&gt;
<!-- ETC -->

The "text" element is supposed to contain valid XML, but instead the
contents appears to be encoded ("<" are encoded as "&lt;", but I'm
surprised to see that quotes aren't encoded!).

I had thought that the "mustBeJAXBElement" property might help me ("There
can be situations where the message body is already in XML, eg from a
String type...", http://camel.apache.org/jaxb.html), but it has no
discernable affect on the output.

I've done some Googling of course and found some helpful posts (
http://stackoverflow.com/questions/5537416/using-jaxb-to-extract-inner-text-of-xml-element/5553682#5553682),
but I'm emailing you to find out if any Camel users have dealt with this
issue before, and whether you found a good Camel solution.

Regards,
David