This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 2500 - [XPath] Predicate list evaluation
Summary: [XPath] Predicate list evaluation
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XPath 2.0 (show other bugs)
Version: Candidate Recommendation
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Don Chamberlin
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-10 13:48 UTC by Timo Boehme
Modified: 2006-02-22 23:49 UTC (History)
0 users

See Also:


Attachments

Description Timo Boehme 2005-11-10 13:48:36 UTC
For my understanding the spec don't clearly specify how predicates of a
predicate list are evaluated. What we have is:
3.2.1
"The value of the step consists of those items that satisfy the predicates."

So i see two possibilities (C be the set of context nodes of a step without
applied predicates):
1) each predicate is applied to C and the intersection of these results will be 
   the result of the step
2) the predicates are applied left to right and the result of one predicate
   evaluation is the context for the following predicate
Both possibilities are equal as long as no positional filter (position(),
first(), last(), numeric item) is used.
The only indication that case 2 is the right one is given in 3.2.4 with the examples
para[@type="warning"][5] and
para[5][@type="warning"]

Furthermore 2.3.4 states
"An implementation is permitted, however, to reorder the predicates to achieve
better performance...". This however could be misleading interpreted as
supporting case 1.

Therefore I would propose to clearly state how predicate lists are to be
evaluated and give a warning/hint in 2.3.4 that reordering of predicates is
dangerous if predicates with references to context positions are included.


Kind regards
Timo
Comment 1 Jonathan Robie 2006-01-31 20:03:48 UTC
Hi Timo,

Isn't the intent clear from the text "A step is a part of a path expression that
generates a sequence of items and then filters the sequence by zero or more
predicates"?
Comment 2 Timo Boehme 2006-02-02 15:40:21 UTC
Hi Jonathan,

No. This sentence only states (in my understanding) that predicates are applied
after evaluating axis and node test. But how they are applied (if we have more
than one) is not explicitly specified.
If we have /n[pa][pb]
according to my description
case 1) evaluate /n[pa] and /n[pb]; the result is the intersection of both
case 2) evaluate /n[pa] = C1 and afterwards C1[pb] = result

I can't find a clear statement in the recommendation which tells that case 2 is
the right one (see also my comment regarding 2.3.4)
Comment 3 Don Chamberlin 2006-02-22 23:49:26 UTC
Timo,
Thanks for your comment. The Query and XSLT working groups considered your 
comment at their meeting on 02 Feb 2006, and agreed that it would be helpful to 
add text clarifying that predicates are effectively applied from left to right. 
This text will be added to the next published version of the XPath and XQuery 
specifications. Since we consider this to be an editorial rather than a 
substantive revision, I have marked this comment as closed. When you see the 
revised documents, please feel free to submit a new comment if you feel the 
issue has not been adequately dealt with.
Regards,
Don Chamberlin, for the Query and XSLT working groups