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 27477 - JSON Serialization
Summary: JSON Serialization
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 3 & XPath 3 Test Suite (show other bugs)
Version: Working drafts
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: O'Neil Delpratt
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 27478
  Show dependency treegraph
 
Reported: 2014-12-01 17:40 UTC by Christian Gruen
Modified: 2014-12-16 15:25 UTC (History)
1 user (show)

See Also:


Attachments

Description Christian Gruen 2014-12-01 17:40:51 UTC
One observation on the test case "Serialization-json-31":

The following expression...

  normalize-unicode('suçon', 'NFC') = 'ç'

...yields false, so I would also expect the regex test to fail.
Comment 1 Christian Gruen 2014-12-01 17:56:16 UTC
Two more observations:

* Serialization-json-40:

Wouldn't "\t\n\r" be a valid result as well? Next, RFC7159 allows the character sequence in escaped characters to be upper or lower case, so I would recommend to use the following regex:

  \\u(0009|t)\\n\\u(000D|000d|r)
 
* Serialization-json-55:

I believe that the output ["
","\r"] would also be correct. A more flexible pattern could look as follows:

  \["&(#13|D|d);","\\u(000D|000d|r)"\]
Comment 2 Josh Spiegel 2014-12-01 21:35:07 UTC
Here is Serialization-json-31:

<test-case name="Serialization-json-31">
   <description>Test the JSON serialization output method - normalization form </description>
   <created by="Josh Spiegel" on="2014-11-02"/>
   <dependency type="spec" value="XQ31+"/>
   <test><![CDATA[

     declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
     declare option output:method "json";
     declare option output:normalization-form "NFC";
        
     "suc&#807;on"

   ]]></test>
   <result>
     <serialization-matches>"su&#231;on"</serialization-matches>
   </result>
</test-case>   

I don't understand how this expression you give relates to this test:

   normalize-unicode('suc&#807;on', 'NFC') = '&#231;'

Did you mean this expression?

   normalize-unicode('suc&#807;on','NFC') = 'su&#231;on'

I think this should evaluate to true.  

Can you clarify?
Comment 3 Christian Gruen 2014-12-01 22:07:32 UTC
Josh, thanks for the clarification and sorry for taking your time. After a second check, I can only agree that the normalization makes complete sense. So all that's left is the two other test cases on serializing &#9; and &#13;.
Comment 4 Josh Spiegel 2014-12-01 22:40:23 UTC
As I understand it, you would like the test suite to (1) allow lower case and upper case escape sequences and (2) allow \r or \u000D

On (2) the specification currently says:

"If the JSON output method is selected, replace " with \" and the newline character (&#x000A;) with \n."

It doesn't mention \r.  I think it should.

If you agree, then I think you should file a bug against the specification asking for clarification.  You could re-purpose this bug but it may be confusing that bug comment is unrelated.
Comment 5 Christian Gruen 2014-12-01 22:56:03 UTC
I have just file the new bug 27478.
Comment 6 Christian Gruen 2014-12-13 15:59:35 UTC
Based on the decision of Bug 27478, the allowed results should now be as follows:

* Serialization-json-40
  "\t\n\r "

* Serialization-json-55
  Three possible results:
  - ["&#xD;","\r"],
  - ["&#xd;","\r"]
  - ["&#13;","\r"]
Comment 7 O'Neil Delpratt 2014-12-16 14:29:55 UTC
Fix applied to the test cases Serialization-json-40 and Serialization-json-55
Comment 8 Christian Gruen 2014-12-16 15:02:02 UTC
Thanks for the fixes, O'Neil. Just one more thing. I think the special character need to be escaped:

* Serialization-json-40

  <serialization-matches>\\t\\n\\r </serialization-matches>

* Serialization-json-55

  <serialization-matches>\["&amp;#13;","\\r"\]</serialization-matches>
  <serialization-matches>\["&amp;#xD;","\\r"\]</serialization-matches>
  <serialization-matches>\["&amp;#xd;","\\r"\]</serialization-matches>
Comment 9 O'Neil Delpratt 2014-12-16 15:25:18 UTC
Fixed according to comment #8: Escaped special characters