concat
adds another double quote if an input string includes one.
I am using XQuery 3.1 on eXide. A̶F̶A̶I̶K̶,̶ ̶e̶X̶i̶d̶e̶ ̶u̶s̶e̶s̶ ̶S̶a̶x̶o̶n̶ ̶a̶s̶ ̶X̶Q̶u̶e̶r̶y̶ ̶e̶n̶g̶i̶n̶e̶.̶ (it doesn't, see joewiz answer below).
The bug occurs when I evaluate concatenated strings.
return concat("'", 'bar')
evaluates to 'bar
which is expected.
return concat('"', 'bar')
evaluates to ""bar
.
How comes? I thought there was no difference between single and double quotes in xquery.
Here's my script:
xquery version "3.1";
let $c := concat('"','car')
return $c
By default, eXide serializes query results using the standard adaptive output method. Since the concat()
function returns a string, adaptive output wraps the strings in double quotes and escapes any double quotes within the string by doubling them. This explains the phenomenon you are seeing.
From the W3C spec linked above:
An instance of
xs:string
,xs:untypedAtomic
orxs:anyURI
is serialized by enclosing the value in double quotation marks and doubling any quotes within the value.
If you would instead like to see your results without any such quote escaping, you can use the dropdown menu just above eXide's query output pane and select "Text Method" or "XML Method" instead.
eXide's documentation (viewable via Help > Documentation) explains its serialization feature and default setting as follows:
In 2.4.0, eXide jettisoned its longstanding “pretty-printing” library, now using eXist’s built-in serialization methods. This change means improved whitespace accuracy and speed when viewing your query results, and turns eXide into a serialization sandbox. By toggling the output methods via the “Output” dropdown menu, you can serialize query results not just as Adaptive, JSON, XML, or the old “direct” (rendered) method, but also as Text, HTML5, XHTML, XHTML5, and MicroXML. The new “Indent” checkbox lets you toggle whether query results are indented or not.
Finally, I should note that eXist has its own native XQuery engine, and eXide passes queries directly to eXist for execution, not to Saxon. eXist uses Saxon solely for XSLT - i.e., when you use the transform
module to invoke an XSLT from XQuery.