You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by "aizu-m (via GitHub)" <gi...@apache.org> on 2026/10/07 14:54:20 UTC
[PR] terminate the xsi:type block walk in Validator.beginEvent [poi-xmlbeans]
aizu-m opened a new pull request, #134:
URL: https://github.com/apache/poi-xmlbeans/pull/134
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
Re: [PR] terminate the xsi:type block walk in Validator.beginEvent [poi-xmlbeans]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #134:
URL: https://github.com/apache/poi-xmlbeans/pull/134#issuecomment-6211538357
Thanks for this. The `t != null` guards look right, and I've kept them. I pushed one follow-up commit (63c5a6e9) because of a problem the second test uncovered.
**Problem:** a complex type with union simple content gets the content type's simple variety and union members (`StscComplexTypeResolver`). This means `isAssignableFrom` took the union-member branch for `ct` too, and `ct.isAssignableFrom(xs:int)` returned true. With the null guards in place, `unionMemberSubstitutionUnderTypeBlock` stopped throwing, but the document then **validated successfully**. A simple type was accepted as `xsi:type` for a complex type, where the spec requires cvc-elt.4.3a. The test's `assertDoesNotThrow` didn't catch this.
**Changes:**
- `SchemaTypeImpl.isAssignableFrom`: the union-member branch (Type Derivation OK (Simple) 2.2.4) now applies only when the type is a simple type: `isSimpleType() && getSimpleVariety() == UNION`.
- The second test is renamed `simpleTypeSubstitutionForUnionContentComplexType`. It now asserts that `validate()` returns false with a single `cvc-elt.4.3a` error. I also removed the unused `assertDoesNotThrow` import.
The real union case (test 1) still validates, and it still relies on your null guard in the block walk.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
Re: [PR] terminate the xsi:type block walk in Validator.beginEvent [poi-xmlbeans]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning merged PR #134:
URL: https://github.com/apache/poi-xmlbeans/pull/134
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
Re: [PR] terminate the xsi:type block walk in Validator.beginEvent [poi-xmlbeans]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #134:
URL: https://github.com/apache/poi-xmlbeans/pull/134#issuecomment-6215121308
Merged with my follow up change. Get back to me if more is needed or if you think my commit has issues.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
Re: [PR] terminate the xsi:type block walk in Validator.beginEvent [poi-xmlbeans]
Posted by "aizu-m (via GitHub)" <gi...@apache.org>.
aizu-m commented on PR #134:
URL: https://github.com/apache/poi-xmlbeans/pull/134#issuecomment-6231012183
Read through 63c5a6e9. Your follow-up is right. I'd treated the second case as the same union walk and only checked that it stopped throwing, so I missed that ct was inheriting the union variety and letting xs:int through. Gating 2.2.4 on isSimpleType() is the correct place for it, and cvc-elt.4.3a is the expected outcome there. Nothing more from my side. Thanks for merging.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org