UnaryLookup expression failure
While testing some XQuery lookup expressions on BaseX 8.6.7, I got a wrong result for this one: (map{'a':(1,3)},map{'a':(2,4)})!?a[2] It should have returned the second item of the 'a' entry for each of the maps, i.e. 3 4 but it returns just 3 Apparently the predicate is applied as if everything before it was in parentheses, i.e. as if it were ((map{'a':(1,3)},map{'a':(2,4)})!?a)[2] The (simplified) parse tree for the original expression and the XQuery 3.1 grammar however indicates that the predicate is part of the mapping target expression: <SimpleMapExpr> <ParenthesizedExpr> ... </ParenthesizedExpr> <TOKEN>!</TOKEN> <PostfixExpr> <UnaryLookup> <TOKEN>?</TOKEN> <NCName>a</NCName> </UnaryLookup> <Predicate> <TOKEN>[</TOKEN> <IntegerLiteral>2</IntegerLiteral> <TOKEN>]</TOKEN> </Predicate> </PostfixExpr> </SimpleMapExpr> Best regards Gunther
Hi Günther, Thanks for the concise bug report. I stumbled across a similar issue just recently [1], so I’m glad to confirm that the latest BaseX 9.0 snapshot returns the correct result [2]. All the best, Christian [1] https://github.com/BaseXdb/basex/commit/ab52f2dde2628bbeac5da22898bf6e28f682... [2] http://files.basex.org/releases/latest/ On Mon, Oct 30, 2017 at 8:25 PM, Gunther Rademacher <grd@gmx.net> wrote:
While testing some XQuery lookup expressions on BaseX 8.6.7, I got a wrong result for this one:
(map{'a':(1,3)},map{'a':(2,4)})!?a[2]
It should have returned the second item of the 'a' entry for each of the maps, i.e.
3 4
but it returns just
3
Apparently the predicate is applied as if everything before it was in parentheses, i.e. as if it were
((map{'a':(1,3)},map{'a':(2,4)})!?a)[2]
The (simplified) parse tree for the original expression and the XQuery 3.1 grammar however indicates that the predicate is part of the mapping target expression:
<SimpleMapExpr> <ParenthesizedExpr> ... </ParenthesizedExpr> <TOKEN>!</TOKEN> <PostfixExpr> <UnaryLookup> <TOKEN>?</TOKEN> <NCName>a</NCName> </UnaryLookup> <Predicate> <TOKEN>[</TOKEN> <IntegerLiteral>2</IntegerLiteral> <TOKEN>]</TOKEN> </Predicate> </PostfixExpr> </SimpleMapExpr>
Best regards Gunther
participants (2)
-
Christian Grün -
Gunther Rademacher