File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes JAXB: Creating a message with a CDATA section Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JAXB: Creating a message with a CDATA section" Watch "JAXB: Creating a message with a CDATA section" New topic
Author

JAXB: Creating a message with a CDATA section

Rick Portugal
Ranch Hand

Joined: Dec 17, 2002
Posts: 243
How can I use JAXB to create an XML message that contains a CDATA tag?
I want to create an XML message that looks like this:

<thisTag><![CDATA[
123 456
789 321 ]]></thisTag>

But I can't figure out how to get "CDATA" to appear in the message.


IBM 286, SCJP, SCWCD, EIEIO
Rick Portugal
Ranch Hand

Joined: Dec 17, 2002
Posts: 243
I tried to force the CDATA tag by prepending the string "<!CDATA[[" to the contents of my data. But JAXB translated it to "& l t ; !CDATA[[". Does anybody know how to tell JAXB not to convert "<" to "& l t ;"?
[ December 29, 2004: Message edited by: Rick Portugal ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12787
    
    5
The org.w3c.dom.Document class has a method:
createCDATASection( String contents )
I'm not sure where JAXB fits into this, but Java 1.4 includes that package as part of the normal library.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAXB: Creating a message with a CDATA section