You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Jurica Krizanic <jk...@gmail.com> on 2012/07/27 11:05:05 UTC

CDATA saving problem

Hello,
I am uxing XMLBeans 2.5.0 and having an issue with saving XML to the file..
When the XML is saved to the file, CDATA section marks are removed, but
content inside the CDATA remains in the file.

I would like CDATA marks also remain in the file.

I was trying to set XMLOptions with setSaveCDataLengthThreshold() and
setSaveCDataEntityCountThreshold()
methods,
browsing through already asked questions on the mailing list,  but I can't
get it work correctly.

Can someone provide any help?


Thank you in advance!

Best regards,
Jurica Krizanic

Re: CDATA saving problem

Posted by VikingBlue <ma...@uhc.com>.
I tried with Following code, but nothing works, what did I miss?

XmlOptions xmlOptions = new XmlOptions();
xmlOptions.setUseCDataBookmarks();
xmlOptions.setSaveCDataEntityCountThreshold(0);
xmlOptions.setSaveCDataLengthThreshold(1);
XmlObject response = XmlObject.Factory.newInstance(xmlOptions);


NotesType.Note note = response.addNewNoteTyp();
XmlCursor c = note.newCursor();
c.toFirstChild();
c.toNextToken();
c.setBookmark(CDataBookmark.CDATA_BOOKMARK);
c.dispose();
note.setStringValue("testing");




Jerry Sy wrote:
> 
> You also need to set setUseCDataBookmarks option to true as well. If 
> your original xml contains CDATA, that option will ensure it is retained 
> and will be present when you save the XML.
> As for setSaveCDataLengthThreshold and setSaveCDataEntityCountThreshold, 
> both conditions must be satisfied for CDATA tag to be added.
> 
> Jerry
> 
> On 07/27/2012 02:05 AM, Jurica Krizanic wrote:
>> Hello,
>> I am uxing XMLBeans 2.5.0 and having an issue with saving XML to the 
>> file..
>> When the XML is saved to the file, CDATA section marks are removed, 
>> but content inside the CDATA remains in the file.
>>
>> I would like CDATA marks also remain in the file.
>>
>> I was trying to set XMLOptions with setSaveCDataLengthThreshold() and 
>> setSaveCDataEntityCountThreshold() methods,
>> browsing through already asked questions on the mailing list, but I 
>> can't get it work correctly.
>>
>> Can someone provide any help?
>>
>>
>> Thank you in advance!
>>
>> Best regards,
>> Jurica Krizanic
>>
>>
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/CDATA-saving-problem-tp34219622p34681301.html
Sent from the Xml Beans - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: CDATA saving problem

Posted by je...@oracle.com.
You also need to set setUseCDataBookmarks option to true as well. If 
your original xml contains CDATA, that option will ensure it is retained 
and will be present when you save the XML.
As for setSaveCDataLengthThreshold and setSaveCDataEntityCountThreshold, 
both conditions must be satisfied for CDATA tag to be added.

Jerry

On 07/27/2012 02:05 AM, Jurica Krizanic wrote:
> Hello,
> I am uxing XMLBeans 2.5.0 and having an issue with saving XML to the 
> file..
> When the XML is saved to the file, CDATA section marks are removed, 
> but content inside the CDATA remains in the file.
>
> I would like CDATA marks also remain in the file.
>
> I was trying to set XMLOptions with setSaveCDataLengthThreshold() and 
> setSaveCDataEntityCountThreshold() methods,
> browsing through already asked questions on the mailing list, but I 
> can't get it work correctly.
>
> Can someone provide any help?
>
>
> Thank you in advance!
>
> Best regards,
> Jurica Krizanic
>
>
>
>