Subject: RE: Newbie question: how to count equal nodes into one result element
From: "Harbarth, Juliane" <jhb@xxxxxxxxxxxxxx>
Date: Mon, 21 Jun 1999 16:26:55 +0200
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
<xsl:template match="/">
<result>
<xsl:apply-templates/>
</result>
</xsl:template>
<xsl:template match="tag">
<xsl:variable name="currentFruit"><xsl:value-of
select="."/></xsl:variable>
<xsl:variable name="others">
<xsl:number
expr="count(from-preceding-siblings(tag[from-self(*)=$currentFruit]))"/>
</xsl:variable>
<xsl:if test="$others=0">
<tag>
<value><xsl:value-of select="."/></value>
<occurred>
<xsl:number
expr="count(from-following-siblings(tag[from-self(*)=$currentFruit])) + 1"/>
</occurred>
</tag>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|