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

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: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Fri, 17 Nov 2006 12:51:59 +0000

On 11/17/06, Robert Eaton <reaton@xxxxxxxxxxxxxxx> wrote:
I am trying to create some output based on the combination of several
different attribute values. But the same combination of value could
occur multiple times within the input document and I only want the
output to appear once for each unique combination of attribute values.
I have tried the code below, at this stage it just outputs the values
while I was trying to get it working. 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.
I am going about this in completely the wrong way? How should I compare
a node within an iteration of a for-each with the same value for the
previous node? Or is there a different/more efficient way to filter the
results down to only unique value?

This appears to be a grouping problem, so for XSLT 1.0 use "Muenchian grouping", in XSLT 2.0 use this inbuilt <xsl:for-each-group> (search for whichever applies)

If you need help with either of these, post back a sample input XML
and an expected result

cheers
andrew


Current Thread
Keywords