<?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>28179</bug_id>
          
          <creation_ts>2015-03-09 15:40:00 +0000</creation_ts>
          <short_desc>[F+O 3.1] handling of numbers in json-to-xml() is underspecified</short_desc>
          <delta_ts>2016-12-16 19:55:19 +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="Michael Kay">mike</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>118454</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-03-09 15:40:00 +0000</bug_when>
    <thetext>The spec for json-to-xml() does not make it clear whether the JSON input

23e0

should generate

&lt;number&gt;23&lt;/number&gt;

or

&lt;number&gt;23e0&lt;/number&gt;

or something else.

Two options that one could use are:

(a) retain the JSON lexical form

(b) convert the JSON lexical form to xs:double using string-to-double conversion, and then convert the xs:double to string

The advantage of (a) is that there is never any loss of precision (there&apos;s nothing in JSON that limits the number of digits in a number). But the spec hints that (b) was intended, in that it mentions the rules for string-to-double conversion.

Note however that in the reverse mapping, xml-to-json(), retaining the lexical form is not an option, because the lexical space of xs:double is a superset of the JSON number format (for example, JSON does not allow 015, or .12).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118525</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-03-11 12:24:44 +0000</bug_when>
    <thetext>This was accepted by the WG on 10 Mar 2015, and has been applied to the spec.

Specifically: json-to-xml() retains the lexical form of the number in the string value of the generated node (except when the XDM implementation reconstructs the string value from the typed value). xml-to-json()starts with the typed value of the node, or converts the string value to xs:double, and then outputs the result of casting this xs:double to xs:string.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>