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 29007 - json-to-xml definition is inconsistent with construction from PSVI
Summary: json-to-xml definition is inconsistent with construction from PSVI
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 3.1 (show other bugs)
Version: Candidate Recommendation
Hardware: PC All
: 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: 2015-07-30 16:31 UTC by Josh Spiegel
Modified: 2016-12-16 19:55 UTC (History)
0 users

See Also:


Attachments

Description Josh Spiegel 2015-07-30 16:31:31 UTC
In FNO 3.1, 17.5.3 fn:json-to-xml:

"The XDM tree returned by the function does not contain any unnecessary (albeit valid) nodes such as whitespace text nodes, comments, or processing instructions, or attributes (escaped and escaped-key) whose value is equal to the default value (false)."

In XDM 3.1, 6.2.4 Construction from a PSVI:

  attributes
     "Default and fixed attributes provided by XML Schema processing are added to the [attributes]"

Example 1:

  import schema namespace fn = "http://www.w3.org/2005/xpath-functions";
  validate { 
    json-to-xml('"foo"', map { 'validate' : false() })  
  }

Result:

  <string escaped="false" xmlns="http://www.w3.org/2005/xpath-functions">foo</string>

Example 2:

  json-to-xml('"foo"', map { 'validate' : true() }) 
  
Result 2:

  <string xmlns="http://www.w3.org/2005/xpath-functions">foo</string>


And, the following expression will often return false:

  deep-equal(
    json-to-xml(json, map { 'validate' : true() }),
    validate { json-to-xml(json, map { 'validate' : false() }) }
  )

I think the WG should make the behavior of the 'validate' flag consistent with validation by either removing the default from the schema or by adding the defaults in the definition of json-to-xml.
Comment 1 Michael Kay 2015-09-01 15:48:32 UTC
The WG decided: if the result is typed, the defaulted attributes must be present; if the result is untyped, the defaulted attributes must be absent.
Comment 2 Michael Kay 2015-09-02 17:29:58 UTC
To implement the decision, I propose to change the paragraph

The XDM tree returned by the function does not contain any unnecessary (albeit valid) nodes such as whitespace text nodes, comments, or processing instructions, or attributes (escaped and escaped-key) whose value is equal to the default value (false). It does not include any whitespace in the value of number or boolean element nodes.

to read:

The XDM tree returned by the function does not contain any unnecessary (albeit valid) nodes such as whitespace text nodes, comments, or processing instructions. It does not include any whitespace in the value of number or boolean element nodes, or in the values of the *escaped* and *escaped-key* attribute nodes. 

If the result is typed, every element named *string* will have an attribute named *escaped* whose value is either "true" or "false", and every element having an attribute named *key* will also have an attribute named *escaped-key* whose value is either "true" or "false".

If the result is untyped, the attributes *escaped* and *escaped-key* will never be present with the value "false". (In cases where the value false would be appropriate, the attribute will be absent). 

The changes have been applied.
Comment 3 Josh Spiegel 2015-09-02 17:32:48 UTC
Sounds good to me.  Thanks.