Open StanimirIglev opened 3 weeks ago
Hi, I will insert a fix in the next release of the package.
The fix requires a change of these lines:
adding a part for delegating the validation/decode to a substitute:
if self.abstract:
if self.name not in self.maps.substitution_groups:
reason = _("can't use an abstract element for validation "
"unless it's the head of a substitution group")
yield self.validation_error(validation, reason, obj, **kwargs)
else:
for xsd_element in self.iter_substitutes():
if obj.tag == xsd_element.name:
yield from xsd_element.iter_decode(obj, validation, **kwargs)
return
I will extend also encoding part to process abstract elements and substitution (the tag matching is not so simple, because it depends by the convention used for decoded data).
Thank you for the contribution
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:
schema.xsd
):document.xml
):Expected 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:Environment:
xmlschema
version: 3.4.0Additional notes:
is_valid
andvalidate
).