RE: [xsl] CDATA Handling

Subject: RE: [xsl] CDATA Handling
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 6 Jan 2009 09:41:44 -0000
CDATA is treated by XSLT as an input convenience: the XSLT processor doesn't
know that the data was entered using CDATA, any more than it knows whether
you used the SHIFT key or CAPS LOCK. It's just a shortcut for data entry,
not part of the information content of the document. This also explains why
there is very weak support for producing CDATA on output.

If your XML document design uses CDATA to convey information, then you need
to think seriously about improving the design. If the receiving application
only works if the data is enclosed in CDATA, then you need to think
seriously about improving that application. If you can't do either of those
things, then you are going to have to do some messy programming to generate
the CDATA section. One way is to use cdata-section-elements on xsl:output as
suggested already on this thread, another is to generate the CDATA start and
end strings (<![CDATA[ and ]]>) using character maps or
disable-output-escaping.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: J. S. Rawat [mailto:jrawat@xxxxxxxxxxxxxx] 
> Sent: 06 January 2009 05:56
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx; xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] CDATA Handling
> 
> Hi,
> Can anyone help let me about the handling of CDATA by XSLT 
> 2.0 (saxon).
> 
> Input
> <img.embed><![CDATA[R0lGODlhDQANAMQ0IAOw==]]></img.embed>
> 
> Required output
> <![CDATA[R0lGODlhDQANAMQ0IAOw==]]>
> 
> Thanks
> ...JSR

Current Thread