This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 29273 - [SER31] Adaptive Serialization: serialization of strings, result of fn:string
Summary: [SER31] Adaptive Serialization: serialization of strings, result of fn:string
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Serialization 3.1 (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: C. M. Sperberg-McQueen
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-09 15:49 UTC by Christian Gruen
Modified: 2015-11-18 13:41 UTC (History)
3 users (show)

See Also:


Attachments

Description Christian Gruen 2015-11-09 15:49:52 UTC
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.
Comment 1 Michael Kay 2015-11-09 16:55:40 UTC
>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.
Comment 2 Christian Gruen 2015-11-09 17:02:24 UTC
> 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?
Comment 3 Michael Kay 2015-11-09 17:23:00 UTC
Yes, of course, you are right: XQuery requires ampersands to be escaped in string literals. I have never understood why.
Comment 4 Andrew Coleman 2015-11-18 13:41:44 UTC
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