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 29160 - [XQ31] Obsolete Note under "order by"
Summary: [XQ31] Obsolete Note under "order by"
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 3.1 (show other bugs)
Version: Last Call drafts
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Jonathan Robie
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-29 17:39 UTC by Michael Kay
Modified: 2015-09-30 21:17 UTC (History)
1 user (show)

See Also:


Attachments

Description Michael Kay 2015-09-29 17:39:09 UTC
Section 3.11.8 ends with the obsolete Note:

Note:

Since the order by clause in a FLWOR expression is the only facility provided by XQuery for specifying a value ordering, a FLWOR expression must be used in some queries where iteration would not otherwise be necessary. For example, a list of books with price less than 100 might be obtained by a simple path expression such as $books/book[price < 100]. But if these books are to be returned in alphabetic order by title, the query must be expressed as follows:

for $b in $books/book[price < 100]
order by $b/title
return $b

This could be replaced by a new Note:

An alternative way of sorting is available from XQuery 3.1 using the fn:sort function. In previous versions of the language, a set of books might be sorted into alphabetic order by title using the FLWOR expression:

for $b in $books/book[price < 100]
order by $b/title
return $b

In XQuery 3.1 the same effect could be achieved using the expression

$books/book
=> filter(function($book){$book/price < 100}) 
=> sort(function($book){$book/title})
Comment 1 Josh Spiegel 2015-09-30 21:17:46 UTC
Fixed as suggested except for the second example I used:

  sort(
    $books/book[price < 100],
    function($book){$book/title}
  )

Because introducing fn:filter appears unnecessary and I found it slightly distracting when comparing the examples.