Open adamretter opened 5 years ago
is this a separate problem from #2205, i can't really tell?
@duncdrum yes, it's different.
It seems the parser already chokes on the implicit context element .?headers
at least changes the error message.
The verbose equivalent of the code does run
filter($ms, function ($m) {
not(empty(
filter($m?headers, function ($h) {
matches($h?value, 'filename="fred"')})))})
@line-o Er.. I don't use .
in the code above?!?
@adamretter yes, doing that just changes the error. That was all I wanted to add.
I tested two simplified queries:
$ms[not(empty(?headers))]
error found while executing expression: org.exist.xquery.XPathException: err:XPST0003 expecting closing parenthesis ')', found 'headers' [at line ...]
vs
$ms[not(empty(.?headers))]
Unexpectedly received 2 parameter(s) in call to function 'empty()'. Defined function signatures are: empty($items as item()*) xs:boolean
I am also wondering, if the same syntax for filtering node sets //a[.]
also applies to sequences of maps, but I could not find anything. The xquery spec does refer to node-sets only, it seems.
@adamretter Maybe I am missing something, can you give me a pointer?
I can confirm it works in BaseX. So do both of the simplified queries, I posted above.
exist 5.3.0-SNAPSHOT is affected
The originally reported issue seems to be limited to map lookups with implicit context passed to function calls inside of predicates.
(map {"f": 1}, map {"f": 2})[string(?f) eq '1']
whereas this works
(map {"f": 1}, map {"f": 2})[?f > 1]
With the changes to the XQuery parser included in eXist 5.3.0 you can write:
$ms[?headers[?value ! matches(., 'filename="fred"')] => exists()]
which is further proof that the unary lookup passed to a function call inside a predicate is the root cause of this issue.
and $ms[not(empty(.?headers[matches(.?value, 'filename="fred"')]))]
returns the expected result.
The following query should return the second map, instead we get an error
XPST0003
. This does work in BaseX and Saxon, but not in eXist-db. Appears to be a parser error.Tested on eXist-db 5.0.0-RC6