Skip to content

Fix // followed by reverse axis step being misinterpreted#6080

Closed
joewiz wants to merge 1 commit intoeXist-db:developfrom
joewiz:fix/dslash-reverse-axis
Closed

Fix // followed by reverse axis step being misinterpreted#6080
joewiz wants to merge 1 commit intoeXist-db:developfrom
joewiz:fix/dslash-reverse-axis

Conversation

@joewiz
Copy link
Copy Markdown
Member

@joewiz joewiz commented Mar 3, 2026

Summary

  • Fix // (DSLASH) followed by a reverse axis step (preceding::, ancestor::, ancestor-or-self::, parent::, preceding-sibling::) being misinterpreted by the XQuery tree walker
  • The tree walker was overwriting the reverse axis with DESCENDANT_SELF_AXIS, so e.g. $node//preceding::node() behaved like $node/descendant-or-self::node() instead of the correct $node/descendant-or-self::node()/preceding::node()
  • Fix both the DSLASH and ABSOLUTE_DSLASH handlers to detect reverse axes and insert an explicit descendant-or-self::node() step before the reverse axis step, rather than merging them
  • Add tests covering // with all reverse axes

Closes #691

Test plan

  • New dslashWithReverseAxis test in XPathQueryTest passes (both local and remote parametrized variants)
  • All 150 existing XPathQueryTest tests pass with no regressions
  • XQTS prod-AxisStep.* test suites (345 tests) show zero regressions compared to baseline

🤖 Generated with Claude Code

@joewiz joewiz requested a review from a team as a code owner March 3, 2026 03:35
@joewiz joewiz force-pushed the fix/dslash-reverse-axis branch from dcf61fc to c280cec Compare March 3, 2026 05:38
The // abbreviation in XPath expands to /descendant-or-self::node()/.
When followed by a reverse axis (preceding, ancestor, etc.), the tree
walker incorrectly overwrote the reverse axis with DESCENDANT_SELF_AXIS,
destroying the original semantics. For example, $node//preceding::node()
behaved like $node/descendant-or-self::node() instead of the correct
$node/descendant-or-self::node()/preceding::node().

Fix both the DSLASH and ABSOLUTE_DSLASH handlers to detect reverse axes
(constants 0-4) and insert an explicit descendant-or-self::node() step
before the reverse axis step, rather than merging them.

Closes eXist-db#691

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@joewiz
Copy link
Copy Markdown
Member Author

joewiz commented Apr 6, 2026

[This comment was co-authored with Claude Code. -Joe]

Closing — superseded by #6207 (v2/xq31-compliance-fixes).

This work has been consolidated into a clean v2/ branch as part of the eXist-db 7.0 PR reorganization. The new PR includes all commits from this PR plus additional related work, with reviewer feedback incorporated where applicable. See the reviewer guide for the full context.

@joewiz joewiz closed this Apr 6, 2026
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.

The // pseudo-operator followed by an axis step is misinterpreted

2 participants