Repository navigation
🐛 fix(xsd): validate every base type's content - #2135
Merged
Merged
Conversation
A complex type derived by extension in two or more steps was matched only against the particle of its nearest base. The particles of the types further up the chain were dropped, so a document that omitted the elements those types require was accepted, and a complete document was rejected. The content is now the particles of the whole base chain, root-most type first, followed by the type's own particle. Child elements are typed by the declarations from every one of them. An xs:all that extends a base with content is now a schema error, as XSD 1.0 requires. Before, the base's particles were dropped in that case as well.
Merging this PR will not alter performance
Comparing Footnotes
|
The check that rejects an xs:all added to a base with content asks whether a group ref names an xs:all group. No test extended a base with content by a group ref to a sequence group, so the branch that accepts such a group was never run. The new test covers it, with a document that satisfies the base and the group and one that omits an element of the group.
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.
Validation of a type derived by extension in two or more steps checked only the particle of its nearest base. Elements that the grandparent type requires were not enforced, so a document missing them was accepted, and a complete document could be rejected. ✅ After this change every particle along the base chain applies, so a document must satisfy all of them.
Architecture
XML Schema Part 1 defines the content of an extension as the base's content followed by the extension's own particle, applied recursively. The effective content of a type now collects every inherited particle, root-most type first. Children are matched against that list in order, each particle starting where the previous one stopped, and element declarations from every particle are collected for type checks. Children that an inherited type declares are type-checked as well.
An extension that adds an
xs:allcontent model to a base with content is now rejected when the schema compiles. XML Schema Part 1 limits anxs:allgroup to the only particle of a content model, and the old matcher dropped the base's particles in that case.Behavior changes
xs:allcontent model to a base with content raisesValueErrorwhen the schema is compiled.xs:allcontent model extended without particles, and a type that extends a base with no content, behave as before.Fixes #1716.