
Hi Jan,
I was also using the GROUP BY construct. This is my query: ... let $qid := tijah:queryall-id($query_nexi, $options) let $nodes := tijah:nodes($qid) let $result := for $node in $nodes return typeswitch ($node) case $elem-node as element(*) return <result> <num> { (count($node/$elem-node/preceding::*) + 1) + This snippet of XQuery is to complex: 'count($node/$elem-node/...'. Both $node and $elem-node contain the tijah-result nodes (with type node() and element(*), respectively). What you want to write is 'count($elem-node/...'.
string-length(tijah:getINEXPath($node)) } </num> <file> { data($node/$elem-node/ancestor-or-self::EAD/@FILE) } file> <title> { data($node/$elem-node/ancestor-or-self::EAD/@TITLE) } </title> ...
<score> { tijah:score($qid, $node/$elem-node) } </score> </result> default return error ("unexpected node")
let $total := count($result) return <results total="{$total}"> { for $res at $rankGlobal in distinct-values($result/file) let $cs-group := $result[file = $res] for $cs-group2 at $rank in $cs-group where exists($cs-group2)
On Jan 14, 2009, at 11:53, jz@uva wrote: this line is unnecessary as there is always exactly one item bound to $cs-group2.
and $rank >= 1
this line is unnecessary as the positional variable always starts from 1 (and can never be less).
and $rank <= 8 and $rankGlobal >= $start and $rankGlobal <= $end order by $cs-group2 cast as xs:integer
what do you want here? I very much doubt that you are able to atomize an XML snippet, then cast the string-value into a number and still get something meaningful out.
return <out id="{$res}">{ $cs-group2 }</out> } </results>
With this query, I get different results in MPS and Alg.
I guess MPS treats your order by differently---read incorrectly---by ignoring every character data after the first number which accidently is the content of element num. Perhaps your query already works the way you expect it by replacing the ORDER BY by the following snippet: 'order by number($cs-group2/ num)'. Jan -- Jan Rittinger Lehrstuhl Datenbanken und Informationssysteme Wilhelm-Schickard-Institut für Informatik Eberhard-Karls-Universität Tübingen http://www-db.informatik.uni-tuebingen.de/team/rittinger