Re: [xsl] variable scope and test directives

Subject: Re: [xsl] variable scope and test directives
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Thu, 20 Feb 2003 01:37:24 -0800 (PST)
> Is it just my Sablotron processor, or are variables declared inside
> xsl:choose trapped inside the "choose" scope(?)?
> That seems useless. It means I can't do things like.
> <xsl:choose>
>     <xsl:when test="/app/presentation/series_id='0'">
>         <xsl:variable name="defaultOption">
>             <option value="0">&#xa0;</option>
>         </xsl:variable>
>     </xsl:when>
>     <xsl:otherwise>
>         <xsl:variable name="defaultOption" select="''" />
>     </xsl:otherwise>
> </xsl:choose>

Of course you can, but the xsl:variables so declared go immediately out
of scope and are useless as you have found out.


<xsl:variable name="someName">
   <!-- As many values on conditions as necessary -->


> Surely no other language does this - because it's, er, stupid!

All block-structured languages have the notion of scope, e.g. in C:

  int c = 3;

/* The above variable "c" is out of scope here */

This is direct translation of your problem in C. As you see, in C the
situation is exactly the same...

So what's stupid about it?


Dimitre Novatchev. -- the home of FXSL

Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more

 XSL-List info and archive:

Current Thread