[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] CDATA in XML->XML transformation
Subject: RE: [xsl] CDATA in XML->XML transformation From: "Michael Kay" <mhkay@xxxxxxxxxxxx> Date: Wed, 26 Sep 2001 10:33:47 +0100 |
> 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> > You can get CDATA sections in the output using <xsl:output cdata-section-elements="..."/>. But this isn't the whole answer. In your example, you have generated <i>nice</i> as an element node. But if you want to produce <![CDATA[this is a <i>nice</i> test]]>, then the angle brackets within the CDATA must be generated as text characters, not as markup - the whole point of CDATA is to say that characters such as "<" are not to be regarded as markup. So instead of producing <i>nice</i> as an element, you will have to generate the "tags" (i.e., the things that look like tags, though they aren't) by hand, e.g. as: <![CDATA[<i>]]><xsl:value-of select="."/><![CDATA[</i>]]> I am at a loss to know why you want to use CDATA in this situation, as it means your nicely marked-up text can no longer be processed as XML, but no doubt you have your reasons. Mike Kay XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] CDATA in XML->XML transfo, Thomas B. Passin | Thread | RE: [xsl] CDATA in XML->XML transfo, Casadome, Francisco |
[xsl] XSLT and parallel processing, Colin Adams | Date | RE: [xsl] Embedded Stylesheets, Chris Bayes |
Month |
Keywords