[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: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Mon, 10 Dec 2001 00:02:51 -0000
variable loop xsl
> xsl fragment:
>
>      <xsl:for-each select="cell">
>          <xsl:if test="number(.)=number(.)">
>            We have a number here
>          <xsl:choose>
>            <xsl:when test="position() mod 2 = 0">
>              mod 2 = 0!
>              <xsl:variable name="aantal_uren">
>                <xsl:value-of select="."/>
>              </xsl:variable>
>              The value of the aantal_uren is: <xsl:value-of
> select="$aantal_uren"/>||
>              The value of the uur_tarief is: <xsl:value-of
> select="$uur_tarief"/>||

This is a syntax error. The variable $uur_tarief is not in scope. A variable
is in scope on the following-siblings of the xsl:variable element containing
its declaration, and on the descendants of those following siblings. You
should get no output from this stylesheet other than an error message.

Mike Kay

>            </xsl:when>
>            <xsl:otherwise>
>              mod 2 != 0!
>              <xsl:variable name="uur_tarief">
>                <xsl:value-of select="."/>
>              </xsl:variable>
>              The value of the aantal_uren is: <xsl:value-of
> select="$aantal_uren"/>||
>              The value of the uur_tarief is: <xsl:value-of
> select="$uur_tarief"/>||
>            </xsl:otherwise>
>          </xsl:choose>
>          </xsl:if>
>          ....
>
> Now, as soon as I loop form the first number containing cell
> to the next, the
> value defined in the previous-sibling seems to go out of scope viz.
> We have a number here
> mod 2 != 0!
> The value of the aantal_uren is: ||
> The value of the uur_tarief is:
> 246
> ||
> <fo:table-cell ><fo:block font-size="8pt" text-align="center">
> 246
> Here are the aantal
> And the tarief
> </fo:block></fo:table-cell>
> We have a number here
> mod 2 = 0!
> The value of the aantal_uren is:
> 135
> ||
> The value of the uur_tarief is: ||
> <...
>
> why?
> --
> 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
>


 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.