I am validating a an XML file which contains:
<TEST />
and I validate like the following:
import lxml as l
def validate(xml_path, xsd_path):
schema_doc = l.parse(xsd_path)
schema = l.XMLSchema(schema_doc)
xml_doc = l.parse(xml_path)
result = schema.validate(xml_doc)
if result:
return True
else:
print("Validation error(s):")
for error in schema.error_log:
print(xml_path + " | Line {}: {}".format(error.line, error.message))
return False
validate(xml_path, xsd_path)
But I get an error pointing to the line where there is an empty tag <TEST />
and I don’t know why.
The complete error message is this:
Line 381: Element '{namespace}TEST': [facet 'pattern'] The value '' is not accepted by the pattern '[a-zA-Z][a-zA-Z0-9_]*'.
what is this exactly?
I tried to find out why, but with no clue really as the empty element is a valid one.