<?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>30402</bug_id>
          
          <creation_ts>2019-02-27 11:56:47 +0000</creation_ts>
          <short_desc>[XSLT30] Incorrect cross-reference for xsl:next-match</short_desc>
          <delta_ts>2019-02-28 15:29:10 +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>XSLT 3.0</component>
          <version>Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></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="Michael Kay">mike</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          <cc>abel.online</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>129575</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2019-02-27 11:56:47 +0000</bug_when>
    <thetext>In § section 6.8 there is a Note starting &quot;As explained in 6.4 Conflict Resolution for Template Rules, ...&quot;.

The cross reference is incorrect. The rule it is referring to is in clause 2 of §6.5, Default Priority for Template Rules.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129576</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2019-02-27 12:26:36 +0000</bug_when>
    <thetext>Moreover, and perhaps more seriously, the relevant text in XSLT 2.0 said:

If the pattern contains multiple alternatives separated by | , then the template rule is treated equivalently to a set of template rules, one for each alternative. However, it is not an error if a node matches more than one of the alternatives.

The last sentence has disappeared from the XSLT 3.0 specification. This would appear to mean that if you write

&lt;xsl:template match=&quot;p[@class=&apos;heading&apos;] | p[@style=&apos;bold&apos;]&quot;&gt;

and xsl:mode specifies on-multiple-match=&quot;fail&quot;, then you will get an error if any p element matches both branches of the union. This seems unfortunate.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129577</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2019-02-27 15:49:16 +0000</bug_when>
    <thetext>In §6.4 rule 3(a). after

If the mode M has an xsl:mode declaration, and the attribute value on-multiple-match=&quot;fail&quot; is specified in the mode declaration, a dynamic error is signaled. The error is treated as occurring in the xsl:apply-templates instruction, and can be recovered by wrapping that instruction in an xsl:try instruction.

I propose adding: &quot;However, no error is signaled if the matching template rules all form part of a set of template rules generated from a single xsl:template declaration whose match pattern is a union pattern (as described in §6.5 rule 2)&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129582</commentid>
    <comment_count>3</comment_count>
    <who name="Abel Braaksma">abel.online</who>
    <bug_when>2019-02-28 15:06:28 +0000</bug_when>
    <thetext>I agree to your suggestion in comment#2.

Or as an alternative, we can remove the rule that a union pattern with &apos;|&apos; needs to be split into multiple template rules. I don&apos;t think the syntax is ambiguous if we remove that rule, and in fact, it should only be an implementation detail.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129583</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2019-02-28 15:08:38 +0000</bug_when>
    <thetext>Removing the rule gives a backwards compatibility problem because match=&quot;doc | node()&quot; is supposed to behave like two rules with different priorities.

It was probably a bad idea, but I think we&apos;re stuck with it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129584</commentid>
    <comment_count>5</comment_count>
    <who name="Abel Braaksma">abel.online</who>
    <bug_when>2019-02-28 15:13:14 +0000</bug_when>
    <thetext>Looks like my alternative proposal would change current behavior after all, so that&apos;s a no-go. In fact, we have a specific Note on xsl:next-match saying:

&gt; a template rule with no priority attribute, whose match pattern contains 
&gt; multiple alternatives separated by |, is treated equivalently to a set of 
&gt; template rules, one for each alternative. This means that where the same item 
&gt; matches more than one alternative, it is possible for an xsl:next-match 
&gt; instruction to cause the current template rule to be invoked recursively. This 
&gt; situation does not occur when the template rule has an explicit priority. 

This implies that union&apos;ed template rules with different default priority would be called again when xsl:next-match is invoked. I never realized this behavior was even possible, I wonder if we have a test covering this specifically.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129585</commentid>
    <comment_count>6</comment_count>
    <who name="Abel Braaksma">abel.online</who>
    <bug_when>2019-02-28 15:13:52 +0000</bug_when>
    <thetext>(In reply to Michael Kay from comment #4)
&gt; Removing the rule gives a backwards compatibility problem because match=&quot;doc
&gt; | node()&quot; is supposed to behave like two rules with different priorities.
&gt; 
&gt; It was probably a bad idea, but I think we&apos;re stuck with it.

You came to the same conclusion at the same time ;)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129586</commentid>
    <comment_count>7</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2019-02-28 15:29:10 +0000</bug_when>
    <thetext>Yes, there are next-match tests for this (that&apos;s what got me here, they weren&apos;t working in one particular Saxon configuration).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>