[xquery-talk] Is this a valid query?

Michael Kay mike at saxonica.com
Sun Jan 10 13:51:48 PST 2016


There's an open bug against the spec on the use of ?-placeholders in conjunction with the arrow operator.

https://www.w3.org/Bugs/Public/show_bug.cgi?id=29346

The grammar allows it, but the semantics have not been specified.

My own view is that

X => map:for-each(A, ?)

should mean

map:for-each(X, A, ?)

which is an error because there are too many arguments.

But we need to await the WG decision on this bug.

Michael Kay
Saxonica


> On 10 Jan 2016, at 19:30, Adam Retter <adam.retter at googlemail.com> wrote:
> 
> Given this valid XQuery (1):
> 
> map:for-each(
>    map {
>        "a" : "1",
>        "b" : "2",
>        "c" : "3"
>    },
>    ?
> )(function($k, $v) {
>    "$k=" || $k
> })
> 
> I am wondering, if rewriting it to the following form results in a
> valid query with the same execution result (2):
> 
> function($k, $v) {
>    "$k=" || $k
> } =>
>    map:for-each(
>        map {
>            "a" : "1",
>            "b" : "2",
>            "c" : "3"
>        },
>        ?
>    )()
> 
> In my mind it does, however I can't find a current implementation
> (eXist, BaseX, Saxon-EE) which will execute it, I guess this is due to
> evaluation order of the expressions (although I get parser errors).
> 
> If I add some brackets to (2), to add precedence to the evaluation
> order so that I have (3):
> 
> function($k, $v) {
>    "$k=" || $k
> } =>
>    (
>    map:for-each(
>        map {
>            "a" : "1",
>            "b" : "2",
>            "c" : "3"
>        },
>        ?
>    ))()
> 
> 
> Then it does seem to execute on BaseX and Saxon, but it feels like I
> shouldn't need to add the brackets and that (2) should work! Can
> someone add some comment/insight for me as to whether the XQuery spec
> requires these brackets to make the parse and execution correct?
> Somehow, I can't see it at the moment...
> 
> 
> Thanks Adam.
> 
> -- 
> Adam Retter
> 
> skype: adam.retter
> tweet: adamretter
> http://www.adamretter.org.uk
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk





More information about the talk mailing list