Thank you that is what I needed. I came across some other things, that I will mention in case anyone else runs across the same problems:
In the case you need to call something like object1.set(object2) in order to preserve the CDATA section: XmlCursor cursor = object1.newCursor(); cursor.toNextToken(); XmlCursor cursor2 = object2.newCursor() cursor2.toNextToken(); cursor2.moveXml(cursor); cursor.dispose(); cursor2.dispose(); Also I was using the XmlStreamReader, and I had to modify the following classes in order for it parse the CDATA sections appropriately: Cur, Xobj, and Jsr173. There is an isTextCData method but it was not being used when getting the eventType/kind, it would just return 4 (CHARACTERS). On Wednesday 28 May 2008 18:33:39 Radu Preotiuc-Pietro wrote: > I have played with the new CDATA feature in the upcoming XMLBeans 2.4, > and this is how you control CDATA in a new document that you are > building: > > node.setKey("ABCDE12345"); > XmlCursor c = node.xgetKey().newCursor(); > c.toFirstContentToken(); > c.setBookmark(CDataBookmark.CDATA_BOOKMARK); > > Hope this helps, > Radu > > > -----Original Message----- > > From: Bryce Fosdick > > [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, May 20, 2008 3:35 PM > > To: user@xmlbeans.apache.org > > Subject: RE: CDATA Example > > > > > > I understand the purpose of CDATA; I am just unclear on how > > to use it within XMLBeans. > > I realize that node.setKey("<![CDATA[ABCDE12345]]>") is not > > going to work (it was written to be an example of what I am > > trying to accomplish), because I am not sure how to make it > > work since key is defined as a string within the complexType > > node, containing more properties than just key. > > > > -----Original Message----- > > From: Radu Preotiuc-Pietro [mailto:[EMAIL PROTECTED] > > Sent: Tue 5/20/2008 4:52 PM > > To: user@xmlbeans.apache.org > > Subject: Re: CDATA Example > > > > CDATA is not supposed to work like that. CDATA is an escape mechanism. > > > > Calling node.setKey("<![CDATA[ABCDE12345]]>") is almost > > certainly not what you want. Call node.setKey("ABCDE12345") > > instead. But anyway, you need to refer to the XML spec or an > > XML book to learn more about CDATA first, to avoid some of > > the frustration... > > > > Radu > > > > On Mon, 2008-05-19 at 14:29 -0700, Bryce Fosdick wrote: > > > Ok so I downloaded the 2.4 source, and updated everything needed to > > > get it working but I am still having problems using the CDATA. > > > > > > If I create a Key xmlobject, the setUseCDataBookmarks seems to be > > > working correctly because if I print the xmlText it > > > > displays <Key><! > > > > > [CDATA[ABCDE12345]]></Key> > > > > > > The problem is I am trying use node.setKey(xml), where xml is the > > > string <! > > > [CDATA[ABCDE12345]]> > > > > > > Everything I have tried results in: > > > <![CDATA[ABCDE12345]]> > > > > > > Any suggestions? > > > Thanks for your help in advance. > > > > > > On Friday 16 May 2008 14:50:07 Radu Preotiuc-Pietro wrote: > > > > In regards to CDATA handling, in XMLBeans < 2.3 there is > > > > no way to > > > > > > influence the algorithm that XMLBeans uses to decide when to put a > > > > > > CDATA > > > > > > > in the output document and when not to (please note, that from the > > > > > > XML > > > > > > > Infoset point of view, use of CDATA section is not relevant as far > > > > > > as > > > > > > > the content of the document, so > > > > <Key><![CDATA[ABCDE12345]]></Key> is > > > > > > equivalent to <Key>ABCDE12345</Key>). > > > > > > > > In XMLBeans 2.3 there are some limited ways to influence > > > > when CDATA > > > > > > sections get used, the relevant XmlOptions are > > > > "setSaveCDataLengthThreshold" and > > > > > > "setSaveCDataEntityCountThreshold". > > > > > > > These XmlOptions must be used when saving the document > > > > (node.xmlText(options)). > > > > > > > > In XMLBeans > 2.3 there is a better way to control CDATA sections > > > > > > usage, > > > > > > > if you have access to the SVN source, see XmlOptions > > > > "setUseCDataBookmarks" (this option must be used on newInstance, > > > > > > like > > > > > > > you suspected). > > > > > > > > Hope this helps, > > > > Radu > > > > > > > > > -----Original Message----- > > > > > From: Bryce Fosdick [mailto:[EMAIL PROTECTED] > > > > > Sent: Thursday, May 15, 2008 11:49 AM > > > > > To: user@xmlbeans.apache.org > > > > > Subject: CDATA Example > > > > > > > > > > I am needing to create a CDATA element, but I am having no luck > > > > > and I can't find a good example. > > > > > > > > > > The contents will always be 10 characters, padded with right > > > > > spaces if needed. > > > > > > > > > > Here is an example of what needs to be created: > > > > > <Key><![CDATA[ABCDE12345]]></Key> > > > > > > > > > > Here is the path I was heading down: > > > > > XmlOptions options = new XmlOptions(); ... (I'm not sure what > > > > > these should be) XmlString xml = > > > > > XmlString.Factory.newInstance(options); > > > > > xml.setStringValue("ABCDE12345"); > > > > > node.setKey(xml.getStringValue()); > > > > --------------------------------------------------------------------- > > > > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > Notice: This email message, together with any attachments, may > > > > > > contain > > > > > > > information of BEA Systems, Inc., its subsidiaries and > > > > > > affiliated > > > > > > > entities, that may be confidential, proprietary, copyrighted > > > > > > and/or > > > > > > > legally privileged, and is intended solely for the use of the > > > > > > individual or > > > > > > > entity named in this message. If you are not the intended > > > > recipient, > > > > > and > > > > > > > have received this message in error, please immediately > > > > return this > > > > > by > > > > > > > email and then delete it. > > > > --------------------------------------------------------------------- > > > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- > > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > Notice: This email message, together with any attachments, > > may contain information of BEA Systems, Inc., its > > subsidiaries and affiliated entities, that may be > > confidential, proprietary, copyrighted and/or legally > > privileged, and is intended solely for the use of the > > individual or entity named in this message. If you are not > > the intended recipient, and have received this message in > > error, please immediately return this by email and then delete it. > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > Notice: This email message, together with any attachments, may contain > information of BEA Systems, Inc., its subsidiaries and affiliated > entities, that may be confidential, proprietary, copyrighted and/or > legally privileged, and is intended solely for the use of the individual or > entity named in this message. If you are not the intended recipient, and > have received this message in error, please immediately return this by > email and then delete it. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]