<?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>18861</bug_id>
          
          <creation_ts>2012-09-12 20:40:57 +0000</creation_ts>
          <short_desc>[XSLT 3.0] predicates in patterns</short_desc>
          <delta_ts>2013-08-11 21:39:55 +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>All</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="Michael Kay">mike</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          <cc>abel.braaksma</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>73723</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-09-12 20:40:57 +0000</bug_when>
    <thetext>The current XSLT 3.0 pattern syntax appears to allow

match=&quot;$x&quot;

  and

match=&quot;$x/abc&quot;

  and

match=&quot;$x[xyz]&quot;

  but not

match=&quot;$x[xyz]/abc&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73724</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-09-12 21:04:45 +0000</bug_when>
    <thetext>Also, the pattern syntax appears to allow

/[x]

which is not a legal XPath expression. The semantics rely on all patterns (after expansion of &quot;~&quot;) being legal XPath expressions. In XPath expressions, this has to be written as (/)[x].</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73997</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-09-17 15:25:25 +0000</bug_when>
    <thetext>The statements in comments 0 and 1 don&apos;t seem quite correct. It seems that the grammar allows a predicate after a RootedPattern (such as &quot;/&quot; or &quot;$x&quot;) only if the rooted pattern is in parentheses. So $x[xyz] is not allowed, but ($x)[xyz] is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73998</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-09-17 15:39:38 +0000</bug_when>
    <thetext>I believe the following revised grammar fixes the problems:

[1] Pattern       ::=       PatternTerm ( (&apos;|&apos; | &apos;union&apos;) PatternTerm )*

[2] PatternTerm       ::=       PathPattern ( (&apos;intersect&apos; | &apos;except&apos;) PathPattern )*

[3]      PathPattern       ::=      
RelativePathPattern
| &apos;/&apos; RelativePathPattern?
| &apos;//&apos; RelativePathPattern
| StartPattern ((&apos;/&apos;|&apos;//&apos;) RelativePathPattern)?


[4]      RelativePathPattern       ::=       StepPattern ((&quot;/&quot; | &quot;//&quot;) StepPattern)*

[5] StepPattern ::= PatternAxis? NodeTest{XP3} PredicateList{XP30}

[6] PatternAxis ::= (&quot;child&quot; &quot;::&quot;)
| (&quot;descendant&quot; &quot;::&quot;)
| (&quot;attribute&quot; &quot;::&quot;)
| (&quot;self&quot; &quot;::&quot;)
| (&quot;descendant-or-self&quot; &quot;::&quot;)
| (&quot;following-sibling&quot; &quot;::&quot;)
| (&quot;following&quot; &quot;::&quot;)
| (&quot;namespace&quot; &quot;::&quot;)
| &quot;@&quot;

[7] StartPattern ::= PrimaryPattern PredicateList{XP30}

[8] PrimaryPattern ::= VarRef{XP30} | ParenthesizedPattern | FunctionCall | TypePattern

[9] ParenthesizedPattern ::= &quot;(&quot; Pattern &quot;)&quot;

[10] FunctionCall ::= DocCall | IdCall | ElementWithIdCall | KeyCall


[11]       DocCall       ::=       &apos;doc&apos; &apos;(&apos; ArgValue &apos;)&apos;
[12]       IdCall       ::=       &apos;id&apos; &apos;(&apos; ArgValue (&apos;,&apos; ArgValue )? &apos;)&apos;
[13]       ElementWithIdCall       ::=       &apos;element-with-id&apos; &apos;(&apos; ArgValue (&apos;,&apos; ArgValue )? &apos;)&apos;
[14]       KeyCall       ::=       &apos;key&apos; &apos;(&apos; ArgValue &apos;,&apos; ArgValue (&apos;,&apos; ArgValue )? &apos;)&apos;
[15]       ArgValue       ::=       Literal{XP30} | VarRef{XP30}

[16]       TypePattern       ::=       &apos;~&apos; ItemType{XP30}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82960</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-02-12 09:19:58 +0000</bug_when>
    <thetext>We worked on the grammar today and sketched out a revised grammar by hacking away unwanted parts of the XPath grammar. This is in Feb2013/0019.html in the XSL WG archives. This needs further review offline before we are comfortable with it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85117</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-03-28 18:39:17 +0000</bug_when>
    <thetext>The current status is that the grammar has been written up in the spec and appears satisfactory. Michael Dyck has pointed out that there&apos;s a technical ambiguity in the way it&apos;s constructed, because xx() can be both a function call and a kind-test; we probably have to disambiguate that by listing the allowed function names in the grammar rather than leaving it to an extra-grammatical rule.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91277</commentid>
    <comment_count>6</comment_count>
      <attachid>1381</attachid>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2013-07-25 15:31:25 +0000</bug_when>
    <thetext>Created attachment 1381
Suggested improvements for the pattern syntax

Here&apos;s a suggestion based on the remarks above to to keep the limitation on root functions in the pattern syntax. I&apos;ve also renamed FunctionCallP, because it implies that we have replaced FunctionCall with FunctionCallP, which we haven&apos;t, in other places, FunctionCall is still allowed. While none of this is a syntactical ambiguity, perhaps you might consider this alternative syntax as an improvement.

See attachment (the comment section makes the syntax almost unreadable).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91343</commentid>
    <comment_count>7</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2013-07-27 12:36:02 +0000</bug_when>
    <thetext>Around the same time that I added this suggestion, the internal WD was updated and included part of the suggestions that I added here (apparently, I was on the same page as the editor ;) ).

From the discussion that followed, I&apos;ve come to understand that it is not possible to write the EBNF in such a way that it unambiguously allows namespaces or EQNames for the rooted functions.

What remains is

- should we rename FunctionCallP to something like RootedFunctionCall?

- should fn:id() etc be allowed or disallowed, whether in the EBNF or not? The EBNF of XSLT 2.0 disallowed it, but processors seem to silently allow using namespaces. Explicitly disallowing it would mean a backward compatibility issue with current practice, but not with the standard, allowing it would mean a semantic rule on top of the pattern syntax. Doing nothing would keep the status quo.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91459</commentid>
    <comment_count>8</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-07-31 15:43:14 +0000</bug_when>
    <thetext>The original issue is now resolved. There are other issues that have emerged with pattern syntax, but these will be addressed elsewhere.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>1381</attachid>
            <date>2013-07-25 15:31:25 +0000</date>
            <delta_ts>2013-07-25 15:31:25 +0000</delta_ts>
            <desc>Suggested improvements for the pattern syntax</desc>
            <filename>patternsXSLT.txt</filename>
            <type>text/plain</type>
            <size>1643</size>
            <attacher name="Abel Braaksma">abel.braaksma</attacher>
            
              <data encoding="base64">WzFdICAgIAlQYXR0ZXJuMzAgCSAgIAkJIAkgOjo9ICBGdW5jdGlvbmFsUGF0dGVybiB8IFVuaW9u
RXhwclAN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