[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Preserve CDATA for all elements

Subject: RE: Preserve CDATA for all elements
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 14 May 2006 18:48:31 +0100
xslt preserve cdata
Sorry, can't be done. The XSLT processor doesn't get to see where the CDATA
sections were in the source document.

Remember that CDATA sections are just a keyboard shortcut. The following are
all exactly equivalent, and your XSLT processor will see the same input
whichever form you use:

<e>">"</e>
<e>&quot;&gt;&quot;</e>
<e><![CDATA[">"]]></e>

As a matter of interest, *why* do you want to preserve the CDATA sections in
the input document?

If it's really important, you could put the XML through a Perl program or
similar that converts the CDATA section to an XML element as a
pre-processing phase and then does the reverse as a post-process.

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

> -----Original Message-----
> From: Jagdishwar (Jagsmiles) [mailto:jagsmiles@xxxxxxxxx] 
> Sent: 14 May 2006 18:29
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Preserve CDATA for all elements
> 
> I would like to put the <![CDATA[ elements as is in my 
> transformed xml.
> So, i had used following declaration at the beginning of the xsl:
> 	<xsl:output method="xml" cdata-section-elements="elementOne
> elementTwo elementThree"/>
> 
> Its works fine for transforming the specified elements (i.e 
> elementOne elementTwo elementThree) along with the CDATA.
> 
> Actually i want to preserve CDATA as is, in all the elements 
> my source xml.
> But Its not very comfortable to add each and every element to 
> the cdata-section-elements attribute.
> 
> I tried using * instead of the element names.
> 	<xsl:output method="xml" cdata-section-elements="*"/> 
> but it does not work, the xslt transformer says:
> "This name may not contain the '*' character"
> 
> But * works fine in other elements like xsl:strip-space
> 	<xsl:strip-space elements="*"/>
> 
> Is there any way, where i can specify in xsl, to preserve all 
> the CDATA for all the elements of the source xml document.
> 
> Thank you all
> 
> Kind Regards,
> Jagdishwar,
> Jagsmiles @ gmail.com

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.