RE: Change the value of global variables/params ??

Subject: RE: Change the value of global variables/params ??
From: "Richard Lander" <rlander@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 7 Dec 1999 12:28:58 -0500
 Why not use a parameter (xsl:param) instead of a variable?

I may be missing something, but I was under the impression that variables
and parameters were exactly the same, except that values in parameters were
dynamic and that those in variables were static. So, why not use a
parameter?

Richard.

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of Paul Levin
Sent: Tuesday, December 07, 1999 11:53 AM
To: xsl-list@xxxxxxxxxxxxxxxx
Subject: Re: Change the value of global variables/params ??


It is correct when you say that "variables never change their value",
according
to the XSL Spec.
However,  LotusXsl does allow a local variable (a variable inside of a
template)
to have it's value changed.  A "feature" I depend on.

David Carlisle wrote:

> > Is it possible to assigne or change the value of a global variable or
param
> > within a template?
>
> variables never change their value, parameters can be given new values
> when the template is called (not inside the template)
>
> > <xsl:variable name="variable.lang"/>
>
> There's no point doing this as this variable will always have value
> the empty string. Perhaps you wanted a top level xsl:param in which case
> the value could be set when the stylesheet is called.
>
> <xsl:template name="i18n">
>     <xsl:choose>
>       <xsl:when test="$variable.lang='en'">Abstract</xsl:when>
>       <xsl:when test="$variable.lang='fr'">Résumé</xsl:when>
>       ...
>     </xsl:choose>
> </xsl:template>
>
> This doesn't work as the variable.lang is the variable declared at the
> top level, which is always ''. If you want the template to take a
> parameter called variable.lang, you must have a <xsl:param statement
> at the start of _this_ template.
>
> <xsl:template match="langset">
>   <!-- Set the value of language -->
>   <xsl:param name="variable.lang"><value-of
select="@xml:lang"/></xsl:param>
>   ...
>   <call-template name="i18n"/>
>   ...
> </xsl:template>
>
> you see variable.lang need not be a parameter of your langset template
> as this template does not depend on this parameter, but you could pass
> on the value as a parameter to the cal-template
>
> <xsl:template match="langset">
>   <call-template name="i18n">
>     <xsl:with-param  name="variable.lang" select="@xml:lang"/>
>   </call-template>
>    ...
> </xsl:template>
>
> However there is no real need to pass this information down as a
> parameter, as all templates can get the information in the original
> source tree.
>
> so you could not bother with parameters and just have
>
> <xsl:template name="i18n">
>   <xsl:variable name="variable.lang" select=
>   "ancestor-or-self::*/@xml:lang"/>
>     <xsl:choose>
>       <xsl:when test="$variable.lang='en'">Abstract</xsl:when>
>       <xsl:when test="$variable.lang='fr'">Résumé</xsl:when>
>       ...
>     </xsl:choose>
> </xsl:template>
>
> David
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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


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


Current Thread