This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Scope of variable defined in <xsl:choose>
- To: "XSL Mailing List \(E-mail\)" <XSL-List at lists dot mulberrytech dot com>
- Subject: [xsl] Scope of variable defined in <xsl:choose>
- From: "Tim Watts" <timw at 3d3 dot com>
- Date: Mon, 21 May 2001 12:21:36 +1000
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi,
I can't understand this error message
> Error [code:222] [node:
> element '<xsl:value-of>']
> variable not found
> search/search - text/html
for the following code:
> <xsl:choose>
> <xsl:when test="data/merchant/customer">
> <xsl:variable name="numberdisplayed"><xsl:value-of
select="count(data/merchant/customer)" /></xsl:variable>
> </xsl:when>
> <xsl:otherwise>
> <xsl:variable name="numberdisplayed"><xsl:value-of
select="count(data/merchant/orders)" /></xsl:variable>
> </xsl:otherwise>
> </xsl:choose>
> <xsl:value-of select="$numberdisplayed" />
The variable has just been defined, but it can't be used outside of the
<xsl:choose>
Yet, if I have
> <xsl:choose>
> <xsl:when test="/document/data/merchant/customer">
> <xsl:variable name="numberdisplayed"><xsl:value-of
select="count(/document/data/merchant/customer)" />
> </xsl:variable>
> <xsl:value-of select="$numberdisplayed" />
> </xsl:when>
> <xsl:otherwise>
> <xsl:variable name="numberdisplayed"><xsl:value-of
select="count(/document/data/merchant/orders)" />
> </xsl:variable>
> <xsl:value-of select="$numberdisplayed" />
> </xsl:otherwise>
> </xsl:choose>
the output is displayed.
How can the variable be used throughout the scope of the template it has
been defined in?
Thanks,
Tim Watts
PS. Am using Sablotron 0.51.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list