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: "Robert Eaton" <reaton@xxxxxxxxxxxxxxx>
Date: Fri, 17 Nov 2006 16:16:12 -0000
>Use xsl:for-each-group in XSLT 2.0, or Muenchian grouping in XSLT 1.0
>http://www.jenitennison.com/xslt/grouping

I had a look at the link. What I needed was actually a bit simpler than
the functionality described there as I only needed the list of unique
values not details of the elements with those values. But it did point
me in the right direction.
If instead of trying to check if the value matches the previous one when
processing the sorted elements, which turned out not to be possible, I
changed the select in the for-each loop to check that this was the first
element in the document that had that set of attribute values as follow.

<xsl:template name="getListStyleNames">
	<xsl:for-each select="descendant::listitem[not ((../@style =
preceding::listitem/../@style) and (@bodystyle =
preceding::listitem/@bodystyle) and (@style =
preceding::listitem/@style))]">

		<xsl:element name="style">
		<xsl:value-of
select="concat(../@style,@bodystyle,@style)"/>
		</xsl:element>
	</xsl:for-each>
</xsl:template>

This seemed to give the list of unique combinations I was after.

Thanks to Michael and Andrew for your help.

Thanks,
Rob

Current Thread