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 27156 - fn:parse-json
Summary: fn:parse-json
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 3.1 (show other bugs)
Version: Working drafts
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-24 16:41 UTC by Christian Gruen
Modified: 2014-11-17 10:37 UTC (History)
3 users (show)

See Also:


Attachments

Description Christian Gruen 2014-10-24 16:41:34 UTC
I have two question on the specification of fn:parse-json (Working Draft, Oct 7):

* What is supposed to be the default value for the "liberal" option?

* If "unescape" is set to true, will invalid XML characters be replaced by xFFFD, or will an error be raised instead (FOJS0002)?
Comment 1 C. M. Sperberg-McQueen 2014-10-28 19:08:48 UTC
The description of errors says:

    A dynamic error [err:FOJS0001] occurs if the value of $input does not 
    conform to the JSON grammar, unless the option "liberal":true() is 
    present and the processor chooses to accept the deviation.

I think that amounts to saying that the default value is false().
Comment 2 Jonathan Robie 2014-10-28 19:14:18 UTC
(In reply to Christian Gruen from comment #0)
> I have two question on the specification of fn:parse-json (Working Draft,
> Oct 7):
> 
> * What is supposed to be the default value for the "liberal" option?

The default must be False - see this error condition:

A dynamic error [err:FOJS0001] occurs if the value of $input does not conform to the JSON grammar, unless the option "liberal":true() is present and the processor chooses to accept the deviation.

That should be stated explicitly in the table.

> * If "unescape" is set to true, will invalid XML characters be replaced by
> xFFFD, or will an error be raised instead (FOJS0002)?

This error seems to answer the question:

A dynamic error [err:FOJS0002] occurs if the value of $input contains an escaped representation of a character (or codepoint) that is not a valid character in the version of XML supported by the implementation, unless the unescape option is set to false.
Comment 3 Jonathan Robie 2014-10-28 19:17:03 UTC
> > * If "unescape" is set to true, will invalid XML characters be replaced by
> > xFFFD, or will an error be raised instead (FOJS0002)?
> 
> This error seems to answer the question:
> 
> A dynamic error [err:FOJS0002] occurs if the value of $input contains an
> escaped representation of a character (or codepoint) that is not a valid
> character in the version of XML supported by the implementation, unless the
> unescape option is set to false.

Ah, but the specification also says this:

If the input contains escape sequences representing characters or codepoints that are valid characters in the version of XML supported by the implementation, the escape sequence is replaced by the character(s) that it represents. If the input contains escape sequences representing characters or codepoints that are not valid characters in the version of XML supported by the implementation, the escape sequence is replaced by the Unicode replacement character (xFFFD).

So this seems to answer the question two different ways, and they contradict each other.
Comment 4 Michael Kay 2014-11-11 17:26:09 UTC
Also note that the table (first entry) says "An error must be raised (TBA) " - the TBS needs to be resolved
Comment 5 Andrew Coleman 2014-11-14 13:12:02 UTC
At the telecon on 2014-11-11, the WG agreed the following resolution to this bug...


DECISION: On encountering invalid escape sequences, use the Unicode 
replacement character.