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

How can I select only unique combinations of attribute

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

<xsl:template match="/">
	<xsl:call-template name="getListStyleNames"/>
</xsl:template>

<xsl:template name="getListStyleNames">
	<xsl:for-each select="descendant::listitem">
		<xsl:sort select="concat(../@style,@bodystyle,@style)"/>

		<xsl:if test="not(concat(../@style,@bodystyle,@style) =
concat(preceding::listitem/../@style,preceding::listitem/@bodystyle,prec
eding::listitem/@style))">

		<!-- To test just output them for the moment. -->
			<xsl:element name="style">
				<xsl:value-of
select="concat(../@style,@bodystyle,@style)"/>
			</xsl:element>
			<xsl:element name="previousStyle">
				<xsl:value-of
select="concat(preceding::listitem/../@style,preceding::listitem/@bodyst
yle,preceding::listitem/@style)"/>
			</xsl:element>
		</xsl:if>

	</xsl:for-each>
</xsl:template>

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.