<?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>29310</bug_id>
          
          <creation_ts>2015-11-28 08:17:13 +0000</creation_ts>
          <short_desc>[FO31] Invalid and ambiguous XPath expression in normative part of section 5.4.3 fn:substring</short_desc>
          <delta_ts>2016-03-22 09:56:23 +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="Abel Braaksma">abel.braaksma</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>124303</commentid>
    <comment_count>0</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2015-11-28 08:17:13 +0000</bug_when>
    <thetext>Under 5.4.3 fn:substring we write:

&lt;quote&gt;
More specifically, the three argument version of the function returns the characters in $sourceString whose position $p satisfies:

fn:round($start) &lt;= $p &lt; fn:round($start) + fn:round($length)
&lt;/quote&gt;

But this is an illegal XPath expression. If it isn&apos;t meant to be an XPath expression, I thing the text should say so, but even then, the associativity is ambiguous. One might read this as:

(fn:round($start) &lt;= $p) &lt; (fn:round($start) + fn:round($length))

or as:

fn:round($start) &lt;= ($p &lt; fn:round($start)) + fn:round($length)

But neither expressions make much sense in light of the text. Perhaps the following was meant (in which case parentheses are no longer necessary)?

fn:round($start) &lt;= $p and $p &lt; fn:round($start) + fn:round($length)

Alternatively, we might consider using the same approach as for fn:subsequence, which has a clearer way of defining in a proper XPath what the function is supposed to return.

-------

Note that there are other places where ambiguous associativity is used, for instance &apos;1&lt;=N&lt;=S&quot; in fn:replace and &quot;-π/2 &lt;= θ &lt;= +π/2&quot; in math:asin, but in these case the textual context makes it clear that these are not meant to be read as XPath expressions, moreover, the mathematical meaning of &quot;between&quot; is easily deducted from the text.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124304</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-11-28 10:10:38 +0000</bug_when>
    <thetext>These expressions (A &lt; B &lt; C) were of course intended to be read as mathematical formulae rather than XPath expressions, but I take your point.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124391</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-12-08 16:17:21 +0000</bug_when>
    <thetext>Agreed that we will fix this by changing A &lt; B &lt;= C to (A lt B and B le C), i.e. to a valid XPath expression. Note that fn:subsequence is already written this way.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124440</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-12-16 12:26:08 +0000</bug_when>
    <thetext>The change has been applied.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>