expath / expath-cg

Repository for the W3C EXPath Community Group.
15 stars 6 forks source link

file write serialization tests #134

Open benibela opened 3 years ago

benibela commented 3 years ago

There are no tests for file:write in https://github.com/expath/expath-cg/blob/master/tests/qt3/file/file.xml

All the serialization tests from qt3 could be imported for it

One case, I am not sure about, is the expected output of file:write("output.json", "{""a"": ""foo""}" ). Is it {"a": "foo"} or {"a": "foo"}. Probably former, but that is useless..

ChristianGruen commented 3 years ago

It’s supposed to be {"a": "foo"}.

benibela commented 3 years ago

Because " does not need to be escaped at all? How about this test case: file:write("output.json", "{""a"": ""<>foo""}" ). Is it {"a": "<>foo"} or {"a": "&lt;&gt;foo"} ?

ChristianGruen commented 3 years ago

I’d need to check the W3 serialization spec in more depth to give a helpful answer (fn:serialize('&quot;&lt;&gt;') returns "&lt;&gt;).

benibela commented 3 years ago

There is not really a point in escaping > and not escaping " or vice verse.

For characters such as > where XML defines a built-in entity but does not require its use in all circumstances, it is implementation-dependent whether the character is escaped.

https://www.w3.org/TR/xslt-xquery-serialization-31/#serphases

michaelhkay commented 3 years ago

On 26 Jan 2021, at 11:38, Benito van der Zander notifications@github.com wrote:

There is not really a point in escaping > and not escaping " or vice verse.

If you're processing a text node, then escaping " is pointless, but escaping ">" unconditionally saves you the hassle of checking to see whether it's part of a "]]>" sequence.

Michael Kay Saxonica