Skip to content

assess undeclared wildcard elements against their xsi:type in Validator - #151

Merged
pjfanning merged 2 commits into
apache:trunkfrom
aizu-m:wildcard-xsi-type-assess
Nov 15, 2026
Merged

pjfanning merged 2 commits into
apache:trunkfrom
aizu-m:wildcard-xsi-type-assess

Conversation

@aizu-m

@aizu-m aizu-m commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Differential run, XmlObject.validate() against the JDK Xerces validator, schema with <xs:any processContents='lax'/> and no global declaration for u:

<u xsi:type='t:small'>9</u>              xmlbeans: valid  xerces: cvc-maxInclusive-valid
<u xsi:type='t:ct'><z>x</z></u>          xmlbeans: valid  xerces: cvc-datatype-valid.1.2.1
<u xsi:type='t:missing'/>                xmlbeans: valid  xerces: cvc-elt.4.2
strict: <u xsi:type='t:small'>3</u>      xmlbeans: cvc-assess-elt.1.1.1.3.2  xerces: valid

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 _eatContent and 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 test passes.

aizu-m and others added 2 commits November 15, 2026 20:54
…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
pjfanning force-pushed the wildcard-xsi-type-assess branch from f7cb26c to 566133d Compare November 15, 2026 20:05
@pjfanning

Copy link
Copy Markdown
Member

added XmlOptions.setValidateWildcardIgnoreXsiType to optionally allow the old wildcard behaviour

@pjfanning
pjfanning merged commit 0a573fd into apache:trunk Nov 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants