[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-dev
Subject:    RE: How to preserve CDATA sections?
From:       "Cezar Andrei" <cezar () bea ! com>
Date:       2006-07-26 19:28:59
Message-ID: 99479F4D39C9244F8E17E688193A3DD8BCE556 () repbex02 ! amer ! bea ! com
[Download RAW message or body]

Hi David,

 

This is an issue that was requested before, and we didn't have a good answer for it \
for quite a while. 

Since the CDATA is not part of the xml info set, the regular text and CDATA are both \
stored as text in the xml in-memory store, so saving will not preserve the CDATA \
blocks.

But, I checked in yesterday two new options that will allow one to control when CDATA \
is used when saving to text: XmlOptions setSaveCDataLengthThreshold() and \
setSaveCDataEntityCountThreshold().

 

So, get the latest sources from SVN and give it a try.

 

Cezar

 

________________________________

From: Lewis, David [mailto:dlewis@pfc.cfs.nrcan.gc.ca] 
Sent: Wednesday, July 26, 2006 12:29 PM
To: user@xmlbeans.apache.org; dev@xmlbeans.apache.org
Subject: RE: How to preserve CDATA sections?

 

As nobody has (yet) responded to my XMLBeans problem, I thought that I would repost \
it to both the "user" and "dev" mailing lists ...

 

________________________________

From: Lewis, David [mailto:dlewis@pfc.cfs.nrcan.gc.ca] 
Sent: July 20, 2006 3:19 PM
To: user@xmlbeans.apache.org
Cc: Murphy, Eric
Subject: How to preserve CDATA sections?

 

Using XMLBeans 2.2.0, if I parse an XML document that contains CDATA sections to \
escape blocks of text, when I save the document to a file system - the CDATA sections \
are no longer preserved and literals that may be interpreted as markup (such as an \
ampersand) are written out in their escaped form. 

 

For example, it the source document contains:

<element><![CDATA[fred&ethyl]]></element>

... it is saved as:

<element>fred&amp;ethyl</element>

 

Any ideas how to preserve the CDATA sections?

 

Thanks!

 

~ David

 

David Lewis 
Software Developer - National Forest Information System/

Concepteur de logiciels - Système national d'information forestière

 

Natural Resources Canada                     Ressources naturelles Canada             \


Canadian Forest Service.                       Service canadien des forêts

506 West Burnside Road                  506, chemin ouest Burnside

Victoria, B.C. V8Z 1M5                           Victoria, (C.-B.), V8Z 1M5

 

Telephone:  (250) 363 0710                    Téléphone:  (250) 363 0710

Facsimile:   (250) 363 0775                     Télécopier:  (250) 363 0775

Email: dlewis@ pfc.cfs.nrcan.gc.ca       Courriel: dlewis@pfc.cfs.nrcan.gc.ca 

 

NFIS Website / SNIF Site Web: http://nfis.org/ <http://nfis.org/> 

PFC Website / CFP Site Web: http://pfc.cfs.nrcan.gc.ca/ <http://pfc.cfs.nrcan.gc.ca/> \


 

_______________________________________________________________________
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.


[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:st1="urn:schemas-microsoft-com:office:smarttags" \
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="Street"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="address"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="place"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="PlaceType"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="PlaceName"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:"Comic Sans MS";
	panose-1:3 15 7 2 3 3 2 2 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal;
	font-family:Arial;
	color:windowtext;}
span.EmailStyle18
	{mso-style-type:personal;
	font-family:Arial;
	color:navy;}
span.EmailStyle19
	{mso-style-type:personal-reply;
	font-family:Arial;
	color:navy;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Hi David,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>This is an issue that was requested
before, and we didn&#8217;t have a good answer for it for quite a while. \
<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Since the CDATA is not part of the xml info
set, the regular text and CDATA are both stored as text in the xml in-memory
store, so saving will not preserve the CDATA blocks.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>But, I checked in yesterday two new options
that will allow one to control when CDATA is used when saving to text:
XmlOptions setSaveCDataLengthThreshold() and \
setSaveCDataEntityCountThreshold().<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>So, get the latest sources from SVN and
give it a try.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Cezar<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> Lewis, David
[mailto:dlewis@pfc.cfs.nrcan.gc.ca] <br>
<b><span style='font-weight:bold'>Sent:</span></b> Wednesday, July 26, 2006
12:29 PM<br>
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName \
w:st="on">user@xmlbeans.apache.org</st1:PersonName>; dev@xmlbeans.apache.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> RE: How to preserve CDATA
sections?</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>As nobody has (yet) responded to my
XMLBeans problem, I thought that I would repost it to both the
&#8220;user&#8221; and &#8220;dev&#8221; mailing lists \
&#8230;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> <st1:PersonName
w:st="on">Lewis, David</st1:PersonName> [mailto:dlewis@pfc.cfs.nrcan.gc.ca] <br>
<b><span style='font-weight:bold'>Sent:</span></b> July 20, 2006 3:19 PM<br>
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName \
w:st="on">user@xmlbeans.apache.org</st1:PersonName><br> <b><span \
style='font-weight:bold'>Cc:</span></b> Murphy, Eric<br> <b><span \
style='font-weight:bold'>Subject:</span></b> How to preserve CDATA \
sections?</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>Using XMLBeans 2.2.0, if I parse an XML document that
contains CDATA sections to escape blocks of text, when I save the document to a
file system &#8211; the CDATA sections are no longer preserved and literals
that may be interpreted as markup (such as an ampersand) are written out in
their escaped form. <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>For example, it the source document \
contains:<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-indent:.5in'><font size=2 face="Courier New"><span
lang=EN-CA style='font-size:10.0pt;font-family:"Courier \
New"'>&lt;element&gt;&lt;![CDATA[fred&amp;ethyl]]&gt;&lt;/element&gt;<o:p></o:p></span></font></p>


<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>&#8230; it is saved as:<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-indent:.5in'><font size=2 face="Courier New"><span
lang=EN-CA style='font-size:10.0pt;font-family:"Courier \
New"'>&lt;element&gt;fred&amp;amp;ethyl&lt;/element&gt;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>Any ideas how to preserve the CDATA \
sections?<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>Thanks!<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>~ David<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face=Arial><span
lang=EN-CA style='font-size:10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>


<p class=MsoNormal style='text-autospace:none'><font size=3 color=green
face="Comic Sans MS"><span lang=EN-CA style='font-size:12.0pt;font-family:"Comic Sans \
MS"; color:green'>David Lewis</span></font><font size=1 color=green face=Arial><span
lang=EN-CA style='font-size:8.0pt;font-family:Arial;color:green'> <br>
Software Developer &#8211; National Forest Information \
System/<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=1 color=green
face=Arial><span lang=EN-CA style='font-size:8.0pt;font-family:Arial;
color:green'>Concepteur de logiciels &#8211; Système national
d&#8217;information forestière<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=1 color=green
face=Arial><span lang=FR \
style='font-size:8.0pt;font-family:Arial;color:green'><o:p>&nbsp;</o:p></span></font></p>


<p class=MsoNormal style='text-autospace:none'><font size=1 color=green
face=Arial><span lang=FR \
style='font-size:8.0pt;font-family:Arial;color:green'>Natural Resources
Canada&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 Ressources naturelles
Canada&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><st1:place w:st="on"><st1:PlaceName
 w:st="on"><font size=1 color=green face=Arial><span lang=EN-CA
  style='font-size:8.0pt;font-family:Arial;color:green'>Canadian</span></font></st1:PlaceName><font
  size=1 color=green face=Arial><span lang=EN-CA style='font-size:8.0pt;
 font-family:Arial;color:green'> <st1:PlaceType \
w:st="on">Forest</st1:PlaceType></span></font></st1:place><font size=1 color=green \
face=Arial><span lang=EN-CA style='font-size:8.0pt; font-family:Arial;color:green'>
Service.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 Service canadien des forêts</span></font><font size=1 color=green face=Arial><span
style='font-size:8.0pt;font-family:Arial;color:green'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><st1:Street w:st="on"><st1:address
 w:st="on"><font size=1 color=green face=Arial><span lang=EN-CA
  style='font-size:8.0pt;font-family:Arial;color:green'>506 West Burnside \
Road</span></font></st1:address></st1:Street><span \
lang=EN-CA>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 </span><font size=1 color=green face=Arial><span lang=EN-CA style='font-size:
8.0pt;font-family:Arial;color:green'>506, chemin ouest \
Burnside<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=1 color=green
face=Arial><span lang=FR \
style='font-size:8.0pt;font-family:Arial;color:green'>Victoria, B.C. V8Z
1M5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 Victoria, (C.-B.), V8Z 1M5<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=1 color=green
face=Arial><span lang=FR \
style='font-size:8.0pt;font-family:Arial;color:green'><o:p>&nbsp;</o:p></span></font></p>


<p class=MsoNormal style='text-autospace:none'><font size=1 color=green
face=Arial><span lang=FR \
style='font-size:8.0pt;font-family:Arial;color:green'>Telephone:&nbsp; (250) 363
0710&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 Téléphone:&nbsp; (250) 363 0710<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=1 color=green
face=Arial><span lang=FR \
style='font-size:8.0pt;font-family:Arial;color:green'>Facsimile:&nbsp;&nbsp; (250) \
363 0775&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 Télécopier:&nbsp; (250) 363 0775<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=1 color=green
face=Arial><span lang=EN-CA style='font-size:8.0pt;font-family:Arial;
color:green'>Email: dlewis@
pfc.cfs.nrcan.gc.ca&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Courriel:
dlewis@pfc.cfs.nrcan.gc.ca </span></font><font size=1 color=green face=Arial><span
style='font-size:8.0pt;font-family:Arial;color:green'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=1 color=green
face=Arial><span lang=EN-CA style='font-size:8.0pt;font-family:Arial;
color:green'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=1 color=green
face=Arial><span lang=EN-CA style='font-size:8.0pt;font-family:Arial;
color:green'>NFIS Website / SNIF Site Web: </span></font><span lang=EN-CA><a
href="http://nfis.org/"><font size=1 color=green face=Arial><span
style='font-size:8.0pt;font-family:Arial;color:green'>http://nfis.org/</span></font></a></span><font
 size=1 color=green face=Arial><span lang=EN-CA style='font-size:8.0pt;
font-family:Arial;color:green'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=1 color=green
face=Arial><span lang=EN-CA style='font-size:8.0pt;font-family:Arial;
color:green'>PFC Website / CFP Site Web: </span></font><span lang=EN-CA><a
href="http://pfc.cfs.nrcan.gc.ca/"><font size=1 color=green face=Arial><span
style='font-size:8.0pt;font-family:Arial;color:green'>http://pfc.cfs.nrcan.gc.ca/</span></font></a></span><font
 size=1 color=green face=Arial><span lang=EN-CA style='font-size:8.0pt;
font-family:Arial;color:green'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-CA
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

</div>

</body>

</html>
<PRE>_______________________________________________________________________
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.
</PRE>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic