Python libxml2/ libxslt unlinkNode from transformed result produces memory-leak

184 views Asked by At

i've tried to transform an XML with libxslt and then unlink a Node from the transformed result, but i getting a memory exception. (I know that i can convert the xslt transformed result to a string and then parse it again to a document, but i need to process the result directly -> performance issues.)

My code:

# XSLT Transform
doc = libxml2.parseDoc(xml_string)
xsl_file_element = libxml2.parseFile('test.xsl')
xsl_transform = libxslt.parseStylesheetDoc(xsl_file_element)
xml_result_doc = xsl_transform.applyStylesheet(doc, {})    
xsl_transform.freeStylesheet()
doc.freeDoc()

# Unlink Node from XSLT-Transformed result
xml_result_root = xml_result_doc.getRootElement()
xml_result_root.unlinkNode()
xml_result_root.setTreeDoc(None)
xml_result_root.freeNode()
xml_result_doc.freeDoc()
0

There are 0 answers