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

Re: variable going out of scope in a for-each loop? su

Subject: Re: variable going out of scope in a for-each loop? sub and grand totals
From: Eric Smith <Eric.Smith@xxxxxxxxxxxx>
Date: Mon, 10 Dec 2001 22:01:17 +0100
Re:  variable going out of scope in a for-each loop? su
According to Nate Austin on Mon, Dec 10, 2001 at 10:17:19AM -0600:
> Eric -
> 
> If it's always the last two nodes that you want to multiply, then it's
> pretty straight forward:
> 
> <xsl:value-of select="cell[last()-1] * cell[last()]"/>
> 
> (where row is the current node).
> 
> If you just want the product of all nodes that are numbers, you have to use
> a recursive process.  You can start by selecting all number nodes by using a
> select expression similar to the xsl:if you used:  <xsl:variable
> name="numberNodes" select="cell[number(.)=number(.)]"/>  (replace
> xsl:variable with xsl:with-param to pass it to your recursive template).

Your above code works perfectly (of course), now I need to give a grandtotal
of all the prododucts I calculated above.  Does that mean that I
need to loop through the table twice once to create all those
subtotals as above and again to get the sum of all of them with a recursive template?
Not sure how to implement this ....

> 
> Alternately, if it's possible to use extension functions and you're using
> Saxon, I'm sure Mike has one that'll make this job a piece of cake.  I'll
> leave it to him (or whoever else steps up) to give that to you.
> 

Nope I am using xsltproc for now because of the reason below.

-- 
Eric Smith - currently using xalan and xsltproc - what a difference speed makes - and fop on linux

 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.