[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: sum() of nodeset

Subject: RE: sum() of nodeset
From: Shimon Pozin <shimonp@xxxxxxxxxxxxxxx>
Date: Thu, 30 Nov 2000 15:46:46 -0500
xsl value of sum
Thanks again for the answer!
One more problem, however. In my original mail I simplified
the question taking m=1 as a parameter:
-------------------xsl------------------------
<xsl:for-each select="//row[@m=1]">
    <tr>
       <td><xsl:value-of select="@m" /></td>
       <td><xsl:value-of select="@y" /></td>
       <td><xsl:value-of select="@v" /></td>
    </tr>
</xsl:for-each>
----------------------------------------------
How can I build this table for all different m's? Is there a way
to do a loop from 1 to 12 somehow? I cannot figure this out.
Again, your help is invaluable!

Shimon

> -----Original Message-----
> From: Pendakur, Ramesh [mailto:ramesh.pendakur@xxxxxxxxx]
> Sent: Thursday, November 30, 2000 1:26 PM
> To: 'xsl-list@xxxxxxxxxxxxxxxx'
> Subject: RE: sum() of nodeset
> 
> 
> you can use <xsl:value-of select="sum(//row[@m=1]/@m)" 
> the sum() function is defined in XPath specification section 4.4
> 
> -ramesh
>   _____  
> 
> 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
> 
> 
> Hello!
> 
> I have xml file like this:
> ----------xml-------------
> <xml>
> <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 />
> ...
> </xml>
> --------------------------
> and xsl like this (only relevant part is quoted to save space):
> -------------xsl----------
> <xsl:for-each select="//row[@m=1]">
>    <tr>
>       <td><xsl:value-of select="@m" /></td>
>       <td><xsl:value-of select="@y" /></td>
>       <td><xsl:value-of select="@v" /></td>
>    </tr>
> </xsl:for-each>
> --------------------------
> 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,
> 
> Shimon
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.