Skip to content

[bugfix] cover native collection.xconf.xsd via OASIS catalog + jaxp - #6687

Merged
line-o merged 3 commits into
eXist-db:developfrom
duncdrum:test/native-schema-jaxp-catalog-gap
Sep 14, 2026
Merged

line-o merged 3 commits into
eXist-db:developfrom
duncdrum:test/native-schema-jaxp-catalog-gap

Conversation

@duncdrum

@duncdrum duncdrum commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Description:

Adds NativeSchemaJaxpCatalogGapTest to close the integration gap left by #6528, and fixes the gap it found:

  • Green control: validation:jaxv-report + XSD 1.1 language URI against schema/collection.xconf.xsd (valid minimal collection.xconf; empty one fails xs:assert).
  • Previously missing path (now fixed): validation:jaxp-report via an OASIS catalog whose <uri> maps http://exist-db.org/collection-config/1.0 to an absolute file: URI of that same native XSD — mirrors the WEB-INF/catalog.xml → $EXIST_HOME/schema/ wiring tools are meant to use.

Root cause: Jaxp#newXsd11Validator wired an OASIS/system catalog's org.xmlresolver.Resolver in directly as the XSD 1.1 validator's LSResourceResolver. That resolver's resolveResource() requires a non-null systemId before it will consult the catalog at all, so a <uri> entry keyed purely by namespace was invisible whenever the instance carried no schemaLocation hint — even though the same catalog entry already worked for the default SAX pipeline, which falls back to the namespace as the systemId (see XercesXmlResolverAdapter#resolveEntity).

Fix: XercesXmlResolverAdapter#asLSResourceResolver applies that same namespace-as-systemId fallback. Code review of the first fix found validation:jaxv()'s SchemaFactory catalog wiring had the identical unfixed gap (same raw-Resolver pass-through, for xs:import/xs:include resolution during schema compilation), so it's fixed the same way and both call sites now share a single asLSResourceResolver(LSResourceResolver) dispatch instead of duplicating the instanceof check.

Existing coverage did not catch this: JaxpXsdCatalogTest XSD 1.1 cases use directory-search over /db/.../, which SearchResourceResolver already resolves purely by namespace; CollectionConfigSchema6000Test / Maven validate use raw SchemaFactory, not validation:jaxp.

What Changed

  • exist-core/src/main/java/org/exist/resolver/XercesXmlResolverAdapter.java — new asLSResourceResolver(Resolver) wrapping an org.xmlresolver.Resolver as an LSResourceResolver with a namespace→systemId fallback, plus an asLSResourceResolver(LSResourceResolver) overload that dispatches on the concrete resolver type (only wrapping when it's a Resolver) so both call sites below share one implementation.
  • exist-core/src/main/java/org/exist/xquery/functions/validation/Jaxp.java — newXsd11Validator now routes its catalog resolver through the new adapter before handing it to the XSD 1.1 Validator.
  • exist-core/src/main/java/org/exist/xquery/functions/validation/Jaxv.java — same fix for the SchemaFactory#setResourceResolver catalog wiring.
  • exist-core/src/test/java/org/exist/xquery/functions/validate/NativeSchemaJaxpCatalogGapTest.java — the regression test; updated comments now that the gap is closed, and escapes the generated catalog's file: URI attribute (Path#toUri() doesn't XML-escape characters like & a checkout path could contain).

Reference:

Type of tests:

JUnit (ExistXmldbEmbeddedServer) in exist-core.

mvn -pl exist-core -Dtest=NativeSchemaJaxpCatalogGapTest test

Test Plan

  • NativeSchemaJaxpCatalogGapTest — 3/3 green (was 2/3, 1 expected-red)
  • JaxpXsdCatalogTest — 12/12 green (no regression)
  • Full validate/validation package (JaxpParseTest, JaxvTest, JaxpDtdCatalogTest, JaxpSchemaLocationSecurityTest, JaxpXsd11DetectionCacheTest, IsMissingElementDeclarationTest, Jing*/Parse* suites, etc.) — 77/77 green
  • CI: all checks green except a pre-existing network flake (unparsed-text-from-url, unrelated fn:unparsed-text() GitHub-raw fetch)

Made with Cursor

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

📊 XQTS result comparison

Comparison of this run against develop.

Metric develop this run Change
➖ Passed 28,846 (90.67%) 28,846 (90.67%) 0 (0.00 pp)
➖ Failures 1,568 1,568 0
➖ Errors 134 134 0
➖ Skipped 1,267 1,267 0
🧪 Total tests 31,815 31,815 0

Relative to develop: 1 newly passing, 1 newly failing, 0 new errors, 0 newly skipped — counting only tests recorded in both runs whose outcome changed.

🔴 Newly failing tests (1)
  • Constr-inscope-1 (was passing)
🟢 Newly passing tests (1)
  • Constr-inscope-2 (was failing)

Runtime: 466.4s (+1.25s vs develop).

@duncdrum
duncdrum force-pushed the test/native-schema-jaxp-catalog-gap branch from c19ea64 to 34dae71 Compare September 8, 2026 16:06
duncdrum and others added 2 commits September 9, 2026 16:30
Adds a control that jaxv-report + XSD 1.1 applies schema/collection.xconf.xsd,
and an assertion that jaxp-report via an OASIS catalog mapping the
collection-config namespace to that same file: URI reports valid — the
tool-facing path eXist-db#6528 advertised but never integration-tested (eXist-db#6686).

Co-authored-by: Cursor <cursoragent@cursor.com>
validation:jaxp-report()'s XSD 1.1 retry validator wired an OASIS/system
catalog's org.xmlresolver.Resolver in directly as the LSResourceResolver.
That resolver's resolveResource() requires a non-null systemId before it
will consult the catalog at all, so a <uri> entry keyed purely by
namespace was invisible whenever the instance had no schemaLocation hint
-- even though the same catalog entry already worked for the default SAX
pipeline, which falls back to the namespace as the systemId.

Add XercesXmlResolverAdapter#asLSResourceResolver to apply that same
namespace-as-systemId fallback to the XSD 1.1 validator pipeline, and
wire it into Jaxp#newXsd11Validator. Turns
NativeSchemaJaxpCatalogGapTest's jaxpViaOasisCatalogAgainstNativeCollectionSchemaValid
green.

Closes eXist-db#6686
@duncdrum
duncdrum force-pushed the test/native-schema-jaxp-catalog-gap branch from 34dae71 to d3dc43d Compare September 9, 2026 14:41
@duncdrum duncdrum changed the title test(validation): cover native collection.xconf.xsd via OASIS catalog + jaxp [bugfix] cover native collection.xconf.xsd via OASIS catalog + jaxp Sep 9, 2026
Code review of the jaxp fix (previous commit) found the identical gap
unfixed on validation:jaxv()'s SchemaFactory catalog wiring: it passed
the raw org.xmlresolver.Resolver straight to setResourceResolver(),
so an xs:import/xs:include with no schemaLocation, resolved purely by
namespace through an OASIS/system catalog, would silently fail the
same way jaxp's XSD 1.1 validator did.

Add an asLSResourceResolver(LSResourceResolver) overload that centralizes
the Resolver-vs-other dispatch (mirroring the existing switch in
setXmlReaderEntityResolver), and use it from both Jaxp and Jaxv instead
of duplicating the instanceof check.

Also escape the file: URI embedded in NativeSchemaJaxpCatalogGapTest's
generated catalog.xml, since Path#toUri() does not XML-escape characters
like '&' that a checkout directory name could legally contain.
@duncdrum
duncdrum marked this pull request as ready for review September 9, 2026 15:40
@duncdrum
duncdrum requested a review from a team as a code owner September 9, 2026 15:40
@duncdrum duncdrum added the bug issue confirmed as bug label Sep 9, 2026
@duncdrum duncdrum added this to v7.0.0 Sep 9, 2026
@duncdrum duncdrum added this to the eXist-7.0.0 milestone Sep 9, 2026
@duncdrum duncdrum moved this to In review in v7.0.0 Sep 9, 2026

@line-o line-o left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM <3

@line-o
line-o merged commit 5cbe8a1 into eXist-db:develop Sep 14, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in v7.0.0 Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug issue confirmed as bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

validation:jaxp + OASIS catalog does not apply native XSD 1.1 schemas from $EXIST_HOME/schema

3 participants