libXML now returnes info why XML is not valid (#218)

Co-authored-by: Adam Bem <adam.bem@zoho.eu>
Reviewed-on: #218
Reviewed-by: Mikolaj Widla <widlam@noreply.example.com>
This commit is contained in:
2023-06-05 14:40:03 +02:00
parent a8e902e910
commit 86b3572003

View File

@@ -77,10 +77,12 @@ def xsd(source: str, xsd: str) -> bool:
document_input = BytesIO(source.encode("utf-8"))
xml = etree.parse(document_input).getroot()
if xml_schema.validate(xml):
return "XML is valid."
else:
return "XML is NOT valid."
try:
xml_schema.assertValid(xml)
return "XML is valid"
except etree.DocumentInvalid as e:
return str(e)
def xslt(source: str, xslt: str) -> str: