Repository navigation
Conversation
… union
UnionDatatypeValidator::isSubstitutableBy() only compared the candidate
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, which is wrong per
XML Schema 1.0, Type Derivation OK (Simple), clause 2.1.
With schema full checking this rejected valid schemas in which a complex
type restriction narrows an element of a union type to a restriction of
that 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.
Walk the base chain of the candidate while it is a union (restrictions of
a union are unions; a list whose item type is the union must not match).
Add sample test DOMCount4 with a schema that restricts a union-typed
element to one- and two-level restrictions of the union.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes XERCESC-2269.
UnionDatatypeValidator::isSubstitutableBy()only compared the candidatetype 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:typeand substitution groups.
The fix walks the candidate's base chain, as
DatatypeValidator::isSubstitutableBy()does, but only while the validatoris 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 == thistest is subsumed by the first iteration.Member-type handling is unchanged.
Test: new sample test
DOMCount4(CMake and autotools) runsDOMCount -n -s -f union-restriction.xmlon a schema that restricts aunion-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, whichoriginally 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.