This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Scope of variable defined in <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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]