diff --git a/Backend-libXML/Parser.py b/Backend-libXML/Parser.py index 1a93562..7dcb211 100644 --- a/Backend-libXML/Parser.py +++ b/Backend-libXML/Parser.py @@ -2,7 +2,7 @@ from lxml import etree from io import BytesIO -def format(source: str, prettify: bool) -> str: +def formatXML(source: str, prettify: bool) -> str: """Method used to format XML :param source: XML to format @@ -85,17 +85,17 @@ def xsd(source: str, xsd: str) -> bool: def xslt(source: str, xslt: str) -> str: """ - Method used to transformate XML string using XSLT + Method used to transform XML string using XSLT :param source: XML string to transform - :param xslt: XSLT string used to transformate XML + :param xslt: XSLT string used to transform XML :return: Result of transformation """ xslt_input = BytesIO(xslt.encode("utf-8")) - xslt_transform = etree.XSLT(etree.parse(xslt_input).getroot()) + xslt_transform = etree.XSLT(etree.parse(xslt_input)) document_input = BytesIO(source.encode("utf-8")) xml = etree.parse(document_input).getroot() - result = xml.xslt(xslt_transform).decode() - return result \ No newline at end of file + transformed = str(xslt_transform(xml)) + return formatXML(transformed, True) \ No newline at end of file diff --git a/Backend-libXML/main.py b/Backend-libXML/main.py index 46fe1fc..c0a962b 100644 --- a/Backend-libXML/main.py +++ b/Backend-libXML/main.py @@ -37,9 +37,9 @@ def process_xml(request: request, type: str) -> str: elif (type == "xpath"): response_json['result'] = Parser.xpath(data, process) elif (type == "prettify"): - response_json['result'] = Parser.format(data, True) + response_json['result'] = Parser.formatXML(data, True) elif (type == "minimize"): - response_json['result'] = Parser.format(data, False) + response_json['result'] = Parser.formatXML(data, False) else: raise ValueError("Valid operation types are: xsd, xslt, xpath")