Thank you Leo,

It works perfectly!
You have helped me a lot.

Have a nice day!

Regards,

Wiard

2011/4/3 Leonard Wörteler <leonard.woerteler@uni-konstanz.de>
Dear Wiard,

Am 03.04.2011 18:44, schrieb Wiard Vasen:
> for $n at $pos in db:open("tfidfbrievenvangogh")
> where $pos > ( "let001.xml") and $pos < ( "let201.xml")
> return
> for $i in $n//*
> where $i[text() contains text 'above']
> return <hit>{base-uri($i)}<score>{ft:score($i[text() contains text
> 'above'])}</score></hit>

does this (rather drastical) rewriting approximately do what you want?

let $range := 1 to 201
for $doc in collection('tfidfbrievenvangogh')
let $uri := base-uri($doc),
   $num := substring($uri, string-length($uri) - 6, 3)
where $num castable as xs:integer
 and xs:integer($num) = $range
return <document uri='{$uri}'>{
 for $n score $s in $doc//*[text() contains text 'above']
 return <hit score='{$s}'>{ $n }</hit>
}</document

I added some structure to the output (which you can easily remove), used
only standard functions and optimized the query for performance where I
saw fit.

Hope that helps,
 cheers Leo