Sortby support


According to the new draft of the W3C about Xquery, a Sortby expression must return a single value for every context, otherwise an error should be raised. Quip, however, chooses to ignore the expression in this cases and produces a result anyway.

Consider for example the following query:

document(“data\tree-data.xml”)/book/section Sortby (…/author)

The book has more than one author, so an error should be raised.


Thank you for pointing this out. That one slipped my attention.

As you can imagine, I am not always pleased, when a new draft of the W3C
working group is published, because it means work…

Therefore, I am afraid you will find more such inconsistencies, (e.g. the filter function of
quip takes two arguments, instead of just one as proposed in the latest draft.)

However, I am always grateful, if someone points these things out, such that we
can put them on our to-do list.

Sven Eric

I checked the documents of the query group again. You are right, in the
XQuery 1.0 paper it says:

For each member of the sequence, the ordering expression must return a single
value of some type for which the “>” operator is defined (for example, a number or a
string); otherwise an error results.

But, as a matter of fact, > is defined on node-sets (even if it is not nicely defiend). In the
semantics paper I did not find this restriction. There just a reference to the ordering
relation > is made, which actually is defiend for sets as:

[[ E1 < E2 ]]
[[ not(empty(for $v1 in [[E1]] return
for $v2 in [[E2]] return
if lt($v1, $v2) then $v1 else ())) ]] ]]

Sven Eri