sum of n numbers in xslt
This is an open discussion with 1 reply, filed under XSLT.
Search
Without seeing your XML and XSLT it's difficult to be more specific... but within an xsl:for-each
it is difficult. You could use recursive templates instead:
- http://stackoverflow.com/questions/1333558/xslt-to-sum-product-of-two-attributes
- http://www.codeguru.com/csharp/.net/net_data/sortinganditerating/article.php/c13051
- http://getsymphony.com/learn/articles/view/combining-different-template-methods/
- http://stackoverflow.com/questions/436998/multiply-2-numbers-and-then-sum-with-xslt
- http://getsymphony.com/discuss/thread/48657/#position-3
Or if your numbers (5, 3, 2) are in a consistent element in your XSLT then you can use this to sum all instances of the element.
<xsl: value-of select="sum(/xpath/to/this/element)" />
Create an account or sign in to comment.
hi,
I want to add all output which are in numbers (e.g: 5+3+2 ) in a particular for-each loop.. any one tell the correct way to add n numbers in for-each loop..
thanks