aizu-m opened a new pull request, #152: URL: https://github.com/apache/poi-xmlbeans/pull/152
Found with a differential run of `XmlObject.validate()`, `ValidatingXMLStreamReader` and the JDK Xerces validator over the same schemas and instances. Only the stream reader disagreed, and only when the root element carried an xsi attribute. 1. `validate_event` creates the Validator on the first START_ELEMENT and sends two BEGIN events: one for the type it was started with (the document type from `typeForGlobalElement`, or the caller's content type), then one for the element. Both passed `_elemEvent`, whose `getXsiType`/`getXsiNil` read the current element's attributes. 2. `Validator.beginEvent` therefore checked the root's xsi:type and xsi:nil against the document type. A document type is never the base of a named type and has no nillable field. 3. The resulting error sets `_eatContent` at document level. Nothing else in the document is validated, and the facets of the xsi:type are never applied. ``` schema: <i> is xs:int, t:small restricts xs:int with maxInclusive=5, <n> is xs:int nillable <i xsi:type='t:small'>3</i> validate(): valid Xerces: valid stream reader: cvc-elt.4.3a not derived from D=i <i xsi:type='t:small'>9</i> validate(): cvc-maxInclusive-valid stream reader: cvc-elt.4.3a <n xsi:nil='true'/> validate(): valid Xerces: valid stream reader: cvc-elt.3.1 not nillable ``` The root BEGIN now uses `_simpleEvent`, which carries no xsi attributes. The CHARACTERS-first path and `pushBufferedAttributes` already start the validator that way. After the change the differential run has no stream-reader-only disagreement left. Regression tests added to `ValidatingXMLStreamReaderTests`; they fail before the change and pass after. Full `./gradlew test` passes. -- 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]
