def Run(argv): (validate_flag, out_file, ignore_pis, top_level_params, stylesheets, source, trace_on_error, command_line_error) = ParseCommandLine(argv) out_file = out_file and open(out_file, 'w') or sys.stdout processor = Processor() import os try: from Ft.Lib import pDomlette BETA_DOMLETTE = os.environ.get("BETA_DOMLETTE") if BETA_DOMLETTE and not validate_flag: from Ft.Lib import cDomlette g_readerClass = cDomlette.RawExpatReader reader = cDomlette.RawExpatReader() elif validate_flag: reader = pDomlette.SaxReader(validate=1) else: reader = pDomlette.PyExpatReader() except ImportError: import minisupport reader = minisupport.MinidomReader(validate_flag) try: processor.setDocumentReader(reader) for sty in stylesheets: processor.appendStylesheetUri(sty) if source == '-': result = processor.runStream(sys.stdin, ignore_pis, topLevelParams=top_level_params) else: result = processor.runUri(source, ignore_pis, topLevelParams=top_level_params) except XsltException, e: s = cStringIO.StringIO() traceback.print_exc(1000, s) sys.stderr.write(s.getvalue()) sys.stderr.write(str(e) + '\n') sys.exit(-1)
def convert_spread(): xsltproc = Processor() xsltproc.appendStylsheetUri("templ.xsl") html = xsltproc.runUri("temp.xml")