Subject: XSL & CDATA Processing From: Rohit Mathur <geek_on_line@xxxxxxxxx> Date: Tue, 29 Jun 2004 12:21:13 +1000 (EST) |
Hi, I am trying to perform an XSL transform for an XML Document to remove duplicate Nodes. The XML file is as below <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> The XSL stylesheet I am using to do this is as below. <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> 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 <Test> <Text LineCount="29" Object="RECORD" Status="?" Version="000"> <![CDATA[<Text.Description><![CDATA[]]]]><![CDATA[>]]><![CDATA[Table File]]></Text.Description> <![CDATA[<Text.LongDescription><![CDATA[]]]]><![CDATA[>]]><![CDATA[Table File]]></Text.LongDescription> </Text> </Test> Can anyone help me? Cheers Rohit. Find local movie times and trailers on Yahoo! Movies. http://au.movies.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] putting all the elements , Pedro Castro | Thread | Re: [xsl] XSL & CDATA Processing, G. Ken Holman |
RE: [xsl] putting all the elements , Pedro Castro | Date | Re: [xsl] XSL & CDATA Processing, G. Ken Holman |
Month |