[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|