This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: variable going out of scope in a for-each loop? sub and grand totals
- From: Eric Smith <Eric dot Smith at fruitcom dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Mon, 10 Dec 2001 22:01:17 +0100
- Subject: Re: [xsl] variable going out of scope in a for-each loop? sub and grand totals
- References: <0E436C278A0AD511A3BE00B0D06896FC5F6115@CLAVIN>
- Reply-to: xsl-list at lists dot mulberrytech dot com
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