[prev in list] [next in list] [prev in thread] [next in thread]
List: xmlbeans-user
Subject: RE: CDATA Example
From: "Radu Preotiuc-Pietro" <radup () bea ! com>
Date: 2008-05-28 23:33:39
Message-ID: BF6B6CA032BA0A429BD924F96765147DCC6461 () repbex02 ! amer ! bea ! com
[Download RAW message or body]
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:bryce.fosdick@interactivehotelsolutions.com]
> 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:radup@bea.com]
> 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:bryce.fosdick@ihsadvantage.com]
> > > > 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: user-unsubscribe@xmlbeans.apache.org
> > > > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > >
> > > 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: user-unsubscribe@xmlbeans.apache.org
> > > For additional commands, e-mail: user-help@xmlbeans.apache.org
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> >
> >
> >
>
> 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: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>
>
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: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic