Repository navigation
assess undeclared wildcard elements against their xsi:type in Validator - #151
Merged
Merged
Conversation
…ldcard behaviour Undeclared elements matching a lax or strict wildcard are now assessed against their xsi:type. Users who relied on the previous behaviour, where such elements were skipped (lax) or reported as unresolved (strict) whatever their xsi:type, can opt back in with this validation option. Unlike setValidateTreatLaxAsSkip, declared elements are still validated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pjfanning
force-pushed
the
wildcard-xsi-type-assess
branch
from
November 15, 2026 20:05
f7cb26c to
566133d
Compare
Member
|
added XmlOptions.setValidateWildcardIgnoreXsiType to optionally allow the old wildcard behaviour |
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.
Differential run, XmlObject.validate() against the JDK Xerces validator, schema with
<xs:any processContents='lax'/>and no global declaration foru:How it was found: a differential run of wildcard schemas through both validators. 13 lax and 3 strict disagreements over 18 instance variants.
Observation: when a lax or strict wildcard matches a name with no global declaration, Validator.beginEvent sets
_eatContentand returns before it reads xsi:type. Lax skips the element silently, whatever its content. Strict reports it as unresolved, even when the xsi:type content is valid.Conclusion: cvc-assess-elt.1.2 assesses an element with no declaration against its xsi:type when that resolves. The xs:any definition says strict needs a top-level declaration or an xsi:type. The validator only implements the first route.
Fix: with no declaration but an xsi:type present, carry on with xs:anyType as the declared type. The existing xsi:type resolution, derivation and block checks then run unchanged. Undeclared elements without xsi:type, and setValidateTreatLaxAsSkip, behave as before. XmlObject.validate() and ValidatingXMLStreamReader both go through this path.
After the fix the differential run has no disagreements left for these cases. Regression test added.
./gradlew testpasses.