This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: params troubles
- From: Mike Brown <mike at skew dot org>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 12 Mar 2002 02:35:49 -0700 (MST)
- Subject: Re: [xsl] params troubles
- Reply-to: xsl-list at lists dot mulberrytech dot com
arser.abitu.ru wrote:
> I have a global param $windowname (or variable), and i need to change it in
> a matched or named template. It doesn't work (doesn't change) if i just define a new
> param inside the template with the same name as global one.
Global (top-level) parameters and variables are allowed to be shadowed
(overridden with new params/vars of the same name) within templates. Variables
bound in a template cannot be bound again while they are still in scope.
So it should work.
I think what you are saying is that your new param in the template does not
inherit the value of the global param with the same name? This is actually the
correct behavior, although it is not a contingency that is explicitly
addressed in the XSLT spec where variables and parameters are described. The
only way to pass a value to a parameter in a template is to use xsl:with-param
at the time the template is invoked via xsl:apply-templates or
xsl:call-template.
If you want the param in a template to inherit a global variable as its
default value, you could do that...
<xsl:param name="windowname" select="'default'"/>
<xsl:template match="/">
<xsl:param name="windowname" select="$windowname"/>
...
</xsl:template>
- Mike
____________________________________________________________________________
mike j. brown | xml/xslt: http://skew.org/xml/
denver/boulder, colorado, usa | personal: http://hyperreal.org/~mike/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list