<?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>30229</bug_id>
          
          <creation_ts>2018-03-17 11:27:16 +0000</creation_ts>
          <short_desc>[XSLT30] Patterns like a/id(&apos;x&apos;) are allowed by the syntax</short_desc>
          <delta_ts>2019-02-20 00:23:37 +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>Windows NT</op_sys>
          <bug_status>RESOLVED</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.online</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>129087</commentid>
    <comment_count>0</comment_count>
    <who name="Abel Braaksma">abel.online</who>
    <bug_when>2018-03-17 11:27:16 +0000</bug_when>
    <thetext>The way I understood pattern expressions is that there are predicate patterns, rooted patterns and path patterns. 

* Predicate patterns start with &quot;.&quot;
* Rooted patterns start with a variable like $x, or a function like doc() or id()
* Path patterns start with &quot;/&quot;, &quot;//&quot; , or a nodetest (nametest or kindtest)

The relevant part for this discussion is:

RelativePathExprP  ::= StepExprP ((&quot;/&quot; | &quot;//&quot;) StepExprP)*
StepExprP          ::= PostfixExprP | AxisStepP
PostfixExprP       ::= ParenthesizedExprP PredicateListXP30
ParenthesizedExprP ::= &quot;(&quot; UnionExprP &quot;)&quot;

This means that a RelativePathExprP can also be:

RelativePathExprP  ::= ParenthesizedExprP ((&quot;/&quot; | &quot;//&quot;) ParenthesizedExprP)*

Since ParenthesizedExprP is defined as UnionExprP, it can be any pattern, except for a predicate pattern. That is, it can also be a rooted pattern.

That means (if I understand the grammar correctly) that the following are legal patterns:

* a/(id(&apos;test&apos;))
* b/(c | d)/(e | f)
* c/((root() | id(&apos;test&apos;))
* id(&apos;test&apos;)/(root() | d/e)
* e/($foo | $bar)

I am not sure this is intentional and I am not sure what the result of such expressions should be. I looked through the tests but think we do not have tests with these patterns.

It probably doesn&apos;t make much sense using those expressions, but there must have been a reason that previously functions were not allowed to be used anywhere else than at the root of the pattern (XSLT 2.0). This begs the question, how should these be treated?

My gut tells me that, assuming this was intentional, that those expressions should work like in XPath, that is, the context for these functions is the context they would have in XPath. 

I can&apos;t think of anything logical for an expression like e/($foo) though.

If this was not intentional, we should fix it, if it is intentional, we should create some tests, but perhaps also clarify this in an erratum entry.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129088</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2018-03-17 13:22:57 +0000</bug_when>
    <thetext>It&apos;s certainly rather strange that the grammar allows

doc(&apos;a.xml&apos;)/(id(&apos;a123&apos;))

but not

doc(&apos;a.xml&apos;)/id(&apos;a123&apos;)

But although it&apos;s strange, I think the semantics are well defined.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129526</commentid>
    <comment_count>2</comment_count>
    <who name="Abel Braaksma">abel.online</who>
    <bug_when>2019-02-19 21:18:37 +0000</bug_when>
    <thetext>A draft erratum E18 was published on 13 Feb 2019, HTML version: https://htmlpreview.github.io/?https://github.com/w3c/qtspecs/blob/master/errata/xslt-30/html/xslt-30-errata.html#E18

I think the proposed text (a Note) covers this case perfectly.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>