You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Sh...@lotus.com on 2000/05/24 15:03:16 UTC
Re: problems with variable - variables are only visible when scoped
(Ok, that wasn't a great Subject line, haven't had my morning coffee yet
8-)
This is correct behavior. See: http://www.w3.org/TR/xslt#local-variables
which details how variables are scoped (i.e. where a variable is visible
depending on where you declare it). Basically your xsl:variable
declarations are only visible within the individual xsl:when statements,
and not outside of them. Also, don't forget that you cannot re-bind or
re-set the value of a variable - they're more like constants.
Anyone else have a good suggestion for how to do something like this? This
is a fairly common question, there might be other ideas in the mailing list
archive at http://xml-archive.webweaving.org/xml-archive-xalan/
---- you <le...@post.ch> wrote: ----
> the following code won't work.....
>
> <xsl:template match="/" name="Main">
> <xsl:choose>
> <xsl:when test="Language[. = 'd']">
> <xsl:variable name="Title">uebersicht</xsl:variable>
> </xsl:when>
...
> </xsl:choose>
>
> <H1><xsl:value-of select="$Title"/></H1>
> </xsl:template>
>
> xalan says:
>
> XSL Error: pattern = '$Title'
> VariableReference given for variable out of context or without
definition!
---- ----
- Shane Automation & Test guy
mailto:shane_curcuru@lotus.com AIM:xsltest
http://alphaworks.ibm.com/tech/LotusXSL
http://xml.apache.org/xalan