XSD 1.1 store-time document validation + Saxon catalog resolver - #6530
Conversation
line-o
left a comment
There was a problem hiding this comment.
OK - stale comment is not a blocker
494496f to
798040e
Compare
…antic changes Add a mvn validate execution (xml:transform@schema-governance) that catches semantic edits to the seven native XSD schemas without a matching @Version bump; bump all seven XSDs to reflect post-2023 semantic changes. Closes eXist-db#6190
798040e to
1e02258
Compare
…consolidate governance CI Add schemaVersion="x.y.z" to all five canonical config instances so administrators can see at a glance which XSD version a config file targets, and so startup code can log a DEBUG or WARN when it doesn't match. Consolidate the four separate governance shell scripts into a single governance.xsl, making the version-bump check fully Maven-native. Add SchemaVersionSyncTest to guard the generated constants against drift.
Include schema/ (conf.xsd, collection.xconf.xsd, descriptor.xsd, controller-config.xsd, mime-types.xsd, users.xsd, server.xsd, security-manager.xsd, expath-pkg.xsd and its extensions) in the tarball, zip, Docker image, IzPack installer, and macOS .app bundle as $EXIST_HOME/schema/. Also fix the "abrev" -> "abbrev" typo in expath-pkg.xsd. Closes eXist-db#6189 Partially addresses eXist-db#6008
bb51a30 to
a5fb068
Compare
a5fb068 to
f7f3463
Compare
|
MutableCollection.java (Namespaces / Caffeine / separate class) JettyStart.java:125 |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…generate SchemaVersion constants Extend the Maven validate phase to check every schema/*.xsd against the W3C XSD 1.1 meta-schema (upgrading the bundled XMLSchema.xsd/dtd to the 2009 XSD 1.1 revision); caught and removed five xsi:type="dcterms:W3CDTF" appinfo annotations with no backing schema, bumping the affected schema @Version values. Wire a generate-sources execution that reads each governed XSD's xs:schema/@Version and emits SchemaVersion.java constants so they can never drift from the schemas. Closes eXist-db#5541
…line Wire the XML Catalog API into Saxon's XsltCompiler so xsl:import, xsl:include, and document() URIs resolve via the eXist-db entity catalog (Closes eXist-db#350). Generalize MutableCollection's at-store-time validation to route through a JAXP 1.1 SchemaFactory when the schema or its catalog- resolved meta-schema requires XSD 1.1; extract the detection logic into Xsd11SchemaDetection so validation:jaxp() and org.exist.validation.Validator share the same probe-compile path. Suppress the spurious xmlresolver WARNING for the non-existent "default" catalog entry. Closes eXist-db#5541
… XML_SCHEMA_NS XML_SCHEMA_NS was never read — callers already used XMLConstants directly. XSD_1_1_NS is promoted to Namespaces.XSD_1_1_NS so it is available codebase-wide without duplication. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
f7f3463 to
0fe1766
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dizzzz
left a comment
There was a problem hiding this comment.
I have some open remarks still
|
@duncdrum could you have a look please |
…f MutableCollection MutableCollection carried a schema cache (plain ConcurrentHashMap) plus the namespace-resolution/validation logic that uses it -- neither is Collection state. Splits this into two package-private classes: - Xsd11SchemaCache: the per-namespace "needs XSD 1.1?" cache, now backed by Caffeine for consistency with the codebase's other caches (no eviction policy, since the namespace set is finite and admin-controlled -- this was never a correctness concern, just a style/testability one). - Xsd11ValidationHelper: resolveXsd11SchemaForNamespace, the dynamic-discovery schema holder, parseOrValidateXmlSource, validateWithXsd11Schema, and the Xsd11LexicalHandlerForwarder record -- store-time XSD 1.1 validation, not Collection bookkeeping. MutableCollection keeps only its public clearXsd11SchemaByNamespaceCache() facade (GrammarTooling.java's external call site) and a single delegating call from storeXmlDocument(); 9 imports that only the moved code needed are dropped. Behavior-preserving: all 63 tests across the validation/XSD11 suite pass unchanged. Addresses dizzzz's review comments on eXist-db#6530/eXist-db#6551.
…reated edit 4e949b4 dropped xsi:type="dcterms:W3CDTF" from the dcterms:created annotation in 5 sibling schema files and correctly bumped @Version on 4 of them (collection.xconf.xsd, cxan.xsd, exist.xsd, repo.xsd) -- this one was missed, leaving expath-pkg.xsd's content changed but @Version still 1.1.0. CI's schema governance check (ci-schema-checks.yml, added in PR-A) catches exactly this. Bumps to 1.1.1, a documentation/non-semantic patch per schema/README.md's policy, matching the sibling files' bumps. Verified locally against the real merge-base with upstream/develop: mvn -N xml:transform@schema-governance passes, SchemaVersionSyncTest passes unaffected (expath-pkg.xsd isn't one of the 5 SchemaVersion.java-tracked schemas).
| */ | ||
| final class Xsd11SchemaCache { | ||
|
|
||
| private static final Cache<String, Optional<Schema>> CACHE = Caffeine.newBuilder().build(); |
There was a problem hiding this comment.
Great! we might want to define a max time of caching or a max amount of cached items to prevent memory leaks.
There was a problem hiding this comment.
Good instinct in general, but I don't think it applies here: the key space is the system catalog's namespace list, which is fixed for the life of the running JVM — same as any other config eXist loads at startup/broker-pool-init. A catalog change needs a restart to take effect anyway, and that restart clears this cache along with everything else. So there's no unbounded growth path, just a cache that tops out at "however many namespaces the catalog declares" and stays there. Not adding an eviction policy for a ceiling that's already fixed by config, but happy to revisit if that assumption changes.
`resolveXsd11SchemaForNamespace` use a plain Schema local and wrap once, at the `Xsd11SchemaCache.put()` call site where the cache's Optional-typed value (needed because Caffeine can't cache null) actually matters.
|
@dizzzz XML Schema language's own XSD/DTD have been vendored in this repo since before XSD 1.1 support existed. We switched our own files to xsd 1.1 but kept shipping xsd 1.0 schema lang files. My guess is that the vendoring was specifically so schema validation doesn't have a hard runtime dependency on an external package. Eliminating the vendored copies entirely and resolve them from For now I would suggest to stick with the old approach, while introducing the new feature, and to get rid of conflicting versions. Switching the source of the files should be a patch release. It's a lot of code without functional changes. In other words quite a bit of work, for very little gain. I m more concerned about the new functionality and features to hit |
|
Agreed |
Summary
fn:transform()/transform:transform()) to resolvexsl:importanddocument()URIs via the system catalog — fixes issue Feature request: configure saxon to use webapp/WEB-INF/catalog.xml #350 for the XSLT transform pathorg.exist.validation.Validatorthrough the same XSD 1.1 detectionSchemaVersion.javaconstants from each XSD'sxs:schema/@versionat build timeWARNING: Failed to load catalogmessage when no default catalog existsWhat changed
SaxonConfiguration.java,Transform.java,URIResolution.javaXsd11ValidationHelper.java(new),Xsd11SchemaCache.java(new),Xsd11SchemaDetection.java(new)ValidatorroutingValidator.java,ValidatorXsd11Test.java(new)ResolverFactory.javaschema/generate-schema-version.xsl,exist-core/pom.xmlschema-version-codegenexecutionXsd11StoreTimeValidationTest.java,catalog.xqlXsd11SchemaCache(Caffeine-backed) andXsd11ValidationHelperwere split out ofMutableCollectionper review — that logic is validation/schema infrastructure, not Collection state.Related issues
validation:jaxp()now reports invalid XSD 1.1 schemas instead of silently misbehaving)xsl:import/document(); thefn:transform()+stylesheet-nodecase tracked separately, not fixed here)Test plan
Xsd11StoreTimeValidationTest,ValidatorXsd11Test— XSD 1.1 documents validate correctly at store time and viaValidatorcatalog.xql—transform:transform()resolvesxsl:importvia catalogXsd11SchemaCache/Xsd11ValidationHelperextractionlicense:check, schema governance,SchemaVersionSyncTest— all passNotes
PR-C of a 5-PR split from #6505 (superseded — needs closing separately). #6528 is merged; this branch's diff now shows only its own commits. Next in merge order: #6531 → #6550 → #6551.
🤖 Generated with Claude Code