<?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>4634</bug_id>
          
          <creation_ts>2007-06-12 20:10:22 +0000</creation_ts>
          <short_desc>[FO] poorly formed back-references</short_desc>
          <delta_ts>2007-11-16 09:20:05 +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 1.0</component>
          <version>Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</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>
          
          <blocked>4610</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Andrew Eisenberg">andrew.eisenberg</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>15385</commentid>
    <comment_count>0</comment_count>
    <who name="Andrew Eisenberg">andrew.eisenberg</who>
    <bug_when>2007-06-12 20:10:22 +0000</bug_when>
    <thetext>In section 7.6.1, Regular Expression Syntax, we say:

&quot;Back-references are allowed. ... A back-reference matches the string that was matched by the nth capturing subexpression within the regular expression, that is, the parenthesized subexpression whose opening left parenthesis is the nth unescaped left parenthesis within the regular expression. The closing right parenthesis of this subexpression must occur before the back-reference. ...&quot;

In Bug #4610 we considered the following query:

replace(&quot;abcd&quot;, &quot;(a)\2(b)&quot;, &quot;&quot;)

While I interpreted the violation of &quot;must occur&quot; as requiring that an error be raised, Michael Kay interpreted it as causing the back-reference to fail to match a string.


The replace function acknowledges that a pattern can be invalid, saying:

&quot;An error is raised [err:FORX0002] if the value of $pattern is invalid according to the rules described in section 7.6.1 Regular Expression Syntax.&quot;


Let me suggest that this be clarified by changing the existing sentence: 

&quot;The closing right parenthesis of this subexpression must occur before the back-reference.&quot;

to the following:

&quot;The regular expression is invalid if the closing right parenthesis of this subexpression occurs before the back-reference.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15391</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2007-06-12 20:38:03 +0000</bug_when>
    <thetext>For consistency this also means that it should be an error to use \3 if no third subexpression exists. So I would suggest changing

The closing right parenthesis of this subexpression must occur before the back-reference. 

to

&quot;The regular expression is invalid if this subexpression does not exist or if its closing right parenthesis occurs after the back-reference.&quot;
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15652</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2007-06-27 15:03:04 +0000</bug_when>
    <thetext>The WGs accepted the proposal in comment #1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15991</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2007-07-31 20:42:34 +0000</bug_when>
    <thetext>The change has been merged into erratum E4, which affects another sentence in the same paragraph. See bug #4106.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>