[xquery-talk] Error when using predicate after arrow operator

Joe Wicentowski joewiz at gmail.com
Thu Apr 13 13:36:21 PDT 2017


Hi John,

Thanks for your reply.  I had discovered that parentheses would allow the
query to complete without error, but I struggled to see what rule in the
spec my query violated.  Now I see it: the predicate isn't valid in the
ArrowFunctionSpecifier, defined at
https://www.w3.org/TR/xquery-31/#doc-xquery31-ArrowFunctionSpecifier as:

  EQName | VarRef | ParenthesizedExpr

So the parser sees the ParenthesizedExpr in my `tokenize("\.")` and then
chokes on the following character, the open square bracket.

Thanks for helping me see this!
Joe

On Thu, Apr 13, 2017 at 3:44 PM, John Snelson <John.Snelson at marklogic.com>
wrote:

> The equivalence holds for how it functionally behaves, not for what
> grammar the parser allows. You need parentheses:
>
> ("1.2.3" => tokenize("\."))[. < "3"]
>
>
> John
>
> On 13/04/2017 20:09, Joe Wicentowski wrote:
> > Hi all,
> >
> > As I understand the arrow operator
> > (https://www.w3.org/TR/xquery-31/#id-arrow-operator), the following
> > query:
> >
> >    "1.2.3" => tokenize("\.")
> >
> > is equivalent to:
> >
> >     tokenize("1.2.3", "\.")
> >
> > If this is so, then can anyone shed light on why appending a predicate
> > to the former would raise an error but not so for the latter?  In
> > Saxon, eXist, and BaseX, the following expression:
> >
> >    "1.2.3" => tokenize("\.")[. < "3"]
> >
> > raises an error like:
> >
> >    XPST0003: Unexpected token "[" beyond end of query
> >
> > whereas the pre-XQuery 3.1 approach:
> >
> >     tokenize("1.2.3", "\.")[. < "3"]
> >
> > returns the results I'd expect:
> >
> >    ("1", "2")
> >
> > Thanks,
> > Joe
> > _______________________________________________
> > talk at x-query.com
> > http://x-query.com/mailman/listinfo/talk
>
>
> --
> John Snelson, Principal Engineer              http://twitter.com/jpcs
> MarkLogic Corporation                         http://www.marklogic.com
>
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://x-query.com/pipermail/talk/attachments/20170413/56232052/attachment.html>


More information about the talk mailing list