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."
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."
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.
Thanks in advance,
-Sriram
[EMAIL PROTECTED] wrote:
> There are not allowed in the node test of a match pattern, but _are_
> allowed in predicates:
>
> "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."
>
> from :
>
> http://www.w3.org/TR/xslt#patterns
>
> As far as the core dump with the circular reference -- we're currently not
> diagnosing circular references, so this is the expected behavior. As we
> start doing more sophisticated stylesheet analyses, we may try to catch
> situations like this, but we won't always be able to. In this case, we
> might want to give a warning, but without knowing the source document, we
> wouldn't be able to report an error, since we wouldn't know if the
> offending element even exists.
>
> Dave
>
> Hi,
> I was trying out Xalan C++ 1.2 (RedHat Linux) and found that the
> match attribute of the xsl:template allows a variable
> reference in the predicates.
> (eg)
> <xsl:template match = "doc[$foo]">
>
> The XSLT specification is clear in stating that the variable references
> are not allowed in template and key match patterns.
>
> The following code also coredumps because of the
> circular reference.
>
> <xsl:variable name="foo">
> <xsl:apply-templates select="//doc"/>
> </xsl:variable>
>
> <xsl:template match = "doc[$foo]">
> </xsl:template>
>
> The confusing part is the testcase in the Xalan test suite
> match14.xsl which shows that a variable can be used in the template
> match pattern. Can someone pl. confirm if this is intentional??
>
> Thanks,
> -Sriram