Skip to content

terminate the xsi:type block walk in Validator.beginEvent - #134

Open
aizu-m wants to merge 1 commit into
apache:trunkfrom
aizu-m:xsi-type-block-walk
Open

aizu-m wants to merge 1 commit into
apache:trunkfrom
aizu-m:xsi-type-block-walk

Conversation

@aizu-m

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

Copy link
Copy Markdown
Contributor
java.lang.NullPointerException: Cannot invoke "org.apache.xmlbeans.SchemaType.equals(Object)" because "t" is null
    at org.apache.xmlbeans.impl.validator.Validator.beginEvent(Validator.java:409)
    at org.apache.xmlbeans.impl.validator.Validator.nextEvent(Validator.java:160)
    at org.apache.xmlbeans.impl.store.Validate.emitEvent(Validate.java:172)

Hit this validating a document whose element is typed by a union and carries an xsi:type naming one of the union members, against a schema with block='extension' on that element.

  1. the three block / blockDefault checks in beginEvent walk the substituted type's base chain with for (SchemaType t = xsiType; !t.equals(elementType); t = t.getBaseType()). Each one assumes the declared element type sits somewhere on that chain.
  2. isAssignableFrom, which gates all three, does not promise that. Its union branch accepts a type derived from a member type, which is clause 2.2.4 of Type Derivation OK (Simple), and a union is not on its own members' base chain.
  3. so the walk runs past xs:anySimpleType to xs:anyType. fillInType sets base = null for BTC_ANY_TYPE, the next step is null, and equals throws.
  4. with block='restriction' or '#all' the loop body reports cvc-elt.4.3d on the first iteration. That is why only the extension-only case falls off the end.

Bounded all three walks with t != null, so an exhausted chain ends the loop the way it already does when no blocking derivation step is found. Chains that do contain the declared type, the blocked complex extension among them, behave as before.

Test covers the element-level block, the same substitution under a complex type with union simple content (that one dereferences null in the first loop instead of the third), and a blocked complex extension that must still be reported.

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.

1 participant