Paul J. Lucas
Paul J. Lucas

Reputation: 7123

XML serialization of tab an newline using XQuery

If you look at the the W3C XQuery test K2-Serialization-7.xq:

<a>{ codepoints-to-string(1 to 31) }</a>

the expected result (according to the W3C test suite) escapes all the characters in the the ASCII range 1-31:

<a>&#x1;&#x2;&#x3;&#x4;&#x5;&#x6;&#x7;&#x8;&#x9;&#xA;&#xB;&#xC;&#xD;&#xE;&#xF;&#x10;&#x11;&#x12;&#x13;&#x14;&#x15;&#x16;&#x17;&#x18;&#x19;&#x1A;&#x1B;&#x1C;&#x1D;&#x1E;&#x1F;</a>

It's not clear why the tab (0x9) and newline (0xA) characters are escaped at since they're perfectly legal in XML files. Hence, the expected result seems wrong. Can anybody explain this?

Upvotes: 0

Views: 1236

Answers (1)

user357812
user357812

Reputation:

In fact your expected result is wrong.

From http://www.w3.org/TR/2008/REC-xml-20081126/#charsets

Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] 

Only in XML 1.1 this was changed. From http://www.w3.org/TR/2006/REC-xml11-20060816/#dt-character

Char    ::=    [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] 

Upvotes: 2

Related Questions