This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: select distinct
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] select distinct
- From: "G. Ken Holman" <gkholman at CraneSoftwrights dot com>
- Date: Fri, 15 Dec 2000 22:10:42 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
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@CraneSoftwrights.com
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