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

Re: params troubles

Subject: Re: params troubles
From: Mike Brown <mike@xxxxxxxx>
Date: Tue, 12 Mar 2002 02:35:49 -0700 (MST)
param name windowname
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


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.