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 30375 - [XSLT30] Default priority for match="Q{xyz}*
Summary: [XSLT30] Default priority for match="Q{xyz}*
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 (show other bugs)
Version: Recommendation
Hardware: PC All
: 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-12-14 23:00 UTC by Michael Kay
Modified: 2019-02-20 00:36 UTC (History)
1 user (show)

See Also:


Attachments

Description Michael Kay 2018-12-14 23:00:06 UTC
The syntax for patterns allows a NameTest, and one permitted form of a NameTest is "BracedURILiteral *", for example match="Q{http://www.w3.org/x}*".

The construct is particularly useful because it allows match="Q{}*", which matches elements in no namespace; there is no other convenient way of expressing this test.

The rules for default priority of patterns in section ยง6.5 do not handle this case explicitly. A literal reading of the rules means that it takes the "all other cases" rule 11, with a priority of +0.5. However, a much more reasonable interpretation would be that Q{uri}* is equivalent to p:*, which comes under rule 9, and gives a default priority of -0.25.
Comment 1 Michael Kay 2018-12-14 23:24:09 UTC
I am committing test case match-261, with an expected result that assumes a default priority of -0.25 for this case.
Comment 2 Abel Braaksma 2018-12-17 04:28:52 UTC
(In reply to Michael Kay from comment #0)
> A literal reading of the rules means that it takes the "all other cases" 
> rule 11, with a priority of +0.5
Actually, I don't think so. I think it matches Rule 10, "any other NodeTest", for which the production rules include the "BracedURILiteral *". This would yield a default priority of -0.5.

> However, a much more reasonable interpretation would be that Q{uri}* is 
> equivalent to p:*, which comes under rule 9, and gives a default priority of 
> -0.25.
I agree, and I think we should treat this as a clarification of the text, if possible, since anything else than -0.25 as explained in point 7 (which I read as the 'half wildcard' rule) seems odd.
Comment 3 Michael Kay 2019-01-17 10:44:08 UTC
There is a further complication here.

Consider the case match="element(*:local)"

Rule 7 says it applies "If the pattern is a PathExprP taking the form of an ElementTestXP30 or AttributeTestXP30, optionally preceded by a ForwardAxisP", but it does not cover this case. The entry for element(E) does not apply, because E "represents an arbitrary element name", and not a wildcard.

It seems intuitive that this should come under rule 9, and get a priority of -0.25.

But then what about element(*:local, xs:integer)? This doesn't seem to be covered at all.

Note that this problem applies equally to XSLT 2.0.

Recommendation: if W is a wildcard then:

(1) element(X) and attribute(X) are always treated the same as X and @X, so if X is a "partial wildcard" (A:* or *:A) then it has priority -0.25

(2) if X is a partial wildcard then element(X, T) and attribute(X, T) are treated the same as element(*, T) and attribute(*, T), getting a priority of 0. (In principle, element(X, T) is more specific than element(*, T) and less specific than element(E, T), but we really don't want to introduce another priority level between 0 and 0.25).
Comment 4 Michael Kay 2019-01-17 10:53:07 UTC
Forget comment (3). Partial wildcards are not allowed in an ElementTest or AttributeTest; the syntax element(*:X) or element(X:*) is not allowed.

Silly me for expecting orthogonality.