Schema validator reports the wrong child element as missing
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libxml2 (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Here's the repro script:
#!/usr/bin/env python3
import sys
from lxml import etree
XSD = """\
<xsd:schema xmlns:xsd="http://
<xsd:element name="Person" type="Person"/>
<xsd:complexType name="Person">
<xsd:sequence>
<xsd:element name="Name" type="xsd:string"/>
<xsd:element name="Role" type="xsd:string" maxOccurs="2"/>
<xsd:element name="Detail" type="xsd:string"/>
</xsd:sequence>
</xsd:
</xsd:schema>"""
XML = """\
<Person>
<Name>
<Role>
</Person>"""
print("%-20s: %s" % ('Python', sys.version_info))
print("%-20s: %s" % ('lxml.etree', etree.LXML_
print("%-20s: %s" % ('libxml used', etree.LIBXML_
print("%-20s: %s" % ('libxml compiled', etree.LIBXML_
print("%-20s: %s" % ('libxslt used', etree.LIBXSLT_
print("%-20s: %s" % ('libxslt compiled', etree.LIBXSLT_
schema = etree.XMLSchema
doc = etree.fromstrin
if not schema.
print(
# END OF REPRO SCRIPT
Here's the output:
Python : sys.version_
lxml.etree : (4, 9, 1, 0)
libxml used : (2, 9, 14)
libxml compiled : (2, 9, 14)
libxslt used : (1, 1, 35)
libxslt compiled : (1, 1, 35)
<string>
# END OF OUTPUT
It's clear from examining the schema and the XML document being validated that adding a second Role element is not necessary, and would do nothing to make the document valid. The correct assessment of the validation is that the required Details child element is missing.