[bugfix] Preserve in-scope namespaces when copying XQueryContext#6329
Open
joewiz wants to merge 2 commits into
Open
[bugfix] Preserve in-scope namespaces when copying XQueryContext#6329joewiz wants to merge 2 commits into
joewiz wants to merge 2 commits into
Conversation
The XQueryContext copy constructor copied staticNamespaces (prolog
"declare namespace" entries) but dropped inScopeNamespaces. The tree
parser uses the copy as its lookup context (XQueryTree.g:94), so any
prefix a host application registered via declareInScopeNamespace
before compilation -- the API the XQTS runner uses to apply each
test's <environment><namespace>... declarations -- was invisible to
QName.parse() during tree-walk and produced spurious XPST0081 errors.
Closes 23 XQ 3.1 XQTS failures across op-intersect, op-union, and
op-except (the fn-{intersect,union,except}-node-args tests using the
"atomic" environment), plus partial relief for prod-* tests that go
through the same code path.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
line-o
reviewed
May 10, 2026
| } | ||
| } | ||
|
|
||
| // Copy in-scope namespaces too. Hosts (e.g. the XQTS runner) register |
Member
There was a problem hiding this comment.
I would shorten this comment to
Copy in-scope namespaces registered via declareInScopeNamespace. Otherwise QName.parse()
will raise error XPST0081 when resolving path-step names in any of those
Member
Author
There was a problem hiding this comment.
[This response was co-authored with Claude Code. -Joe]
Done in 5a91572f5d — applied your exact suggested wording.
…r line-o Apply line-o's exact suggested wording from the PR eXist-db#6329 review thread. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
XQueryContextcopy constructor to also copyinScopeNamespaces, not juststaticNamespaces.Why
The tree parser uses a copy of the supplied
XQueryContextas its lookupstaticContext(seeXQueryTree.g:94). When a host application registers prefixes viadeclareInScopeNamespace(prefix, uri)before compilation -- the API the exist-xqts-runner uses to apply each test's<environment><namespace prefix="..." uri="..."/>declaration -- the copy dropped them. Path-stepQName.parse(staticContext, ...)then could not resolve the prefix and threw XPST0081 with the misleading message No namespace defined for prefix<eqname>(where<eqname>is the entireprefix:localtoken because that is whateq.getText()returns at the catch site in the tree parser).The copy constructor previously preserved every other piece of static-context state -- decimal formats, default namespaces, declared functions, modules, etc. -- but
inScopeNamespaceswas overlooked. The fix adds the same kind of straightforward map copy.What changed
exist-core/src/main/java/org/exist/xquery/XQueryContext.java: in theXQueryContext(XQueryContext copyFrom)constructor, after copyingstaticNamespaces, also copyinScopeNamespacesandinScopePrefixes.exist-core/src/test/java/org/exist/xquery/InScopeNamespaceCompileTest.java: new regression test mirroring the failing XQTS scenarios. Compiles(/atomic:root/atomic:integer) intersect/union/except (/atomic:root/atomic:integer)(plus a plain path baseline) after registering theatomicprefix viadeclareInScopeNamespace. Each test fails on develop and passes with the fix.Spec references
<environment><namespace>(source) is the standard mechanism for an XQTS test environment to declare statically-known namespaces.XQTS before/after (XQ 3.1 develop, op-intersect/union/except, same runner JAR)
(Other failures in these test sets -- mostly XQST0031 from XQ10+ tests being forced to
xquery version "4.0"by a runner-side change -- are unrelated to this fix and unchanged.)Test plan
InScopeNamespaceCompileTest) fails on develop, passes with fixmvn test -pl exist-core(6,703 tests, 0 failures, 105 skipped) -- the one pre-existing parallel-test classloader flake (DeepEmbeddedBackupRestoreTest/NoClassDefFound) passes in isolationXQueryContext.java[This response was co-authored with Claude Code. -Joe]
Note on test isolation
mvn test -pl exist-coreshowed one parallel-suite flake that passes when re-run in isolation. Perfeedback_distinguish_ci_failure_shapes.mdthis is a classloader-isolation symptom, not a fix-introduced regression — the fix only touchesXQueryContext's copy constructor (10 lines, additive — copies two existing fields that were silently dropped) and the newInScopeNamespaceCompileTestruns cleanly in isolation. Calling it out here so reviewers don't have to re-verify.