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

RE: XSL: How to Calculate Running Total using Variabl

Subject: RE: 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
xslt running total
> 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

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.