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

select distinct

Subject: select distinct
From: Richard Lander <rlander@xxxxxxxxxxxxx>
Date: Fri, 15 Dec 2000 16:45:44 -0800
select distinct
 Hello,

I'm having some trouble with selecting distinct nodes (no duplicates). I am
using the following algorithm at the moment, which works, but am wondering
if there is something more elegant. generate-id() seems too heavy-handed.

<xsl:template name="element">
  <xsl:param name="path"/>
  <xsl:for-each select="$path//xdr:element">
      <xsl:if test="self::xdr:element[generate-id() =
generate-id($path//xdr:element[@type = current()/@type][1])]">
        <A href="javascript:element('{@type}')">
          <xsl:value-of select="@type"/>
        </A>
      </xsl:if>
  </xsl:for-each>
</xsl:template>

I don't have my Mike Kay book beside me at the moment, so can't look for any
tips on this likely well-documented problem.

I will mention that the elements are not all siblings. Some are, some are
further down. The input looks like:

x
x
x
y
  x
  x
  x
y
  x
  x
  x
x
x

I'm trying to get all the x elements with distinct @type values.

Thanks,

Rich

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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-2013 All Rights Reserved.