RE: VariableReferences in patterns in XSLT 1.0

>      In my previous note, I didn't represent another 
> interpretation of the 
> text in XSLT 1.0 that has come up a number of times.  That 
> interpretation 
> holds the definition of Pattern in section 5.2 [4] to be in 
> conflict with 
> sections 5.3 [1] and 12.2 [2]. 
> 
>      Section 5.2 takes great pains to define the grammar for 
> Pattern very 
> precisely, and states explicitly that "Predicates in a 
> pattern can use 
> arbitrary expressions."  A VariableReference in an XPath 
> expression can 
> appear in places other than a predicate, but the grammar defined for 
> Pattern eliminates such uses.

I think there are quite a few examples of such apparent conflicts in the
spec, and probably in all specs. You have to apply the legal principle that
the more specific rule takes precedence over the more general rule. A rule
affecting some contexts in which patterns are used is more specific than a
rule for patterns in general; and a rule that allows "arbitrary expressions"
is more general than one that disallows variable references. In particular,
it's absolutely normal practice for syntax rules to allow things that the
semantic rules then disallow under particular circumstances.

Michael Kay


> 
>      Thus, the text in 5.3 and in 12.2 can be read as having 
> been intended 
> as a reaffirmation of the rules in 5.2, rather than an additional 
> constraint - except that those rules don't eliminate the use of 
> VariablesReferences in predicates, as the quotation above 
> confirms. Hence, 
> the view that 5.3 and 12.2 actually conflict with the grammar 
> for Pattern 
> in 5.2 and with the quoted sentence.  A new grammar that 
> defines and uses 
> a PredicateWithoutVariables non-terminal would be needed to 
> resolve the 
> conflict if that was the intention of the Working Group.
> 
> [1] http://www.w3.org/TR/xslt#section-Defining-Template-Rules
> [2] http://www.w3.org/TR/xslt#key
> [3] http://www.w3.org/TR/xslt#number
> [4] http://www.w3.org/TR/xslt#patterns
> ------------------------------------------------------------------
> Henry Zongaro      Xalan development
> IBM SWS Toronto Lab   Tie Line 969-6044;  Phone (905) 413-6044
> mailto:zongaro@ca.ibm.com
> 
> 

Received on Friday, 25 October 2002 13:56:33 UTC