Support for XQuery 3.1 string constructors (https://www.w3.org/TR/xquery-31/#id-string-constructors) was added in https://github.com/eXist-db/exist/pull/1297. Running the current develop branch, I get an error when surrounding an interpolation with quotes.
No error with the following code:
xquery version "3.1";
let $a := "my"
return
``[Hello "`{$a}`" world!]``
or as an xqsuite test:
xquery version "3.1";
module namespace sc="http://exist-db.org/xquery/test/string-constructor";
declare namespace test="http://exist-db.org/xquery/xqsuite";
declare
%test:assertEquals('Hello "my" world!')
function sc:simple-interpolation-surrounded-by-quotes() {
let $a := "my"
return
``[Hello "`{$a}`" world!]``
};
This yields the error:
Cannot compile xquery: exerr:ERROR expecting '"', found '<EOF>' [at line 12, column 39]
BaseX 8.6 and Saxon 9.7.0.4 return the expected results: Hello "my" world!
Looks like a lexer issue with the " inside the string constructor. It works if you remove the quotes:
``[Hello `{$a}` world!]``
I'll try to fix it for 3.1
@wolfgangmm Sounds great, thank you. By the way, the test case above was reduced from this example from my book:
xquery version "3.1";
let $name := "XQuery Working Group"
return
``[
prefix foaf: <http://xmlns.com/foaf/0.1/> .
_:xqywg a foaf:Group;
foaf:name "`{ $name }`" .
]``
Should return:
prefix foaf: <http://xmlns.com/foaf/0.1/> .
_:xqywg a foaf:Group;
foaf:name "XQuery Working Group" .
Shall we tag this with the "3.1.0" milestone and a "bug" label?
@dizzzz Thanks!
@wolfgangmm No worries if a fix doesn't make it in to 3.1.0, of course. It can certainly be relegated to the "known issues" list - and deferred an upcoming bugfix or minor release. I just used the string constructor via the latest nightly to escape some quick-and-dirty CSS definitions in an HTML document's
Most helpful comment
Looks like a lexer issue with the " inside the string constructor. It works if you remove the quotes:
I'll try to fix it for 3.1