[xsl] variable scope and test directives

Subject: [xsl] variable scope and test directives
From: "Terence Kearns" <tk.lists@xxxxxxxxxxx>
Date: Thu, 20 Feb 2003 19:02:09 +1100
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>

because now I can't use $defaultOption anywhere.

This doesn't work either:

<xsl:if  test="/app/presentation/series_id='0'">
    <xsl:variable name="defaultOption">
        <option value="0">&#xa0;</option>
    </xsl:variable>
</xsl:if>
<xsl:if  test="/app/presentation/series_id!='0'">
    <xsl:variable name="defaultOption" select="''" />
</xsl:if>
<xsl:value-of select="$defaultOption" />

How is this just crappy behavior or is there a valid reasons for
considdering a test condition as variable scope boundaries? Surely no
other language does this - because it's, er, stupid!
_____________________________
http://terencekearns.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread