RE: [xsl] XML -> XML preserving CDATA

Subject: RE: [xsl] XML -> XML preserving CDATA
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Wed, 12 Sep 2001 11:28:37 +0100
> My source XML can contain different (unknown) elements with CDATA
> sections,
> which should be copied preserving the CDATA sections untouched.
>
> How can this be done?
>

It can't; but it shouldn't matter. The XSLT/XPath specs take the view that
CDATA is purely an input convenience to save you having to escape special
characters; it doesn't affect the information content of a document. So

<foo><![CDATA[ Chic&Apart ]]></foo>

and

<foo> Chic&amp;Apart </foo>

are precisely equivalent. Most XSLT processors will output the latter, but
it shouldn't make any difference to subsequent users of the document which
they choose.

Mike Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread