This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: CDATA in XML->XML transformation
- To: <XSL-List at lists dot mulberrytech dot com>
- Subject: Re: [xsl] CDATA in XML->XML transformation
- From: "Thomas B. Passin" <tpassin at mitretek dot org>
- Date: Tue, 25 Sep 2001 13:21:03 -0400
- References: <200109251626.MAA25860@biglist.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
["me" <info@alternize.com>]
> i came across the following problem: i need to transform an XML file into
> a different XML file. one element needs to be defined as CDATA in the
> second XML file.
>
> right now i got
>
> <xsl:template match="Action">
> <solution><xsl:apply-templates select="text()|i|b" /></solution>
> </xsl:template>
>
> which produces an output like
>
> <solution>this is a <i>nice</i> test</solution>
>
> but now i need the output to be a CDATA section, as i don't want the
> <i></i> part being parsed further, eg the output must look like
>
> <solution><![CDATA[this is a <i>nice</i> test]]></solution>
>
> right now i got no clue whatsoever how to include "<![CDATA[" and "]]>"
> through the XSL file...
>
This is a job for the cdata-section-elements attribute of xsl:output. You
supply a (whitespace-separated) list of elements for which you want text
content to be wrapped in CDATA sections.
Cheers,
Tom P
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list