[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Scope of variable defined in <xsl:choose>

Subject: Scope of variable defined in <xsl:choose>
From: "Tim Watts" <timw@xxxxxxx>
Date: Mon, 21 May 2001 12:21:36 +1000
xsl variable xsl choose
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


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.