Jason Cunningham
2003-08-04 14:18:38 UTC
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
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