This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
The spec states that, for adaptive serialization, "an instance of xs:string or xs:untypedAtomic is serialized by enclosing the value in double quotation marks and doubling any quotes within the value; or optionally by enclosing the value in apostrophes and doubling any apostrophes within the value." Ampersand characters should probably be represented as "&". The same rule could be applied to value of any other type: Right now, the spec says that "VAL is the result of applying the fn:string() function", but it may not immediately be clear how the result is going to look like if fn:string() yields ampersands or quotes.
>Ampersand characters should probably be represented as "&". I don't agree. XQuery doesn't require ampersands to be escaped in a string literal, and XPath doesn't even allow it. We shouldn't encourage users to think of using XML escaping outside XML text and attribute nodes.
> I don't agree. XQuery doesn't require ampersands to be escaped in a string > literal, and XPath doesn't even allow it. We shouldn't encourage users to > think of using XML escaping outside XML text and attribute nodes. I didn’t reflect about XPath; but the XQuery grammar for string literals is as follows: [222] StringLiteral ::= ('"' (PredefinedEntityRef | CharRef | EscapeQuot | [^"&])* '"') | ("'" (PredefinedEntityRef | CharRef | EscapeApos | [^'&])* "'") So I was assuming that ampersands would always need to be escaped? And otherwise, "&" would be ambiguous, as long as the ampersand character *may* be escaped?
Yes, of course, you are right: XQuery requires ampersands to be escaped in string literals. I have never understood why.
The WG decided to adopt the proposal described in the following message https://lists.w3.org/Archives/Public/public-xsl-query/2015Nov/0035.html This also addresses bug 29272