<?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>4601</bug_id>
          
          <creation_ts>2007-06-07 08:08:58 +0000</creation_ts>
          <short_desc>[FS] specification of fs:convert-operand() inconsistent</short_desc>
          <delta_ts>2008-09-06 20:58:38 +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>Formal Semantics 1.0</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</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>minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jens Teubner">jens.teubner</reporter>
          <assigned_to name="Michael Dyck">jmdyck</assigned_to>
          <cc>jens.teubner</cc>
          
          <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>15310</commentid>
    <comment_count>0</comment_count>
    <who name="Jens Teubner">jens.teubner</who>
    <bug_when>2007-06-07 08:08:58 +0000</bug_when>
    <thetext>The specification of fs:convert-operand() is inconsistent in the XQuery Formal Semantics Recommendation.

Section 4.5.2, Paragraph &quot;Normalization&quot; says:  `The internal function fs:convert-operand is applied to each pair of atomic values. If the first argument to this function has type xs:untypedAtomic, then the first argument is cast to type of the second argument.&apos;

Section 7.1.1, &quot;The fs:convert-operand function&quot;, in contrast, says:  `If $actual is an instance of type xs:untypedAtomic, then [...] if $expected is of numeric type, returns $actual cast to xs:double.&apos;

Note that (for e of type xs:untypedAtomic)

  e = 1

would be interpreted as an integer comparison according to the first definition of fs:convert-operand(), but as a double comparison according to the second.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15324</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2007-06-08 01:56:07 +0000</bug_when>
    <thetext>I agree that there is an inconsistency. I believe the definition in 7.1.1 is correct (i.e., it agrees with XQuery section 3.5.2), so the text in 4.5.2 needs to be fixed. I propose to do so by being less specific in 4.5.2 about the workings of fs:convert-operand, since the reader can easily refer to 7.1.1 for the exact definition.

Specifically, in 4.5.2 / Normalization, change:

    If the first argument to this function has type xs:untypedAtomic,
    then the first argument is cast to type of the second argument.
    If the second argument has type xs:untypedAtomic,
    the first argument is cast to a string.

to:

    If either value is of type xs:untypedAtomic, this function casts it
    to a type determined by the other value.

I believe this would be an editorial change, so I&apos;ve downgraded this bug&apos;s Severity to &quot;minor&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>21719</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2008-09-02 01:51:49 +0000</bug_when>
    <thetext>This issue has been entered as FS erratum E055, and the fix has been
committed to the source files for the next edition of the FS document.
Consequently, I&apos;m marking this issue resolved-FIXED.

If you agree with this resolution, please CLOSE the issue.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>21723</commentid>
    <comment_count>3</comment_count>
    <who name="Jens Teubner">jens.teubner</who>
    <bug_when>2008-09-02 12:24:07 +0000</bug_when>
    <thetext>(Sorry for my late response. Somehow I missed your comment a year ago.)

I&apos;m not sure whether the proposed change actually makes things better. Note that that very specific sentence is about fs:convert-operand(), not the general comparison.

More specifically, fs:convert-operand() will only cast its first argument (if necessary, and as determined by the second argument). Your sentence suggests that &quot;either value&quot; is cast to something, which is not what fs:convert-operand() does.

A possible fix to your sentence could be

  If either value is of type xs:untypedAtomic, this function casts
  the first argument to a type determined by the second argument.

I could also imagine something less specific, like

  This function ensures compatible types if either input to the general
  comparison was an instance of xs:untypedAtomic or a node.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>21745</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2008-09-02 19:43:10 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt;
&gt; I&apos;m not sure whether the proposed change actually makes things better.
&gt; Note that that very specific sentence is about fs:convert-operand(), not
&gt; the general comparison.
&gt; 
&gt; More specifically, fs:convert-operand() will only cast its first argument
&gt; (if necessary, and as determined by the second argument). Your sentence
&gt; suggests that &quot;either value&quot; is cast to something, which is not what
&gt; fs:convert-operand() does.

Actually, I was trying to make the text *not* be about the inner workings
of fs:convert-operand, just the net result of the two calls to it. That is,
the interpretation I was hoping for was something like:
    The internal function fs:convert-operand is called twice for each pair
    of atomic values, and if either of the two values is of type
    xs:untypedAtomic, one of the calls will cast it to a type determined
    by the other value.

That is, I want the idea of &quot;two values&quot; or &quot;a pair of values&quot; to mean
    the values bound to $v1 and $v2 within any given iteration
    of the inner &apos;some&apos; expr
and not
    the arguments to any given invocation of fs:convert-operand

But, I agree, I haven&apos;t completely achieved that yet. So I think I need to
slightly widen the scope of the change. How about this for the para:

    The normalization rule for a general comparison expression first
    atomizes each argument by applying fn:data, &lt;NEW&gt; resulting in two
    sequences of atomic values. Two nested &lt;code&gt;some&lt;/code&gt; expressions
    then examine (potentially) every pair of values (one value from each
    sequence). For each pair, the internal function fs:convert-operand is
    called twice; if either of the two values is of type xs:untypedAtomic,
    one of the calls will cast it to a type determined by the other value.
    &lt;/NEW&gt; The overloaded internal function corresponding to the general
    comparison operator is then applied to the two converted values.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>21808</commentid>
    <comment_count>5</comment_count>
    <who name="Jens Teubner">jens.teubner</who>
    <bug_when>2008-09-06 07:42:42 +0000</bug_when>
    <thetext>Michael,

looks much better now, thanks.  I agree with your proposal, feel free to close the bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>21809</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2008-09-06 20:58:38 +0000</bug_when>
    <thetext>Ah good. I have updated the FS Errata document and the source files for 
the next edition of the FS document, and will now close the bug.
</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>