Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect we'd want all of the orderings here.
These should be valid as well, right?
I think the only constraints are:
[[1]]
comes before[2]
(array order) and[1]
(descendant)[2]
comes before2
(descendant)[1]
comes before1
(descendant)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there's a way we can express the constraints themselves rather than listing all of the possibilities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although valid permutations, applying the wildcard selector to
1
and2
will never produce a node, so their position has no impact on the resulting node list.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They don't have to produce a node for these orderings. I'm not sure what point you're making.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might have misunderstood what you were saying 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, these are the result of
..
before[*]
is applied. See section 2.5.2.2 of the RFC. Actually, I made the same mistake the other day, see "Confession" in my recent blog post.Those are constraints on the traversal order. The RFC requires that
[*]
is applied to the input node and its descendants.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gregsdennis I've given that a lot of thought. The best description of the constraints that I know of is in the RFC, but that's not amenable to coding in a testcase. The difficulty is that a mixture of deterministically and non-deterministically ordered subsections are flattened into the resultant nodelist and it's very hard to keep track of what's going on. If someone can think of a way of encoding this rather than listing all the possibilities, that would be very interesting. For the moment, I think generating the list of possibilities is the most reliable approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't make sense.
..
on its own doesn't do anything. It merely informs the[*]
that it should recurse.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not what RFC 9535 says. Section 2.5.2.2 explains the semantics of
..[<selectors>]
in terms of first visiting the input value and its descendants to form the list of nodes D1, ..., Dn (where n >= 1 and D1 is the input value).So that's the semantics of the
..
part of..[*]
, even though..
on its own is not valid syntax in the RFC.Then, and this is crucial, the RFC says:
So, in this example, we need to apply
[*]
to each of the input node and its descendants. We then concatenate the resultant nodelists to form the result of..[*]
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're confident that these are the only two possibilities, I'm happy to go with it. I still don't understand why the others I listed aren't valid outputs, though.