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 and CDATA sections

843834Jul 16 2002 — edited Oct 13 2008
Hi,

I'm using JAXB to read in XML data like the following:

<OBJECT id="TABLET-REPORT">
<ATTRIBUTE name="STYLE">
<VALUE><![CDATA[formulogic.css]]></VALUE>
</ATTRIBUTE>
<ATTRIBUTE name="LABEL">
<VALUE><![CDATA[~a]]></VALUE>
</ATTRIBUTE>
<ATTRIBUTE name="HEADER">
<VALUE><![CDATA[ </tr>]]></VALUE>
<VALUE><![CDATA[ <th class="maintext" width="10%" align="center">Cost
per Tab</td>]]></VALUE>
</ATTRIBUTE>
</OBJECT>

JAXB doesn't seem to have a problem with the CDATA sections, but I can't
actually detect that they're there--so I just get the content back.

I was using the CDATA section to indicate that the contents were in a
string, so I actually want to treat the following two differently:
<VALUE><![CDATA[~a]]></VALUE>
<VALUE>~a</VALUE>

Anyone have any good ideas how to do this?

Also, when writing out, if I have a string with quotes in it (ie
"\"fred\""); I'd like to write this out as
<VALUE><![CDATA[fred]]></VALUE>

I can't see any way to do this with JAXB.

Thanks in advance.
Denis

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 10 2008
Added on Jul 16 2002
4 comments
431 views