RE: [xsl] Calculating Sum in XSLT 1.0

Subject: RE: [xsl] Calculating Sum in XSLT 1.0
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 22 Dec 2004 17:12:26 -0000
sum(preceding-sibling::sibling/@value)

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Abhijit Junnare [mailto:mavlaabhi@xxxxxxxxx] 
> Sent: 22 December 2004 17:09
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Calculating Sum in XSLT 1.0
> 
> I am trying to generate a sum of attribute values of
> sibling nodes via XSLT 1.0
> 
> My XML looks like this
> 
> <sibling value="5"/>
> <sibling value="7">
> <sibling value="9">
> <sibling value="13">
> <currentnode>some text</currentnode>
> 
> When I am processing the template for currentnode I
> want to calculate the sum of the "value" attribute of
> all its previous sibling nodes i.e. I want to find the
> sum of 5,7,9 and 13. The names of the sibling node and
> current node are different. 
> I know there isn't a direction function to do this. If
> anyone has written template or come accross the
> problem then please let me know how did you solve it. 
> Thank you for your help and Merry Christmas.
> Abhi
> 
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> Read only the mail you want - Yahoo! Mail SpamGuard. 
> http://promotions.yahoo.com/new_mail 

Current Thread