[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: Re: Change the value of global variables/params ??
From: Paul Levin <plevin@xxxxxxx>
Date: Tue, 07 Dec 1999 11:53:02 -0500
xsl variable change value
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.