[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] help on removing duplicates


Subject: Re: [xsl] help on removing duplicates
From: "Juergen" <xsl@xxxxxxxxxxxxxxx>
Date: Fri, 21 Jan 2005 16:04:37 +0100

Hi jvalentin,

try this:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:key name="duplicateEl" match="el" use="node" />
<xsl:key name="duplicateNode" match="rel/el/node" use="concat(parent::el/parent::rel/parent::el/node,'::',.)" />


<xsl:template match = "/">
<xsl:for-each select="xml/el[count(. | key('duplicateEl', node)[1]) = 1]">
<xsl:sort select="node" />
<xsl:variable name="node" select="node"/>
<xsl:value-of select="node"/><xsl:text>-</xsl:text>
<xsl:for-each select="//rel[parent::el/node=$node]/el/node[count(. | key('duplicateNode', concat(parent::el/parent::rel/parent::el/node,'::',.))[1]) = 1]">
<xsl:sort select="." />
<xsl:value-of select="."/>
</xsl:for-each>
<xsl:text>$</xsl:text>
</xsl:for-each>
</xsl:template>


</xsl:stylesheet>

I get: linebreaks with $
       A-XY
       B-XZ
       C-Z
       ...


Cheers,


Juergen


Current Thread