TEDEFO-5148: Preserve predicates and the leading separator when joining paths - #58
Merged
rousso merged 1 commit intoAug 27, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
XPathProcessor.join discarded the predicates of the paths it joined, and the leading separator of the first one. A caller that joined a path carrying a filter received the path without it, and nothing reported an error.
The cause was that a step and its predicates are held separately in XPathStep, and join composed its result from the step text alone. Its sibling, contextualize, already appended the predicates, so the two disagreed.
The change is in four parts.
A step now renders itself, predicates included, and both places that compose a path from steps use it. Composing a path while forgetting the predicates is no longer something a caller can do by choosing the wrong accessor.
Where a path starts from is now recorded when it is parsed, as an XPathAnchor of RELATIVE, ROOT or DESCENDANT_FROM_ROOT. The steps cannot carry it, since the separator that expresses it is not a step. It is read from the parse tree, where the grammar states it plainly as pathexpr : (SLASH relativepathexpr?) | (SS relativepathexpr) | relativepathexpr, rather than from the start of the input, so that anything the lexer skips first, such as a comment, does not hide it. Only the outermost path expression is taken; a path inside a predicate belongs to the predicate.
join now composes the two parts as a single sequence of steps. Previously it glued two halves together with a separator of its own, which put one in front of the result whenever the first part had been emptied by parent steps.
Two further cases are corrected. A join that resolves to where it started, such as join("/a", ".."), returned nothing and threw; it now gives "/" when the path was anchored at the root and "." when it was not, which is the convention contextualize already follows. And the first step of a path that searches from the root is no longer cancelled against a parent step: "//a/.." selects the parents of every a element at any depth, which is not the root.
One thing is deliberately left as it is. Separators inside a path are still not retained, so join("a//b", "c") gives a/b/c. That belongs to the step model rather than to join, and is worth its own change.
Verified by 73 tests in this repository, and end to end through the EFX Toolkit, where the three context-override forms now keep their predicates in both expression translators.