RE: New twist: eliminating nodes with duplicate content, case-ins ensi tive

Subject: RE: New twist: eliminating nodes with duplicate content, case-ins ensi tive
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Mon, 6 Dec 1999 18:08:57 -0000
> My question is really how to eliminate duplicates, counting
>    <handle>FOO</handle>
> and
>    <handle>foo</handle>
> as duplicates.
> 
> I still need an answer, if anyone knows one.
> 
> <xsl:variable "unique-handles" select="//handle[not( self::node() =
> following::handle )]"/>
> 

Can't be done in a single pass. (A brave assertion!) This is because there
is no general existential quantifier in XSLT and no map() function to
generate a set of strings by applying a function (translate()) to another
set of strings. If you apply translate to a node-set, it only translates the
string value of the first node.

Conceptually you need (using SQL-like syntax rather than pure predicate
logic)

select="//handle[not exists( select N from following::handle where
translate(N, $lc, $uc) = 
translate(self::node(), $lc, $uc)]

I suggest you do one pass to normalize case, and a second pass to do the
real transformation.

Mike Kay


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


Current Thread