Implement W3C XQuery Update Facility 3.0#6214
Open
joewiz wants to merge 6 commits intoeXist-db:developfrom
Open
Implement W3C XQuery Update Facility 3.0#6214joewiz wants to merge 6 commits intoeXist-db:developfrom
joewiz wants to merge 6 commits intoeXist-db:developfrom
Conversation
19 tasks
…e List Adds the core XQUF expression classes for insert, delete, replace, rename, and transform (copy-modify-return) operations, plus the Pending Update List (PUL) merge-and-apply infrastructure. The PUL implements the W3C XQUF 3.0 update primitive model with five phases: insert, replace, rename, delete, and put. Update primitives are collected during expression evaluation and applied atomically at snapshot boundaries. Expression classes: - XQUFInsertExpr: insert node (before/after/into/as first/as last) - XQUFDeleteExpr: delete node - XQUFReplaceNodeExpr: replace node - XQUFReplaceValueExpr: replace value of node - XQUFRenameExpr: rename node - XQUFTransformExpr: copy-modify-return (in-memory deep copy + PUL) Includes namespace conflict detection (XUDY0021/0023/0024) inspired by BaseX's NamePool approach. Spec: W3C XQuery Update Facility 3.0, Sections 2.1-2.5 XQTS: 684/684 non-schema tests pass Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implements XUST0001 (non-updating expression in updating context) and XUST0002 (updating expression in non-updating context) static type checking across the expression hierarchy. Adds Expression.isVacuous() method for recursive vacuousness detection, which allows expressions like empty sequences and conditionals with all-vacuous branches to pass XUST checks. This is required because vacuous expressions are compatible with both updating and non-updating contexts per the W3C XQUF 3.0 spec. Key changes: - Expression.java: isVacuous(), isUpdating(), analyze() flags - PathExpr: context step propagation fix (i>=1 for XQUF) - TypeswitchExpression, SwitchExpression: branch-level XUST checks - ConditionalExpression: then/else branch XUST checks - ErrorCodes: XUST0001, XUST0002, XUDY0009, XUDY0014-0024, XUTY0004-0013, XUTY0022 - FunctionSignature: updating annotation support - FunctionCall: updating function call propagation Spec: W3C XQuery Update Facility 3.0, Section 2.6 (Static Typing) XQTS: 684/684 non-schema tests pass Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extends the memtree DocumentImpl with mutation methods required by XQUF update primitives operating on in-memory (copy-modify-return) nodes. The flat-array architecture of eXist's memtree requires careful index management for insertions, deletions, and replacements. Key additions to DocumentImpl: - insertChildNode/insertChildNodes: insert before/after/into - removeNode: delete with descendant cleanup and array compaction - replaceNode: atomic replace preserving document order - replaceValue: text/attribute/PI/comment value replacement - renameNode: element/attribute/PI rename with namespace handling - replaceElementContent: replace all children with text node - compact(): post-update array defragmentation ElementImpl/NodeImpl changes: - getFirstChildFor(): skip deleted nodes in chain navigation - Namespace propagation helpers for insert operations Updates are processed in reverse document order where needed to avoid flat-array cross-contamination during batch operations. Spec: W3C XQuery Update Facility 3.0, Section 3 (Update Primitives) XQTS: 684/684 non-schema tests pass Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds parser and tree walker rules for all W3C XQuery Update Facility 3.0 expressions: insert, delete, replace (node and value), rename, and copy-modify-return (transform). XQuery.g (lexer/parser): - New tokens: REPLACE, RENAME, COPY, MODIFY, FIRST, LAST, BEFORE, AFTER, INTO, WITH, UPDATING - insertExpr, deleteExpr, replaceExpr, renameExpr, transformExpr - Integration into exprSingle production - Updating function annotations XQueryTree.g (tree walker): - Instantiates XQUF expression classes from AST - Legacy/XQUF syntax conflict detection via markLegacyUpdate/ markXQUFUpdate on XQueryContext - Updating function declaration handling XQueryFunctionAST.java: - isUpdating() flag for function declarations Spec: W3C XQuery Update Facility 3.0, Section 2.1 (Syntax) XQTS: 684/684 non-schema tests pass Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds fn:put() for persistent document storage via the XQUF Pending Update List, plus the XQueryContext integration layer that connects the XQUF expression classes to the query execution lifecycle. XQUFFnPut.java: - W3C fn:put($node, $uri) implementation - Creates a put update primitive on the PUL - Validates node must be document or element node (FOUP0001) XQueryContext changes: - PendingUpdateList field with get/set accessors - Legacy/XQUF syntax conflict detection (markLegacyUpdate/ markXQUFUpdate) to prevent mixing update syntaxes - PUL reset in context cleanup XQuery.java: - PUL application at query completion boundary FnModule.java: - Register XQUFFnPut in fn: namespace FunInScopePrefixes.java: - Support in-memory nodes for namespace prefix queries Spec: W3C XQuery Update Facility 3.0, Section 2.5.2 (fn:put) XQTS: 684/684 non-schema tests pass Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds comprehensive JUnit test coverage for all W3C XQuery Update Facility 3.0 operations, plus a performance benchmark for measuring update primitive throughput. XQUFBasicTest.java (73 tests): - Insert node (before/after/into/as first/as last) - Delete node (element, attribute, text, comment, PI) - Replace node and replace value of node - Rename node (element, attribute, PI) - Copy-modify-return (transform) expressions - Namespace conflict detection (XUDY0021/0023/0024) - XUST0001/XUST0002 static type errors - Complex multi-step update scenarios XQUFBenchmark.java: - Performance benchmarks for insert/delete/replace throughput - Deep tree copy-modify-return scaling tests bindingConflictXQUF.xqm: - XQUF-specific namespace binding conflict tests using copy-modify-return syntax (separated from legacy tests because the two syntaxes cannot be mixed in one module) XQTS: 684/684 non-schema tests pass (W3C XQuery Update Facility) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fd603f2 to
2e30b57
Compare
Member
Author
|
[This response was co-authored with Claude Code. -Joe] CI state: 8/9 checks pass. The 1 remaining failure (windows integration) is a pre-existing test hang unrelated to this PR. Dependencies: Wave 3. Should merge after Wave 1 and Wave 2 PRs, and before For full context on all 7.0 PRs and the merge order, see the Reviewer Guide. |
This was referenced Apr 14, 2026
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.
Summary
Implements the W3C XQuery Update Facility 3.0 alongside eXist's existing legacy update syntax. Both syntaxes coexist — legacy update continues to work unchanged.
What Changed
org.exist.xquery.xquf— PUL (Pending Update List) + expression classesisVacuous()recursive detectionSpec References
XQTS
Tests
Supersedes
Test plan
🤖 Generated with Claude Code