Subject: Re: Change the value of global variables/params ?? From: Paul Levin <plevin@xxxxxxx> Date: Tue, 07 Dec 1999 11:53:02 -0500 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Change the value of global vari, David Carlisle | Thread | RE: Change the value of global vari, Richard Lander |
RE: new feature desired: return var, Kay Michael | Date | Re: Change the value of global vari, Patrice Bonhomme |
Month |