> I agree that the predicate allows variables, but I feel the xsl:template
> is an exception, IMHO. The statement below doesn't refer to patterns,
> but to the whole match attribute value of the xsl:template. Also Kay's
> (Second Ed) book, page 314 explains this with an example.
>
>     "The match attribute is required unless the xsl:template element has
>      a name attribute (see [6 Named Templates]). It is an error for the
>      value of the match attribute to contain a VariableReference."
>

I disagree with Mike here.  A pattern can contain a predicate, and that
predicate can contain a variable reference.

> from:
>    http://www.w3.org/TR/xslt#section-Defining-Template-Rules
>
> Also under the section xsl:key
>
>    "It is an error for the value of either the use attribute or the
>     match attribute to contain a VariableReference."

What has xsl:key got to do with match patterns for templates?  They're two
totally different things.

> from:
>    http://www.w3.org/TR/xslt.html#key
>
> The spec is denying the use of variables even for an expression in the
> case of the 'use' attribute of xsl:key.

Yes, this was done to help prevent circular definitions of keys.

The following processors are happy to accept a variable in the predicate of
a match attribute of xsl:template:

   Xalan
   XT

The following processors are not:

   MSXML
   Saxon

I think it's worth trying to get a clarification from the WG, since the
recommendation is in conflict with itself.  This section:

   "A pattern must match the grammar for Pattern. A Pattern is a set of
   location path patterns separated by |. A location path pattern is a
   location path whose steps all use only the child or attribute axes.
   Although patterns must not use the descendant-or-self axis, patterns may
   use the // operator as well as the / operator. Location path patterns
   can also start with an id or key function call with a literal argument.
   Predicates in a pattern can use arbitrary expressions just like
   predicates in a location path."

and this section:

   "It is an error for the value of the match attribute to contain a
   VariableReference."

are contradictory.  A match attribute is defined as being a pattern.  If
the predicate in a pattern allows an arbitrary expression, then it should
allow a variable reference, just like it does in a location path.
Otherwise, it's not an arbitrary expression.

Dave


Reply via email to