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

Re: Variable and parameter with same name and scope a

Subject: Re: Variable and parameter with same name and scope allowed in 2.0
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Tue, 2 May 2006 08:21:03 -0700
Re:  Variable and parameter with same name and scope  a
At the time I protested against this as strongly as I could, but they
still let it into the spec.

Dave, It might be a good idea to put this into the "Don'ts" of the XSLT FAQ.



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.


On 5/2/06, andrew welch <andrew.j.welch@xxxxxxxxx> wrote:
It seems this is allowed in 2.0:

<xsl:function name="f:f">
       <xsl:param name="p"/>
       <xsl:variable name="p" select="concat($p, 'a')"/>
       <xsl:sequence select="$p"/>
</xsl:function>

The same goes for named templates - a variable is allowed to have the
same name as a parameter.

I can see how its possible - the variable will always come after the
parameter, so it will always 'win' when it comes to scope.  My concern
is that this sort of thing would usually end up from a mistake, and
then get silently handled by the code - it's shadowing, and its well
known how many problems that can cause.

I've only tried this with Saxon 8.7.1 so I'm assuming it's
intentional?  Is there a good reason for this - something that I'm not
seeing at the moment?

thanks
andrew

Current Thread

Back To School Sale!

Save 30% off all Stylus Studio 2008 Products when you purchase from our Online Shop.

Offer ends August 31, 2008.

Coupon Code
TRTY-C4JV-OFF

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-2007 All Rights Reserved.