-
Notifications
You must be signed in to change notification settings - Fork 81
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description:
The xmlschema library incorrectly invalidates XML documents that use elements from a substitution group whose head is abstract. According to the W3C XML Schema specifications, substitution group members can appear in the instance document even if the head element is abstract.
To reproduce:
- XML Schema (
schema.xsd):
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="abstractSubgroupHead" type="xs:integer" abstract="true"/>
<xs:element name="subgroupMember" type="xs:positiveInteger" substitutionGroup="abstractSubgroupHead"/>
</xs:schema>- XML document (
document.xml):
<subgroupMember>1</subgroupMember>- Validate:
xmlschema-validate --schema schema.xsd document.xml -vExpected behavior:
The XML document should be validated successfully because subgroupMember is a global element; thus, a valid root within the instance document.
Actual behavior:
The xmlschema library reports the following error:
document.xml is not valid
failed validating <Element 'subgroupMember' at 0x7f6285136110> with XsdElement(name='abstractSubgroupHead', occurs=[1, 1]):
Reason: cannot use an abstract element for validation
Schema component:
<xs:element xmlns:xs="http://www.w3.org/2001/XMLSchema" name="abstractSubgroupHead" type="xs:integer" abstract="true" />
Instance type: <class 'xml.etree.ElementTree.Element'>
Instance:
<subgroupMember>1</subgroupMember>
Path: /subgroupMember
Environment:
xmlschemaversion: 3.4.0- Python version: 3.11.8
Additional notes:
- The bug happens regardless of whether one uses the CLI or the API (
is_validandvalidate). - I believe the problem occurs only when the substitution element is used as a root element of the instance document, i.e., if there is another global element with complex type, which contains a reference to the abstract subgroup head, the validation is correct.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working