xsl-list
[Top] [All Lists]

RE: XSL: How to Calculate Running Total using Variable within FOR-LOOP?

2003-12-05 01:17:04

PROBLEM:  I can't figure out how to calculate the BATCHTOTAL. 
 I think it's because with each loop, the GRANDTOTAL variable 
goes out of scope.

Without a sample of your xml you make it more difficult to guess, but
this sounds like you want to do the first calculation in a variable and
then sum that into a grandtotal.

For example,

Build a variable with your first set of calculations:

<xsl:variable name="batchTotals">
  <subtotal name="hourly">123</subtotal>
  <subtotal name="lesser">456</subtotal>
</xsl:variable>

Then sum what you need from that:

<xsl:variable name="grandTotal" select="sum($batchTotals/subtotal)"/>

(convert to node-set first in xslt 1.0)

Just separate out your operations into variables, with each one working
on the last.  

cheers
andrew

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



<Prev in Thread] Current Thread [Next in Thread>
  • RE: XSL: How to Calculate Running Total using Variable within FOR-LOOP?, Andrew Welch <=