Skip to content

TEDEFO-5148: Preserve predicates and the leading separator when joining paths - #58

Merged
rousso merged 1 commit into
developfrom
TEDEFO-5148-preserve-predicates-when-joining-paths
Aug 27, 2026
Merged

TEDEFO-5148: Preserve predicates and the leading separator when joining paths#58
rousso merged 1 commit into
developfrom
TEDEFO-5148-preserve-predicates-when-joining-paths

Conversation

@rousso

@rousso rousso commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

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.

@rousso
rousso merged commit 08593fc into develop Aug 27, 2026
5 checks passed
@rousso
rousso deleted the TEDEFO-5148-preserve-predicates-when-joining-paths branch August 27, 2026 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant