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:
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user