<?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>28836</bug_id>
          
          <creation_ts>2015-06-22 12:33:49 +0000</creation_ts>
          <short_desc>fn:parse-json, fallback function</short_desc>
          <delta_ts>2016-12-16 19:55:16 +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>Windows NT</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="Christian Gruen">christian.gruen</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>121424</commentid>
    <comment_count>0</comment_count>
    <who name="Christian Gruen">christian.gruen</who>
    <bug_when>2015-06-22 12:33:49 +0000</bug_when>
    <thetext>In the current spec, the fallback function of fn:parse-json is defined to have the function signature &quot;function(xs:string) as xs:string&quot;. In the given example, however...

  parse-json(&apos;{&quot;x&quot;:&quot;\\&quot;, &quot;y&quot;:&quot;\u0000&quot;}&apos;, map{&apos;fallback&apos;:function($s){&apos;[&apos;||$s||&apos;]&apos;}})

...the function is only of type `function(*)` (because the type are not explicitly stated), and it can only be determined at runtime if the passed on and returned item is of type xs:string (or a value that can be promoted to xs:string).

Maybe the correct solution (albeit not so nice to read) would be to specify &quot;function(*)&quot; as type, and require the function to only accept and return strings?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>121436</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-06-22 18:48:04 +0000</bug_when>
    <thetext>Doesn&apos;t function coercion handle this case?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>121437</commentid>
    <comment_count>2</comment_count>
    <who name="Christian Gruen">christian.gruen</who>
    <bug_when>2015-06-23 09:21:50 +0000</bug_when>
    <thetext>I see. Yes, sounds absolutely reasonable.

In that case, it could make sense not to return FOJS0005, but the actual error caused by function coercion. Otherwise, it could be difficult for an implementation to decide if an error was caused by the function signature or by the processed data:

Currently, I would expect this expression to yield FOJS0005:

  json-to-xml(&apos;&quot;\uFFFF&quot;&apos;, map { &apos;fallback&apos;:
    function($s) as xs:integer { 1 }
  })

And I would expect this expression to yield XPTY0004:

  json-to-xml(&apos;&quot;\uFFFF&quot;&apos;, map { &apos;fallback&apos;:
    function($s) as xs:string { 1 }
  })

Maybe it would be safer to raise XPTY0004 in all cases?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122097</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-07-15 17:49:23 +0000</bug_when>
    <thetext>We are thinking that perhaps rule 6 of 1.5 (option parameter conventions) should change from

A dynamic error occurs if the supplied value cannot be converted to the required type, or if the value after conversion is not one of the permitted values for the option in question. 

to

(a) A type error XPTY0004 occurs if the supplied value cannot be converted to the required type

(b) A dynamic error (error code defined specifically for each function) if the value after conversion is not one of the permitted values for the option in question.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122098</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-07-15 17:51:14 +0000</bug_when>
    <thetext>The proposal was accepted.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122121</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-07-15 23:52:50 +0000</bug_when>
    <thetext>The change has been applied.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122123</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-07-16 01:27:03 +0000</bug_when>
    <thetext>I have applied the change.

I have also sought WG approval for a further change: renaming unescape=false/true to escape=true/false. The reason for this is to reflect the changed semantics introduced by the agreed resolution to this bug, and to avoid the difficulty of understanding the double negative in unescape=false.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>