11.5 Variables and parameters within templates

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 UTC