xsl-list
[Top] [All Lists]

RE: Counting uniquely selected values of elements

2003-04-14 06:19:57
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