On 17.07.2008, at 15:27, Stefan Manegold wrote:
On Thu, Jul 17, 2008 at 03:14:41PM +0200, Andreas Meinl wrote:
On 17.07.2008, at 12:52, Stefan Manegold wrote:
My second question is that I cannot execute this kind of queries, which runs well in eXist and Sedna:
<average> { fn:round(fn:avg( for $doc in fn:collection("samples") return $doc/example/@sum )) } </average>
For MonetDB/XQuery I have to pull out pf:collection and add a second return statement:
let $col := pf:collection("samples")/child::document-node() return <average> { fn:round(fn:avg( for $doc in $col return $doc/example/@sum )) } </average>
Why can't you use "pf:collection("samples")/child::document-node ()" in the for loop? Do you get any error? If so which?
When I use pf:collection in the for loop, I get this output:
xquery><average> { more>fn:round(fn:avg( more>for $doc in pf:collection("samples")/child::document-node() more>return $doc/example/@sum more>)) } </average> more><> MAPI = monetdb@localhost:50000 QUERY = <average> { ERROR = !parse error: syntax error, unexpected /, expecting QName on line 5, column 9 (next token is `/') !parse error: XQuery parsing failed xquery>
The expected result is "<average>12345</average>" like it is in eXist and Sedna.
wouldn't
<average> { fn:round(fn:avg( pf:collection("samples")//example/@sum )) } </average>
do the same job? --- that compiles fine with me ...
Indeed, this version seems to work - but not, when I replace "//" by "/child::document-node()/". Then I get the same error message:
xquery><average> { more>fn:round(fn:avg( more>pf:collection("samples")/child::document-node()/example/@sum more>)) } </average> more><> MAPI = monetdb@localhost:50000 QUERY = <average> { ERROR = !parse error: syntax error, unexpected /, expecting QName on line 4, column 9 (next token is `/') !parse error: XQuery parsing failed xquery>
The first version (the one with the "let" statement) works fine even with "/child::document-node()/". And there are no further differences... So why is "/child::document-node()/" working outside the "<average>" element, but not inside?
I honestly don't know. Could you please file a bug report via the SF bug tracker to document it? Then we / "someone" will have a look at it once there is time ...
Ok, I have filled in a bug report on SourceForge. Let's see what time will bring... Thanks a lot for you help! Regards, Andreas Meinl