Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow self::(a|b|c) #107

Closed
michaelhkay opened this issue Jan 4, 2022 · 5 comments
Closed

Allow self::(a|b|c) #107

michaelhkay opened this issue Jan 4, 2022 · 5 comments
Labels
Feature A change that introduces a new feature XPath An issue related to XPath

Comments

@michaelhkay
Copy link
Contributor

After an explicit axis specifier (including the abbreviated axis specifier "@", but not including the default axis specifier), allow a composite NodeTest that consists of a |-separated list of NodeTest's in parentheses. For example

@(id|name)

ancestor::(section|chapter)

child::(comment()|processing-instruction())

The composite NodeTest matches a node if any of its constituent NodeTest's matches.

@joewiz
Copy link

joewiz commented Jan 4, 2022

This would be great! This would be a far more natural way to express NodeTests like these.

@cedporter cedporter added XPath An issue related to XPath Enhancement A change or improvement to an existing feature Feature A change that introduces a new feature and removed Enhancement A change or improvement to an existing feature labels Sep 14, 2022
@rhdunn rhdunn added the XQuery An issue related to XQuery label Sep 15, 2022
@michaelhkay
Copy link
Contributor Author

Here's the detail.

AbbrevForwardStep ::= "@"?  NodeTest
changes to

AbbrevForwardStep  ::= "@"  NodeTest | SimpleNodeTest
NodeTest ::= SimpleNodeTest | ParenthesizedNodeTest
ParenthesizedNodeTest ::= "(" SimpleNodeTest ("|" SimpleNodeTest)* ")"
SimpleNodeTest ::= NameTest | KindTest

(Note, I've chosen not to allow child::(A | (B|C) ) - no nesting allowed or needed.

In 4.6.2.2 we need to add "A ParenthesizedNodeTest matches a node if any of its constituent SimpleNodeTests matches the node".

Apart from that it's just a case of adding examples and notes.

XSLT needs to pick up the change in the syntax for patterns. A pattern that uses a ParenthesizedNodeTest has a default priority of +0.5.

@dnovatchev dnovatchev removed the XQuery An issue related to XQuery label Sep 22, 2022
@ChristianGruen ChristianGruen added this to the QT 4.0 milestone Oct 14, 2022
@michaelhkay
Copy link
Contributor Author

Note that most of the time, this construct is just syntactic sugar: @(A|B) is equivalent to @A|@B.

However, with a reverse axis, it does add expressive power. ancestor::(div1|div2)[2] is not easily expressed any other way, because (ancestor::div1|ancestor::div2)[2] has a different meaning (the union operator sorts nodes into document order before applying the predicate).

@michaelhkay
Copy link
Contributor Author

This proposal overlaps issue #23. It's wider than issue #23 in that it allows unions of NodeTests, not just NameTests. But it's narrower in that it doesn't allow multiple names in an elementTest (for example element(A|B|C)).

@michaelhkay
Copy link
Contributor Author

This change has been implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature A change that introduces a new feature XPath An issue related to XPath
Projects
None yet
Development

No branches or pull requests

6 participants