A small program that uses Python to process XML transformations in the first few days to convert xml,xsl into HTML.
LIBXML2, so the LIBXML2 module must be installed before it can be used.
#-*-Coding:mbcs-*-#!/usr/bin/pythonimport libxml2, Libxsltclass compoundxml:def __init__ (self): Self._result = None self._xsl = None Self._xml = None def do (self, xml_file_name, xsl_file_name): Self._xml = L Ibxml2.parsefile (xml_file_name) if self._xml = = None:return 0 Styledoc = libxml2.parsefile (xsl_file_name) if Styledoc = = None:return 0 self._xsl = Libxslt.parsestylesheetdoc (styledoc) if self._xsl = = None: return 0 Self._result = Self._xsl.applystylesheet (Self._xml, None) def get_xml_doc (self): return to self. _result def get_translated (self): return self._result.serialize (' UTF-8 ') def save_translated (sel F, file_name): Self._xsl.saveresulttofilename (file_name, Self._result, 0) def release (self): "This Fu Nction must is called in the end. "' Self._xsl.freestylesheet () Self._xml.freedoc () Self._result.freedoc () self._xsl = None Self._xml = None Self._result = None if __name__ = = ' __main__ ': test = Compoundxml () test.do (' Test/test Xmlutil.xml ', ' test/testxmlutil.xsl ') print test.get_translated () test.save_translated (' test/testxmlutil.htm ') test . Release ()