libXML now returnes info why XML is not valid

This commit is contained in:
2023-06-05 14:25:25 +02:00
parent 89517a6821
commit 1ddf06a830

View File

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