This is with eXist-2.0.RC:
At http://www.w3.org/TR/xquery-30-use-cases/#groupby_q6 the w3c mentions ordering by a non-grouping key - I do not even know, if their example is valid syntax at all. I read it as "my masters voice" though.
The sample there fails in eXist with the message: Cannot compile xquery: exerr:ERROR err:XPST0003: No closing end tag found for element constructor
I would expect both revisions of the code below to be equivalent. The puzzle: are statements ordered like this valid xquery? If so, then eXist does not conform…
for, let, group, let, order
Works in eXist 2.0.RC: anonymous key ordering
xquery version "3.0"; let $zoo := <zoo> <dweller kind="dog" name="frodo"/> <dweller kind="cat" name="mimi"/> <dweller kind="dog" name="nero"/> <dweller kind="dog" name="bello"/> <dweller kind="cat" name="mitzi"/> <dweller kind="cow" name="berta"/> </zoo> return <animals>{ for $dwellers in $zoo//dweller let $kind := $dwellers/@kind group by $kind order by count($dwellers) return <species kind="{$kind}" count="{count($dwellers)}">{ for $animal in $dwellers order by $animal/@name return <animal name="{$animal/@name}"/> }</species> }</animals>
Fails in eXist 2.0.RC: named key ordering
xquery version "3.0"; let $zoo := <zoo> <dweller kind="dog" name="frodo"/> <dweller kind="cat" name="mimi"/> <dweller kind="dog" name="nero"/> <dweller kind="dog" name="bello"/> <dweller kind="cat" name="mitzi"/> <dweller kind="cow" name="berta"/> </zoo> return <animals>{ for $dwellers in $zoo//dweller let $kind := $dwellers/@kind group by $kind let $count := count($dwellers) order by $count return <species kind="{$kind}" count="{$count}">{ for $animal in $dwellers order by $animal/@name return <animal name="{$animal/@name}"/> }</species> }</animals>
Dannes Wessels
2012-11-27
Dannes Wessels
2012-11-27