+ styledoc = libxml2.parseFile(filepath)
+ style = libxslt.parseStylesheetDoc(styledoc)
+ result = style.applyStylesheet(doc, None)
+ if (output_xpath_filter):
+ p = result.xpathNewContext()
+ xpath_result = p.xpathEval(output_xpath_filter)
+ if (xpath_result == []):
+ raise Exception("Could not apply processor %s."%processor)
+
+ stylesheet_result = xpath_result
+ p.xpathFreeContext()
+ else:
+ stylesheet_result = result #style.saveResultToString(result)
+
+ style.freeStylesheet()
+ #doc.freeDoc()
+ #result.freeDoc()
+
+ return stylesheet_result
+
+ def wrap_up(self, doc):
+ filepath = os.path.join(sfatables_config, 'processors', self.final_processor)
+
+ if not os.path.exists(filepath):
+ raise Exception('Could not find final rule filter')
+
+ styledoc = libxml2.parseFile(filepath)