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 2921 - Provide an exemple of a numeric range used as filter epression
Summary: Provide an exemple of a numeric range used as filter epression
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 1.0 (show other bugs)
Version: Candidate Recommendation
Hardware: All All
: P4 enhancement
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: 2006-02-23 08:31 UTC by Pierrick Brihaye
Modified: 2006-03-14 23:35 UTC (History)
0 users

See Also:


Attachments

Description Pierrick Brihaye 2006-02-23 08:31:03 UTC
It would be nice to have an example for this commonly used kind of filter
expression :

$foo[(2 to 5)]

New users often tend to use a predicate-like syntax - $foo[2 to 5] - and thus
get syntax errors.

It would also be nice to add a reference to "Filter expressions" (3.3.2) in the
"Predicates" section (3.2.2). I don't know whether it should start with
"warning", "see also", "do no confuse"...
Comment 1 Michael Kay 2006-02-23 09:59:42 UTC
$foo[(2 to 5)] is not a legal expression. It will give you a type error
FORG0006: se the rules for effective boolean value at
http://www.w3.org/TR/xpath20/#id-ebv, which are referred to from the rules for
predicates at http://www.w3.org/TR/xpath20/#id-predicates

There was an example of such a construct in a very early draft of XQuery back in
2001, but it never had any defined semantics.

You can achieve the desired effect by writing

$foo[position()=(2 to 5)]

or if you prefer, by

subsequence($foo, 2, 4)

Michael Kay
(personal response)
Comment 2 Pierrick Brihaye 2006-02-23 10:15:52 UTC
Clean and clear answer.

I thus reformulate  : may the first example provided by Michael be added to the
specs ?

The comment about cross-referencing predicates and filter expressions still
stands although I now lean more an more towards "warning" semantics :-)
Comment 3 Don Chamberlin 2006-03-14 23:34:56 UTC
Pierrick,
On 14 March 2006, the Query Working Group agreed to add the requested example to the explanation of predicates. Since this is an editorial suggestion that was accepted by the working group, I am marking this Bugzilla entry as Closed.
Regards,
Don Chamberlin (for the Query Working Group)