Subject: Re: [xsl] XSL & CDATA Processing From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 28 Jun 2004 23:37:42 -0400 |
I am trying to perform an XSL transform for an XML Document to remove duplicate Nodes. The XML file is as below ... The XSL stylesheet I am using to do this is as below. ... The output generated removes the duplicate node but somehow doesn't process the CDATA sections properly.
<Test> <Text LineCount="29" Object="RECORD" Status="?" Version="000"> <![CDATA[<Text.Description>]]>Table File</Text.Description> <![CDATA[<Text.LongDescription>]]>Table File</Text.LongDescription> </Text> </Test>
I have tried adding a "cdata-section-elements" section to the xsl:ouput tag telling it to treat Text.Description & Text.LongDescription as CDATA. This creates the following output
T:\ftemp>type rohit.xml <Test> <Text LineCount="29" Object="RECORD" Status="?" Version="000"> <Text.Description><![CDATA[Table File]]></Text.Description> <Text.LongDescription><![CDATA[Table File]]></Text.LongDescription> </Text>
<Text LineCount="29" Object="RECORD" Status="?" Version="000"> <Text.Description><![CDATA[Table File]]></Text.Description> <Text.LongDescription><![CDATA[Table File]]></Text.LongDescription> </Text> </Test>
T:\ftemp>type rohit.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" > <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:template match="Text"> <xsl:if test="not(@Object = preceding::Text/@Object)"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:if> </xsl:template>
<xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
T:\ftemp>saxon rohit.xml rohit.xsl <Test> <Text LineCount="29" Object="RECORD" Status="?" Version="000"> <Text.Description>Table File</Text.Description> <Text.LongDescription>Table File</Text.LongDescription> </Text>
</Test> T:\ftemp>type rohit2.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" > <xsl:output method="xml" cdata-section-elements="Text.Description Text.LongDescription" omit-xml-declaration="yes"/> <xsl:template match="Text"> <xsl:if test="not(@Object = preceding::Text/@Object)"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:if> </xsl:template>
<xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
T:\ftemp>saxon rohit.xml rohit2.xsl <Test> <Text LineCount="29" Object="RECORD" Status="?" Version="000"> <Text.Description><![CDATA[Table File]]></Text.Description> <Text.LongDescription><![CDATA[Table File]]></Text.LongDescription> </Text>
-- Public training 3 days XSLT & 2 days XSL-FO: Phoenix,AZ 2004-08-23 World-wide on-site corporate, govt. & user group XML/XSL training. G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
XSL & CDATA Processing, Rohit Mathur | Thread | RE: [xsl] XSL & CDATA Processing, Michael Kay |
XSL & CDATA Processing, Rohit Mathur | Date | RE: [xsl] XSL & CDATA Processing, Michael Kay |
Month |