Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JAXB: Failing to parse embedded processed HTML in a tag

843834Jan 14 2003 — edited Jan 15 2003
In 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 "&lt;" to "<" and all references to ">" to "&gt;", 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.&lt;br/&gt;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 "&lt;" 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 12 2003
Added on Jan 14 2003
4 comments
487 views