[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: How can I select only unique combinations of attr

Subject: RE: How can I select only unique combinations of attribute value?
From: "Robert Eaton" <reaton@xxxxxxxxxxxxxxx>
Date: Fri, 17 Nov 2006 16:16:12 -0000
unique combinations
>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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.