JAXB: Failing to parse embedded processed HTML in a tag
843834Jan 14 2003 — edited Jan 15 2003In my application, I'm pulling data from an XML file which originally contained a
<choice> <any/> </choice>
construct in the XSD, used to embed HTML into an XML document. During processing, I pull the contents in as a string, and change all references to "<" to "<" and all references to ">" to ">", and then rewrite in a different form.
So, for example, what might originally have been:
<tag>This is an example.
It will show you what happens.</tag>
becomes:
<tag>This is an example.<br/>It will show you what happens.</tag>
This all seems fine, until I try to parse a file generated using this method using JAXB, where the <tag> definition is of type xsd:string. In that case, it appears that JAXB is incorrectly ignoring the fact that there isn't any well-formed XML in the tag and attempting to parse, because I get a "javax.xml.bind.UnmarshallException: Unexpected element{}:br" exception, indicating that at some point during JAXB unmarshalling it decided to convert "<" into "<" and then introduce that in while parsing.
Short of changing the generation code (which is infeasible) to wrap my HTML in <!CDATA[]]> tags, is there any way to work around this? This appears to be a bug to me in the JAXB 1.0beta implementation, unless there's some subtlety that I'm missing.
Kirk Wylie