<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>29007</bug_id>
          
          <creation_ts>2015-07-30 16:31:31 +0000</creation_ts>
          <short_desc>json-to-xml definition is inconsistent with construction from PSVI</short_desc>
          <delta_ts>2016-12-16 19:55:29 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Functions and Operators 3.1</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Josh Spiegel">josh.spiegel</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>122328</commentid>
    <comment_count>0</comment_count>
    <who name="Josh Spiegel">josh.spiegel</who>
    <bug_when>2015-07-30 16:31:31 +0000</bug_when>
    <thetext>In FNO 3.1, 17.5.3 fn:json-to-xml:

&quot;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).&quot;

In XDM 3.1, 6.2.4 Construction from a PSVI:

  attributes
     &quot;Default and fixed attributes provided by XML Schema processing are added to the [attributes]&quot;

Example 1:

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

Result:

  &lt;string escaped=&quot;false&quot; xmlns=&quot;http://www.w3.org/2005/xpath-functions&quot;&gt;foo&lt;/string&gt;

Example 2:

  json-to-xml(&apos;&quot;foo&quot;&apos;, map { &apos;validate&apos; : true() }) 
  
Result 2:

  &lt;string xmlns=&quot;http://www.w3.org/2005/xpath-functions&quot;&gt;foo&lt;/string&gt;


And, the following expression will often return false:

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

I think the WG should make the behavior of the &apos;validate&apos; flag consistent with validation by either removing the default from the schema or by adding the defaults in the definition of json-to-xml.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122990</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-09-01 15:48:32 +0000</bug_when>
    <thetext>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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123049</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-09-02 17:29:58 +0000</bug_when>
    <thetext>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 &quot;true&quot; or &quot;false&quot;, and every element having an attribute named *key* will also have an attribute named *escaped-key* whose value is either &quot;true&quot; or &quot;false&quot;.

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

The changes have been applied.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123050</commentid>
    <comment_count>3</comment_count>
    <who name="Josh Spiegel">josh.spiegel</who>
    <bug_when>2015-09-02 17:32:48 +0000</bug_when>
    <thetext>Sounds good to me.  Thanks.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>