RE: [xsl] Counting uniquely selected values of elements

Subject: RE: [xsl] Counting uniquely selected values of elements
From: "Ragulf Pickaxe" <jawxml@xxxxxxxxxxx>
Date: Mon, 14 Apr 2003 13:19:57 +0000
Thanks for the very quick response.

I am not that good at keys, though - always avoiding them when possible - so just one moer question on this:

The a and b elements are always there but there might be some (d) elements before the c element: a/b/d/c, perhaps a/b/d/e/f/c.

Kan I in the solution below, just substitute a/b/c with a/b//c?

Thanks again.

Ragulf Pickaxe :)


See <http://jenitennison.com/xslt/grouping>


<xsl:key name="uniq" match="a/b/c" use="." />

<xsl:template match="root">
<xsl:for-each select="a/b/c[generate-id(.) = generate-id(key('uniq', .))]">
<xsl:value-of select="."/> occurs <xsl:value-of select="count(key('uniq', .))"/> times. <xsl:text/>
</xsl:for-each>
</xsl:template>


Cheers,

Jarno - neuroticfish: wakemeup! (club-edit)



_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail



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



Current Thread