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

Subject: RE: [xsl] XSL: How to Calculate Running Total using Variable within FOR-LOOP?
From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Fri, 5 Dec 2003 08:17:04 -0000
> 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


Current Thread