Rod-O opened a new pull request, #67: URL: https://github.com/apache/xerces-c/pull/67
Fixes [XERCESC-2269](https://issues.apache.org/jira/browse/XERCESC-2269). `UnionDatatypeValidator::isSubstitutableBy()` only compared the candidate type with the union itself and with its member types. A simple type derived from the union by restriction, whose base validator is the union, was therefore not considered validly derived from it, contrary to XML Schema 1.0 "Type Derivation OK (Simple)", clause 2.1. With schema full checking this rejected valid schemas that restrict a union-typed element to a restriction of the union ("element 'e' has type that does not derive from type of corresponding element in the base"); the same check is used for `xsi:type` and substitution groups. The fix walks the candidate's base chain, as `DatatypeValidator::isSubstitutableBy()` does, but only while the validator is a union: restrictions of a union are always unions, and a list whose item type is the union (whose base validator is also the union) must not match. The existing `toCheck == this` test is subsumed by the first iteration. Member-type handling is unchanged. Test: new sample test `DOMCount4` (CMake and autotools) runs `DOMCount -n -s -f union-restriction.xml` on a schema that restricts a union-typed element to a one-level and a two-level restriction of the union. It fails on master with the message above and passes with the fix. The full ctest suite passes (81/81) on Ubuntu 24.04 (GCC 13, ICU transcoder, curl net accessor). The W3C QT3 schema `prod/SchemaImport/unionListDefined.xsd`, which originally exposed the bug, loads with the fix. Files: - `src/xercesc/validators/datatype/UnionDatatypeValidator.hpp`: the fix. - `samples/data/union-restriction.xsd`, `samples/data/union-restriction.xml`, `samples/expected/DOMCount4.log`, `samples/scripts/DOMCount4`, `samples/CMakeLists.txt`, `samples/Makefile.am`: the regression test. -- 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]
