W3C home > Mailing lists > Public > xsl-editors@w3.org > October to December 1999

11.5 Variables and parameters within templates

From: <bob_buxton@uk.ibm.com>
Date: Fri, 10 Dec 1999 14:34:30 +0000
To: xsl-editors@w3.org
cc: Scott_Boag/CAM/Lotus@lotus.com
Message-ID: <80256843.00504FD1.00@d06mta03.portsmouth.uk.ibm.com>


I have been somewhat confused by the wording of the phrase  "xsl:variable is
allowed
anywhere within a template that an instruction is allowed. In this case,
the binding is visible for all following siblings and their descendants."

I took it mean that "siblings and their descendants."  referred to the structure
of the source document and that if I set a variable whilst processing a template
for an element  that I would be able to use that variable in the templates for
child elements.

Scott Boag informs me that:
>> The visibility/scoping is based on the stylesheet structure.  A variable set
in one template is not visible in another template, unless you pass it as a
parameter.  Note that I think "siblings" in "xsl:variable is allowed anywhere
within a template that an instruction is allowed. In this case, the binding is
visible for all following siblings and their descendants. "  means sibling of
the xsl:variable element, not the containing element.  I think this works like
traditional scoping rules of modern languages.

I think it would be clearer  to say in the recommendation.
"In this case, the binding is visible for all following elements of the template
but is not visible in any other template unless explicitly passed as a
parameter"

Unfortunately I find the requirement to pass variables as parameters results in
very long and unwieldy lists of xsl:param and xsl:with-param elements in all of
the intermediate templates between the one where I set a variable and where I
need to reference it.

Bob Buxton

CICS/TS Systems Management (CPSM) development
MP 208, IBM Hursley, Winchester SO21 2JN, UK
Ext 248193, External  (+44)01962-818193
bob_buxton@uk.ibm.com
Received on Friday, 10 December 1999 09:38:10 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:59:49 GMT