Subject: Anything wrong in grouping/counting?
From: "Ranjan K. Baisak" <ranjanbaisak@xxxxxxxxx>
Date: Thu, 26 May 2005 02:32:06 -0700 (PDT)
|
I have following script for grouping and
counting.Apology for big chunk of code. Why count is
always count+1 for first row? Am I doing something
wrong?
-----------------------
<xsl:variable name="partlist">
<xsl:for-each
select="//A[property/@name='PartNumber']">
<xsl:copy>
<xsl:copy-of
select="property[@name='PartNumber']/@val"/>
</xsl:copy>
</xsl:for-each>
</xsl:variable>
<!--Sort PartNumber by @val -->
<xsl:variable name="OrderedParts">
<xsl:for-each select="exslt:node-set($partlist)/*">
<xsl:sort select="@val"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:variable>
<xsl:for-each
select="exslt:node-set($OrderedParts)/*">
<xsl:variable name="current" select="@val"/>
<xsl:if test="string(@val) != string(
following-sibling::node()[1]/@val)">
<xsl:variable name="count"
select="count(preceding-sibling::node()[@val =
$current])+1"/>
<xsl:variable name="partnumber" select="@val"/>
<xsl:call-template name="colorTemplate"/>
<td>
<xsl:value-of select="$count"/>
</td>
</xsl:if>
</xsl:for-each>
-------------------
I would appreciate your help.
-Ranjan
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|