[MonetDB-users] Two questions with XQuery
Hi there, I'm currently porting some XQuery scripts to MonetDB/XQuery, and encountered two maybe simple obstacles. The first one is that I can't use fn:collection, but instead always have to apply pf:collection. The online documentation [1] states both alternatives should be practicable. For example in eXist and Sedna I can write: let $a := fn:collection("samples") return $a//id But this does not work for MonetDB/XQuery! Here I have to use: let $a := pf:collection("samples")/child::document-node() return $a//id 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> So what am I doing wrong? Does MonetDB/XQuery by any chance comply more with any standards than eXist and Sedna do? Or ist fn:collection just not implemented in the current release of MonetDB/XQuery? I would be glad if someone could give me a hint! It's so confusing... Thank you! Regards, Andreas Meinl [1] http://monetdb.cwi.nl/projects/monetdb/XQuery/QuickTour/DOCMGT/ index.html#openall
Hi Andreas, On Thu, Jul 17, 2008 at 12:17:33PM +0200, Andreas Meinl wrote:
Hi there,
I'm currently porting some XQuery scripts to MonetDB/XQuery, and encountered two maybe simple obstacles.
The first one is that I can't use fn:collection, but instead always have to apply pf:collection. The online documentation [1] states both alternatives should be practicable.
For example in eXist and Sedna I can write:
let $a := fn:collection("samples") return $a//id
But this does not work for MonetDB/XQuery! Here I have to use:
let $a := pf:collection("samples")/child::document-node() return $a//id
The latest release of MonetDB/XQuery does currently not support fn:collection() with (new and default) "Algebra" back-end of the pathfinder compiler. fn:collection() is currently only available with the (still included but obsolete/deprecated) "milprint_summer" back-end. See the release notes for details: http://monetdb.cwi.nl/Development/Releases/Version4.24/index.html#XQuery For details about the differences please see http://monetdb.cwi.nl/XQuery/QuickTour/DOCMGT/index.html#openall We apologize for the inconveniences, and plan to implement fn:collection() also with the (default) "Algebra" back-end in the next release of MonetDB/XQuery.
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?
So what am I doing wrong? Does MonetDB/XQuery by any chance comply more with any standards than eXist and Sedna do? Or ist fn:collection just not implemented in the current release of MonetDB/XQuery?
To the best of our knowledge, MonetDB/XQuery complies with the W3C XQuery standard. See above for details concerning fn:collection() & pf:collectio(). For details on the remaining supported functionality and extensions beyond the XQuery standard, please the MonetDB/XQuery web site at http://monetdb.cwi.nl/XQuery/index.html and the latest release notes at http://monetdb.cwi.nl/Development/Releases/Version4.24/index.html#XQuery
I would be glad if someone could give me a hint! It's so confusing...
I hope, I managed to clearify the confusion. Please don't hesitate to ask again in case you have more questions. Kind regards, Stefan
Thank you!
Regards,
Andreas Meinl
[1] http://monetdb.cwi.nl/projects/monetdb/XQuery/QuickTour/DOCMGT/ index.html#openall
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |
Stefan Manegold wrote:
Why can't you use "pf:collection("samples")/child::document-node()" in the for loop? Do you get any error? If so which?
I tried something similar this morning, and it does not work... you will have to write pf:collection("samples")//document-node() which is slow but works. the child step from the collection node does not work, which is probabaly a bug. -henning
On Thu, Jul 17, 2008 at 02:05:59PM +0200, Henning Rode wrote:
Stefan Manegold wrote:
Why can't you use "pf:collection("samples")/child::document-node()" in the for loop? Do you get any error? If so which?
I tried something similar this morning, and it does not work...
you will have to write
pf:collection("samples")//document-node()
which is slow but works. the child step from the collection node does not work, which is probabaly a bug.
Then please report it as such via the SF bug tracker. Stefan
-henning
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |
Hi Stefan, thanks for your quick reply! Regarding fn:collection I'll just wait for the next release of MonetDB/XQuery. But as pf:collection should be faster, I'm going to favor this approach anyway. 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. Can you do anything with it? (Is the mentioned slash the one of the end-tag "</average>"? But even so, this is not column 9... and there is no further slash in this line...) @Henning: For me pf:collection("samples")/child::document-node() works fine and gives me the same result as pf:collection("samples")// document-node(). Regards, Andreas Meinl
On Thu, Jul 17, 2008 at 02:37:37PM +0200, Andreas Meinl wrote:
Hi Stefan,
thanks for your quick reply!
Regarding fn:collection I'll just wait for the next release of MonetDB/XQuery. But as pf:collection should be faster, I'm going to favor this approach anyway.
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 ... Stefan
Can you do anything with it? (Is the mentioned slash the one of the end-tag "</average>"? But even so, this is not column 9... and there is no further slash in this line...)
@Henning: For me pf:collection("samples")/child::document-node() works fine and gives me the same result as pf:collection("samples")// document-node().
Regards,
Andreas Meinl
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |
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? (As performance matters I want to avoid the double slashes.) Regards, Andreas Meinl
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 ...
(As performance matters I want to avoid the double slashes.)
I see --- what about the following to also avoid the for loop (although that should not make too much of a performance difference thanks to loop-lifting in MonetDB/XQuery): let $sums := pf:collection("samples")/child::document-node()/example/@sum return <average> { fn:round(fn:avg( $sums )) } </average> Stefan
Regards,
Andreas Meinl
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |
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
On 07/17/2008 04:59 PM, Andreas Meinl wrote with possible deletions:
Ok, I have filled in a bug report on SourceForge. Let's see what time will bring...
As far as I can oversee -- I fixed it. Meanwhile you could just use node() instead of document-node(). The kindtest node() is even no-cost :-) Jan -- Jan Rittinger Database Systems Technische Universität München (Germany) http://www-db.in.tum.de/~rittinge/
sorry for the irritating quick reply... for me it also works now. what i did wrong this morning, was to write the query like this: count(pf:collection("wikipedia")/child::*) the result is then "0", which is actually correct, since the name-test on "*" selects only element nodes. -henning Andreas Meinl wrote:
Hi Stefan,
thanks for your quick reply!
Regarding fn:collection I'll just wait for the next release of MonetDB/XQuery. But as pf:collection should be faster, I'm going to favor this approach anyway.
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.
Can you do anything with it? (Is the mentioned slash the one of the end-tag "</average>"? But even so, this is not column 9... and there is no further slash in this line...)
@Henning: For me pf:collection("samples")/child::document-node() works fine and gives me the same result as pf:collection("samples")// document-node().
Regards,
Andreas Meinl
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
participants (4)
-
Andreas Meinl
-
Henning Rode
-
Jan Rittinger
-
Stefan Manegold