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

Re: New twist: eliminating nodes with duplicate content, case-insensi tive


Subject: Re: New twist: eliminating nodes with duplicate content, case-insensi tive
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 7 Dec 1999 10:25:49 GMT

> The code below does it in one pass (it was indeed a brave assertion!),

I suspect that was multiple passes by Michael's counting (as is the code
below) I don't think that you can do it in a single xpath expression,
for the reasons given, but I don't think you need to use explicit
recursion. Isn't this more or less what is wanted?


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


<xsl:variable name="up" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:variable name="lo" select="'abcdefghijklmnopqrstuvwxyz'"/>

<xsl:template match="/">
<xsl:apply-templates select="//handle"/>
</xsl:template>

<xsl:template match="handle">
<xsl:if test="not(following::handle[translate(.,$up,$lo)=
                                    translate(current(),$up,$lo)])">
  <xsl:copy-of select="."/>
</xsl:if>
</xsl:template>

</xsl:stylesheet>

To do this directly in xpath you would need a generalisation of
current() that gave the node current outside the current filter
rather than the node current at the start of the expression.

Of course the above probably results in the current node being downcased
multiple times and it would be better anyway not to use
current() at all and just put the lowercase of the current node value
into a variable.

David


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords