Fixed #94 and done some refactoring #99

Merged
bema merged 10 commits from bema/fix/libxml_headers into master 2023-03-03 10:43:34 +01:00
Showing only changes of commit 7554fc43be - Show all commits

View File

@@ -78,9 +78,13 @@ def xsd(source: str, xsd: str) -> bool:
:param xsd: XSD schema to validate XML against :param xsd: XSD schema to validate XML against
:return: Message saying, if the validation was successful or not :return: Message saying, if the validation was successful or not
""" """
xml_schema = etree.XMLSchema(etree.XML(xsd))
xml = etree.XML(source) schema_input = BytesIO(xsd.encode("utf-8"))
xml_schema = etree.XMLSchema(etree.parse(schema_input).getroot())
document_input = BytesIO(source.encode("utf-8"))
xml = etree.parse(document_input).getroot()
if xml_schema.validate(xml): if xml_schema.validate(xml):
return "XML is valid." return "XML is valid."
else: else: