aizu-m opened a new pull request, #163:
URL: https://github.com/apache/poi-xmlbeans/pull/163
Differential run of `XmlObject.validate()`, `ValidatingXMLStreamReader` and
the JDK Xerces validator. The head is `<xs:element name="head" type="t:base"
block="extension"/>` and `member` is in its substitution group with a type that
extends `t:base`:
<r><member><a>1</a><b>2</b></member></r>
xerces: cvc-complex-type.2.4.a: Invalid content was found starting
with element '{"urn:t":member}'. One of '{"urn:t":head}' is expected.
xmlbeans: valid
stream: valid
How it was found:
- I ran substitution groups through both validators with block on the head,
on its complex type, on an intermediate type and via blockDefault. 7 of 12
cases disagreed. XmlBeans accepted every time.
- `block="substitution"` and `block="#all"` already fail with
cvc-particle.2.3.3a. xsi:type with block already agrees.
- `Validator.beginEvent` swaps in the member when its name differs from the
particle. It only checks `blockSubstitution()` on the head. Nothing looks at
how the member's type was derived.
Observation: XML Schema 1.0 (Substitution Group, and Substitution Group OK
(Transitive) 2.3) drops a member from the group when its type is derived from
the head's type by a method that the head, the head's type or an intermediate
type blocks. XmlBeans ignores all three.
Conclusion: an instance can use a member the schema author blocked, with the
extra content of the extended type, and it validates clean through both
`XmlObject.validate()` and `ValidatingXMLStreamReader`.
Fix: after the `blockSubstitution` check, walk the member type's base chain
up to the head type, the same way Xerces does, and report cvc-particle.2.3.3b
if a blocked method is used. Schemas without block on a head or its types are
not affected. Unblocked derivations and same-type members validate as before. A
union-typed head, where the head type is not on the chain, is left as it is.
After the change the differential run has no substitution group disagreement
left. Regression test added; it fails before the change and passes after.
`./gradlew test` passes.
Not in this change: element declarations do not pick up the schema's
blockDefault (complex types do), so blockDefault only reaches this check
through the head's complex type.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]