Subject: Re: [xsl] variable going out of scope in a for-each loop? From: Eric Smith <Eric.Smith@xxxxxxxxxxxx> Date: Mon, 10 Dec 2001 00:20:22 +0100 |
According to Oleg Tkachenko on Mon, Dec 10, 2001 at 12:55:18AM +0200: > > <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"/>|| > > </xsl:when> > > Oops, $aantal_uren is gone :( > > > <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"/>|| > > Here must be syntax error - unresolved variable reference. > > > 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. > Moreover, a scope of local variable is its parent element boundaries, so when you declare variable within <xsl:when> element, you lose it after </xsl:when> end tag. I declared both vars at the start of the stylesheet so I do not know if this makes it a global or local variable. > > > why? > Perhaps because the processor you are using is trying to be xslt1.0 rec compliant :) I just tried the same thing with xalan and the var also went out of scope (seemingly). - 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] variable going out of sco, Oleg Tkachenko | Thread | Re: [xsl] variable going out of sco, Mike Brown |
RE: [xsl] variable going out of sco, Oleg Tkachenko | Date | Re: [xsl] variable going out of sco, Mike Brown |
Month |