<?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>24308</bug_id>
          
          <creation_ts>2014-01-16 14:09:26 +0000</creation_ts>
          <short_desc>Overriding templates can also be matching templates, but this case has no rules in the spec</short_desc>
          <delta_ts>2014-05-15 14:00:31 +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>Last Call drafts</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>
          <cc>cmsmcq</cc>
    
    <cc>vitaliy.yudenkov</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>98573</commentid>
    <comment_count>0</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2014-01-16 14:09:26 +0000</bug_when>
    <thetext>The only templates that can be overridden are named templates. But if named templates also contain a mode and a match attribute, the behavior is unclear (in fact, I could not find any mention of this case).

Example:

&lt;xsl:override&gt;
    &lt;xsl:template match=&quot;P&quot; mode=&quot;M&quot; name=&quot;N&quot; /&gt;
&lt;xsl:override&gt;

This example overrides named template N and thus affects xsl:call-template. However, it (probably) also affects xsl:apply-template. The spec explains[1] that templates bound to a mode can be overridden by template rules in the stylesheet, but it is unclear what happens when the new template rule appears in the xsl:override, let alone what happens when the same node matches the template rule in the xsl:override and in the stylesheet (main package).

While one could argue that the xsl:override takes precedence or that declaration order is taken into consideration, the following example is currently legal but conflicts with the statement &quot;When a template rule specifies mode=&quot;#all&quot; this is interpreted as meaning all modes declared implicitly or explicitly within the declaring package of the xsl:template element.&quot;:

&lt;xsl:override&gt;
   &lt;xsl:template match=&quot;P&quot; mode=&quot;#all&quot; name=&quot;N&quot; /&gt;
&lt;/xsl:override&gt;

Perhaps the easiest solution is to disallow mode and match attributes when xsl:template appears within xsl:override. After all, simply specifying template rules on the stylesheet level is already enough to define overrides.


[1] http://www.w3.org/TR/xslt-30/#modes-and-packages</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98574</commentid>
    <comment_count>1</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2014-01-16 14:12:50 +0000</bug_when>
    <thetext>Related is also the case of:

&lt;xsl:override&gt;
   &lt;xsl:template name=&quot;P&quot; match=&quot;N&quot; mode=&quot;#unnamed&quot; /&gt;
&lt;/xsl:override&gt;

or the equivalent without the mode attribute. The conflict here is that you are overriding a template rule, but the unnamed mode is local to a package, hence you are doing something illegal here. Imo, this too is a reason not to allow mode and match attributes here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98625</commentid>
    <comment_count>2</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2014-01-16 15:36:30 +0000</bug_when>
    <thetext>Apologies, I missed the line &quot;These may appear only as children of the xsl:override element within the xsl:use-package element.&quot; under 3.6.3.

However, I leave the bug open, because it leaves the questions on #all and #unnamed (and to some extend, #default). More importantly, since only named templates are allowed, this seems to be too much a restriction. 

In addition, I think we should allow the use of a mode from a used package on the stylesheet level (I don&apos;t see why not). When you add a matching template, you are extending or overriding it. Forcing it to be in xsl:override seems counter-intuitive.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98947</commentid>
    <comment_count>3</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2014-01-23 16:24:42 +0000</bug_when>
    <thetext>Please ignore the last paragraph in the previous comment.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99402</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2014-01-29 11:07:06 +0000</bug_when>
    <thetext>Agreed, this is a bit of a mess.

My first reading was that xsl:override was used only for overriding named components (the section heading of 3.6.2.5 is &quot;Overriding named components&quot;). 

But in 3.6.3 we say (table entry &quot;public&quot;) &quot;A using package may use xsl:apply-templates to invoke templates in this mode; it may also declare additional template rules in this mode, which are selected in preference to template rules in the used package. These may appear only as children of the xsl:override element within the xsl:use-package element.&quot;

It&apos;s explicit, I think, that if package P uses package Q, then P can&apos;t include template rules that override rules in Q unless (a) the mode is public (which implies it is named) and (b) the overriding rules are children of xsl:override.

I don&apos;t think we should allow mode=&quot;#all&quot; or mode=&quot;#unnamed&quot; within xsl:override; a template rule appearing here must be in a specific public mode declared in the package-being-overridden.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100141</commentid>
    <comment_count>5</comment_count>
    <who name="C. M. Sperberg-McQueen">cmsmcq</who>
    <bug_when>2014-02-10 14:25:59 +0000</bug_when>
    <thetext>The WG discussed this during the ftf meeting in Prague.  The behavior described in comment 4 seems to the WG to be consistent with treating a template with both @name and @match as two templates, which can be overridden together or separately.  The spec should say this.

The mention of &apos;hidden&apos; as a possible value of the visibility attribute on xsl:expose is incorrect:  it&apos;s not allowed on xsl:expose.

The text of section 3.6.3 doesn&apos;t say what happens with xsl:apply-imports and xsl:next-match when module boundaries are crossed.  

We should ban mode=&quot;#all&quot; and mode=&quot;#unnamed&quot; inside xsl:override (the latter is already effectively banned, since the unnamed mode is private).

The sentence about mode=&quot;#all&quot; is true (modulo the fact that #all will now be illegal inside override), but is subject to misconstruction owing to its location; we probably need to explain why we are saying this here, or move it to another location.

The note at the end of 3.6.3 should specify select=&quot;.&quot; on the apply-templates element.

We considered a proposal to simplify the situation by saying that within templates within xsl:override, any call to xsl:apply-imports works with an empty import tree. (The initial import tree is not visible across package boundaries.) 

ACTION:  editor to come back with a proposal on this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100816</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2014-02-18 20:02:36 +0000</bug_when>
    <thetext>PROPOSAL

1. In the section heading of 3.6.2.5, change &quot;named components&quot; to &quot;components&quot;.

2. After the Note in this section, add: &quot;The rules in the remainder of this section apply to components having a &lt;code&gt;name&lt;/code&gt; attribute (that is, named components). The only element with no &lt;code&gt;name&lt;/code&gt; attribute that can appear as a child of &lt;elcode&gt;xsl:override&lt;/code&gt; is an &lt;elcode&gt;xsl:template&lt;/code&gt; declaration having a &lt;code&gt;match&lt;/code&gt; attribute (that is, a template rule). The rules for overriding of template rules appear in section 3.6.3. If an &lt;elcode&gt;xsl:template&lt;/elcode&gt; element has both a &lt;code&gt;name&lt;/code&gt; and a &lt;code&gt;match&lt;/code&gt; attribute, then it defines both a named component and a template rule, and both sections apply.&quot;

3. In 6.6.2, after the description of ERR XTSE0550, add a statement that #all and #unnamed must not be used on an xsl:template that is a child of xsl:override.

4. Move the sentence &quot;When a template rule specifies mode=&quot;#all&quot; this is interpreted as meaning all modes declared implicitly or explicitly within the declaring package of the xsl:template element.&quot; from 3.6.3 to 6.6.2.

5. In 3.6.3, in the list of allowed values of the visibility attribute, delete &quot;hidden&quot;.

6. In 3.6.3, after the sentence &quot;When a template rule specifies mode=&quot;#all&quot; this is interpreted as meaning all modes declared implicitly or explicitly within the declaring package of the xsl:template element.&quot;, add: &quot;A template rule that is a child of xsl:override must not specify mode=&quot;#all&quot;.

7. In 6.9, add:

When xsl:apply-imports is used in a template rule that appears within an xsl:override element, the instruction considers as candidates all template rules declared in the used package.

When xsl:next-match is used in a template rules that appears within an xsl:override element, the instruction considers as candidates first, all preceding-sibling template rules, then all template rules declared in the used package.

8. In the Note at the end of 3.6.3, change &lt;xsl:apply-templates/&gt; to &lt;xsl:apply-templates selet=&quot;.&quot;/&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101497</commentid>
    <comment_count>7</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2014-02-27 17:00:00 +0000</bug_when>
    <thetext>When you intend to copy and paste these into the spec, be aware that the last code snippet contains a typo: selet =&gt; select.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101974</commentid>
    <comment_count>8</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2014-03-06 10:24:49 +0000</bug_when>
    <thetext>Proposal accepted 2014-02-27 with (minuted) changes.

The draft spec has been updated accordingly.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>