This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
select distinct
- To: "Xsl-List (E-mail)" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] select distinct
- From: Richard Lander <rlander at microsoft dot com>
- Date: Fri, 15 Dec 2000 16:45:44 -0800
- Reply-To: xsl-list at lists dot mulberrytech dot com
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