RE: [xsl] How can I select only unique combinations of attribute value?

Subject: RE: [xsl] How can I select only unique combinations of attribute value?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 17 Nov 2006 13:35:22 -0000
> I thought 
> using preceding would look at the preceding node within the 
> set being used in the for each, and that has been sorted, but 
> this didn't seem to be the case. 

The XPath axes always navigate the tree that the node belongs to. Processing
the nodes in sorted order doesn't change the source tree, so it doesn't
change the result of axis navigation either.


> I am going about this in completely the wrong way? 

Yes.

> How should 
> I compare a node within an iteration of a for-each with the 
> same value for the previous node? 

You shouldn't (and you can't).

> Or is there a 
> different/more efficient way to filter the results down to 
> only unique value?

Use xsl:for-each-group in XSLT 2.0, or Muenchian grouping in XSLT 1.0
http://www.jenitennison.com/xslt/grouping

Michael Kay
http://www.saxonica.com/

Current Thread