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

Re: Variables and Parameters within Templates

From: James Clark <jjc@jclark.com>
Date: Tue, 21 Nov 2000 11:30:00 +0700
Message-ID: <3A19FA48.E4DF2393@jclark.com>
To: TOM <ptittom@free.fr>
CC: xsl-editors@w3.org
The syntax summary tells you where elements are allowed.  If the syntax
summary for an element says that the content of an element is a
"template", then it can contain any element in the category
"instruction".

<!-- Category: instruction -->
<xsl:for-each
  select = node-set-expression>
  <!-- Content: (xsl:sort*, template) -->
</xsl:for-each> 

xsl:variable is in the category "instruction", but xsl:param is not.
Thus xsl:for-each can have xsl:variable children but not xsl:param
children.

TOM wrote:
> 
> Hi,
> the Rec isn't very clear about what is a "template".
> In 11.5 :
>   "It is an erreor if a binding established by an xsl:variable or
>    xsl:param element within a template shadows another binding
>    established by an xsl:variable or xsl:param also within the
>    template. It is not an erreor if a binding established by an
>    xsl:variable or xsl:param element in a template shadows another
>    binding established by an xsl:variable or xsl:param top-level
>    element."
> My question is : what about variables and params in, for example,
> xsl:for-each?
> 
> For example, is the following allowed ?
> <xsl:template match="foo">
>   <xsl:variable name="myVar" select="position()"/>
>   foo : <xsl:value-of select="$myVar"/>
> 
>   <xsl:for-each select="bar">
>     <xsl:variable name="myVar" select="position()"/>
>     bar : <xsl:value-of select="$myVar"/>
>   </xsl:for-each>
> </xsl:template>
> 
> I'm developping the XSLT implementation of the libxml of Daniel Veillard
> and it could totally change the way we'll handle variables.
> 
> Thanks in advance.
> 
> Tom.
Received on Tuesday, 21 November 2000 05:46:58 GMT

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