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

Re: select distinct

Subject: Re: select distinct
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 15 Dec 2000 22:10:42 -0500
xslt select distinct
At 00/12/15 16:45 -0800, Richard Lander wrote:
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.

You can use the Meunchen method as follows to find all like type attributes in the document scope:


  <xsl:key name="typeatts" match="x" use="@type"/>
  ...
     <xsl:for-each select="//x[generate-id(.)=
                               generate-id(key(typeatts,@type))]">
        <A href="javascript:element('{@type}')">
          <xsl:value-of select="@type"/>
        </A>
     </xsl:for-each>

If you need to subset this within a subtree then you can incorporate into the key value the generated id of the apex of the subtree:

  <xsl:key name="typeatts" match="x"
           use="concat( generate-id(ancestor::y),' ',@type )"/>

and change the predicate accordingly.

I hope this helps (the fragment above is untested so I may have mistyped).

............. Ken

--
G. Ken Holman                    mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.             http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999   (Fax:-0995)
Web site: XSL/XML/DSSSL/SGML services, training, libraries, products.
Book: Practical Transformation Using XSLT and XPath ISBN1-894049-05-5
Article:          What is XSLT? http://www.xml.com/pub/2000/08/holman
Next public instructor-led training:           2001-01-27,2001-02-21,
-             2001-02-27/03-01,2001-03-05/07,2001-04-06/07,2001-05-01


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.