Exist: Problem with string constructor interpolations surrounded by quotes

Created on 3 Mar 2017  路  4Comments  路  Source: eXist-db/exist

What is the problem

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.

What did you expect

No error with the following code:

How to reproduce or add a test

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!

Context information

  • eXist-db version: eXist-db 3.0 develop
  • Java version: Java 1.8.0_121-b13
  • Operating system: macOS
  • 64 bit
  • Any custom changes in e.g. conf.xml: no
bug

Most helpful comment

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

All 4 comments

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