(Q15) Make an alphabetic list of publishers. Within each publisher, make a list of books, each containing a title and a price,
in descending order by price.
<publisher_list>
FOR $p IN distinct(document("bib.xml")//publisher)
RETURN
<publisher>
<name> $p/text() </name> ,
FOR $b IN document("bib.xml")//book[publisher = $p]
RETURN
<book>
$b/title ,
$b/price
</book> SORTBY(price DESCENDING)
</publisher> SORTBY(name)
</publisher_list>
- This query introduces the SORTBY clause, which is applied after and intermediate result has been constructed; it thus behaves differently than
xsl:sort
|