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

RE: Need to wrap XML in <![CDATA[...]]> tags

Subject: RE: Need to wrap XML in <![CDATA[...]]> tags
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Mon, 4 Aug 2003 18:50:46 +0100
wrap xml
Your solution would work if you were using an XSLT processor that
supported disable-output-escaping. It seems you aren't. The fact that
d-o-e is non-portable is one of the reasons we often give for avoiding
it.

Another approach might be to use saxon:serialize(), or an equivalent
home-grown extension function of your own.

Best solution would be to find the person who designed this XML
structure and get them to mend their ways. Or you could devise a
sanitary XML representation of the data, generate that, and then
postprocess it using non-XSLT techniques (e.g. change <cdata>...</cdata>
to
<![CDATA[...]]> using a text editor).

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Jason Cunningham
> Sent: 04 August 2003 15:19
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Need to wrap XML in <![CDATA[...]]> tags
> 
> 
> Hi,
> 
> I've got a strange requirement to transform
> 
> <sample>
>   <name>
>     <firstName>Mickey</firstName>
>     <lastName>Mouse</lastName>
>   </name>
> </sample>
> 
> into
> 
> <sample>
>   <person>
>     <![CDATA[
>       <name>
>         <firstName>Mickey</firstName>
>         <lastName>Mouse</lastName>
>       </name>
>     ]]>
>   </person>
> </sample>
> 
> I've written this XSL
> 
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml"/>
> 
>   <xsl:template match="@*|node()">
>     <xsl:copy>
>       <xsl:apply-templates select="@*|node()"/>
>     </xsl:copy>
>   </xsl:template>
> 
>   <xsl:template match='*[name() = "sample"]'>
>     <sample>
>       <person>
>         <xsl:text disable-output-escaping="yes">
>           &lt;![CDATA[
>         </xsl:text>
>         <xsl:copy-of select="./node()"/>
>         <xsl:text disable-output-escaping="yes">
>           ]]&gt;
>         </xsl:text>
>       </person>
>     </sample>
>   </xsl:template>
> 
> </xsl:stylesheet>
> 
> that gets me to
> 
> <sample>
>   <person>
>     &lt;![CDATA[
>       <name>
>         <firstName>Mickey</firstName>
>         <lastName>Mouse</lastName>
>       </name>
>     ]]&gt;
>   </person>
> </sample>
> 
> Unfortunately, this isn't good enough, for the system I am 
> interfacing with. 
>   I can not figure out how I can insert an unescapted '<' 
> into the output - 
> I've read that '<' isn't allowed inside the xsl:text tag.
> 
> Has anyone any ideas?
> 
> Thanks for your time,
> 
> Jason
> 
> _________________________________________________________________
> Find a cheaper internet access deal - choose one to suit you. 
> http://www.msn.co.uk/internetaccess
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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


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.