RE: sum() of nodeset

Subject: RE: sum() of nodeset
From: "Pendakur, Ramesh" <ramesh.pendakur@xxxxxxxxx>
Date: Thu, 30 Nov 2000 10:26:23 -0800
you can use <xsl:value-of select="sum(//row[@m=1]/@m)" 
the sum() function is defined in XPath specification section 4.4


Ramesh Pendakur

Web Standards & Architecture Team (WSAT)
Intel Architecture Labs.
503.264.0572 - desk
503.804.8564 - cell
ramesh.pendakur@xxxxxxxxx <mailto:ramesh.pendakur@xxxxxxxxx> 

-----Original Message-----
From: Shimon Pozin [mailto:shimonp@xxxxxxxxxxxxxxx]
Sent: Thursday, November 30, 2000 8:32 AM
To: 'xsl-list@xxxxxxxxxxxxxxxx'
Subject: sum() of nodeset


I have xml file like this:
<row m=1 y=1999 v=3 />
<row m=1 y=2000 v=43 />
<row m=2 y=1999 v=6 />
<row m=2 y=2000 v=56 />
and xsl like this (only relevant part is quoted to save space):
<xsl:for-each select="//row[@m=1]">
      <td><xsl:value-of select="@m" /></td>
      <td><xsl:value-of select="@y" /></td>
      <td><xsl:value-of select="@v" /></td>
Now, I am trying to get sum of values for a particular m (stands for month, 
of course). I tried:
<td><xsl:value-of select="@m[@m=1]" /></td>, but get 0 in this case
If I try:
<td><xsl:value-of select="//@m[@m=1]" /></td> I get sum of _all_ rows
rather than sum of v's for a particular month. Is there a simple 
solution to my problem without transforming the original file to 
some intermediate format?

Thanks a lot for any ideas,


 XSL-List info and archive:

 XSL-List info and archive:

Current Thread