[xsl] Duplicates in multiple, independent lists

Subject: [xsl] Duplicates in multiple, independent lists
From: J-P Stacey <jps@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 25 Feb 2004 16:42:43 +0000 (GMT)

I've just been implementing a remove-duplicate template, and had a look
at the suggestions at http://www.dpawson.co.uk/xsl/sect2/N2696.html . The
simplest one for my (reasonably small) data set is at #d3417e34, "Remove
duplicates from a list".

However, after several rewrites weren't working, I noticed that
following:: snarfs the whole of the rest of the document
(http://www.w3schools.com/xpath/xpath_location.asp). Now this is no good
for my data, because there are several sets of lists, separated in the
same file and necessarily treated independently as far as duplication is
concerned. I had to resort to preceding-sibling instead:

<xsl:variable name="no-dupes"

This traps the context within each Set and prevents duplicate removal
because of later sets. I also used preceding- rather than
following-sibling because it outputs up the first instance of each
duplicate rather than the last, but I suppose that's a matter of taste.

Would it be useful to add this as a caveat to that bit of the FAQ? It's
not as cute as using // and following::, but it might be useful to flag
what (I think) is going on.


Will Self's mobile ring is Smells Like Teen Spirit.

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

Current Thread