[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?

Subject: Re: variable going out of scope in a for-each loop?
From: Nate Austin <naustin@xxxxxxxxxx>
Date: Mon, 10 Dec 2001 10:17:19 -0600
eric smith austin
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).

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.

Hope that helps.

-Nate

>Date: Mon, 10 Dec 2001 00:20:22 +0100
>From: Eric Smith <Eric.Smith@xxxxxxxxxxxx>
>Subject: Re:  variable going out of scope in a for-each loop?
>
>- - perhaps i am going about this the wrong way - i need to calcualte the
product of the
>last two cells in a row viz.
>
>         <row header="phase">
>            <cell>
>              John Doe
>            </cell>
>            <cell>
>              Engineer
>            </cell>
>            <cell>
>              246
>            </cell>
>            <cell>
>              135
>            </cell>
>          </row>
>
>This should be so easy to do (maybe it is?).
>
>- -- 
>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.