Re: Variables and Parameters within Templates

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 UTC