[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] Need to wrap XML in tags
Subject: RE: [xsl] Need to wrap XML in <![CDATA[...]]> tags From: "Matt Trimmer" <matt.trimmer@xxxxxxxxxxxxxx> Date: Mon, 4 Aug 2003 15:34:58 +0100 |
Hi, I have a similar requirement and I thought you could do it with cdata-section-elements. I want to make the following whole CONTENT section be enclosed in a CDATA section but the cdata-section-elements doesn't seem to do it. Is there something else I should use to make a whole tree CDATA? <?xml version="1.0" ?> - <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" cdata-section-elements="TITLE CONTENT" /> - <xsl:template match="dataroot"> - <DATA SERIAL="200307271225"> - <xsl:for-each select="Source"> - <ITEM> - <URL> <xsl:value-of select="URL" /> </URL> - <LINK> http://www.site.com<xsl:value-of select="PARAM" />&referredURL=<xsl:value-of select="URL" /> </LINK> - <TITLE> <xsl:value-of select="Title" /></TITLE> - <CONTENT> - <html> - <head> - <title> <xsl:value-of select="Title" /> </title> - <body> <xsl:value-of select="Body" /> </body> </head> </html> </CONTENT> ....etc Matt -----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: [xsl] 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"> <![CDATA[ </xsl:text> <xsl:copy-of select="./node()"/> <xsl:text disable-output-escaping="yes"> ]]> </xsl:text> </person> </sample> </xsl:template> </xsl:stylesheet> that gets me to <sample> <person> <![CDATA[ <name> <firstName>Mickey</firstName> <lastName>Mouse</lastName> </name> ]]> </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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Need to wrap XML in <![CDATA[, Jason Cunningham | Thread | Re: [xsl] Need to wrap XML in <![CD, David Carlisle |
[xsl] Pound sign encoding issue, Matt Trimmer | Date | Re: [xsl] Need to wrap XML in <![CD, David Carlisle |
Month |