<?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>29407</bug_id>
          
          <creation_ts>2016-01-30 04:34:14 +0000</creation_ts>
          <short_desc>[QT3] analyze-string-008, analyzeString-017a, nested grouping</short_desc>
          <delta_ts>2016-01-31 16:25:07 +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>XQuery 3 &amp; XPath 3 Test Suite</component>
          <version>Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</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="O&apos;Neil Delpratt">oneil</assigned_to>
          <cc>mike</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>124755</commentid>
    <comment_count>0</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-01-30 04:34:14 +0000</bug_when>
    <thetext>I have trouble understanding why the expected test result is correct here. The test is: analyze-string(&quot;banana&quot;, &quot;(a(n?))&quot;)

This can be interpreted as:
b  -- non-match
an -- match, group 1: an, group 2: n
an -- match, group 1: an, group 2: n
a  -- match, group 1: a, group 2: &lt;empty&gt; or absent

A valid outcome, I think, is the following:

&lt;fn:analyze-string-result xmlns:fn=&quot;http://www.w3.org/2005/xpath-functions&quot;&gt;
    &lt;fn:non-match&gt;b&lt;/fn:non-match&gt;
    &lt;fn:match&gt;
        &lt;fn:group nr=&quot;1&quot;&gt;an&lt;fn:group nr=&quot;2&quot;&gt;n&lt;/fn:group&gt;&lt;/fn:group&gt;
    &lt;/fn:match&gt;
    &lt;fn:match&gt;
        &lt;fn:group nr=&quot;1&quot;&gt;an&lt;fn:group nr=&quot;2&quot;&gt;n&lt;/fn:group&gt;&lt;/fn:group&gt;
    &lt;/fn:match&gt;
    &lt;fn:match&gt;
        &lt;fn:group nr=&quot;1&quot;&gt;a&lt;fn:group nr=&quot;2&quot; /&gt;&lt;/fn:group&gt;
    &lt;/fn:match&gt;
&lt;/fn:analyze-string-result&gt;

This is not the same as the current expected outcome, which assumes that &quot;n&quot; is not part of group 1.

I&apos;m unsure whether the spec mandates that an empty group *must* be specified, or *may* be absent. Though I see no harm in doing so, I can&apos;t readily find this in the spec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124756</commentid>
    <comment_count>1</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-01-30 04:40:56 +0000</bug_when>
    <thetext>Same is true for analyzeString-017a: analyze-string(&quot;banana&quot;, &quot;(b(x?))&quot;)

Currently expected is:

    &lt;fn:match&gt;
        &lt;fn:group nr=&quot;1&quot;&gt;b&lt;/fn:group&gt;
        &lt;fn:group nr=&quot;2&quot; /&gt;
    &lt;/fn:match&gt;
    &lt;fn:non-match&gt;anana&lt;/fn:non-match&gt;

But I believe the correct result ought to be:

    &lt;fn:match&gt;
        &lt;fn:group nr=&quot;1&quot;&gt;b&lt;fn:group nr=&quot;2&quot; /&gt;&lt;/fn:group&gt;
    &lt;/fn:match&gt;
    &lt;fn:non-match&gt;anana&lt;/fn:non-match&gt;

I.e.: the groups are nested, so should be nested in the result. Otherwise there would be no distinction with an regex such as &quot;(b)(x?)&quot; (which I believe would result in the first result above).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124767</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-01-31 10:13:41 +0000</bug_when>
    <thetext>The string value of the XML that results from analyze-string is always the original input string; the function essentially takes the original string and adds markup to show the way in which the regex was (or wasn&apos;t) matched. I think the spec makes this clear. Your proposed result doesn&apos;t have this property.

You say that &quot;the current result assumes that &quot;n&quot; is not part of group 1&quot;. That&apos;s not the case. The current result is

&lt;fn:match&gt;&lt;fn:group nr=&quot;1&quot;&gt;a&lt;fn:group nr=&quot;2&quot;&gt;n&lt;/fn:group&gt;&lt;/fn:group&gt;&lt;/fn:match&gt;

which shows that the &quot;n&quot; is part of both groups 1 and 2 - the groups are nested.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124770</commentid>
    <comment_count>3</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-01-31 16:25:07 +0000</bug_when>
    <thetext>Oh my, looking again at these tests I think I have either been looking at the wrong version locally, or did some copy/paste errors.

With a fresh look and your comment, I wholeheartedly agree. It also makes sense that the nesting takes care of the matched strings belonging to more than one group.

I will close with no action.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>