This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 30229 - [XSLT30] Patterns like a/id('x') are allowed by the syntax
Summary: [XSLT30] Patterns like a/id('x') are allowed by the syntax
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 (show other bugs)
Version: Recommendation
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-17 11:27 UTC by Abel Braaksma
Modified: 2019-02-20 00:23 UTC (History)
0 users

See Also:


Attachments

Description Abel Braaksma 2018-03-17 11:27:16 UTC
The way I understood pattern expressions is that there are predicate patterns, rooted patterns and path patterns. 

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

The relevant part for this discussion is:

RelativePathExprP  ::= StepExprP (("/" | "//") StepExprP)*
StepExprP          ::= PostfixExprP | AxisStepP
PostfixExprP       ::= ParenthesizedExprP PredicateListXP30
ParenthesizedExprP ::= "(" UnionExprP ")"

This means that a RelativePathExprP can also be:

RelativePathExprP  ::= ParenthesizedExprP (("/" | "//") 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('test'))
* b/(c | d)/(e | f)
* c/((root() | id('test'))
* id('test')/(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'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'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.
Comment 1 Michael Kay 2018-03-17 13:22:57 UTC
It's certainly rather strange that the grammar allows

doc('a.xml')/(id('a123'))

but not

doc('a.xml')/id('a123')

But although it's strange, I think the semantics are well defined.
Comment 2 Abel Braaksma 2019-02-19 21:18:37 UTC
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.