Codesample for xml/xslt transforming

Jeremy Jones zanesdad at bellsouth.net
Tue Sep 9 16:27:41 CEST 2003


* Axel Straschil (axel at pizza.home.kosnet.com) wrote:

<snip>

> I've test.xml, test.xsl or two vars with the code
> and wan't to transform it. 
> Google just helped me for C ...


This code used to work (kinda ugly, though - sorry):


            from Ft.Xml.Xslt.Processor import Processor
            import Ft.Xml.InputSource 
            ##I was working with a DOM object here
            xml_data = dom.toxml()
            processor = Processor()
            f = open("rmkr.xsl",'r')
            xsl_data = f.read()
            f.close()
            processor.appendStylesheet(Ft.Xml.InputSource.DefaultFactory.fromString(xsl_data, "uri"))
            result = processor.run(Ft.Xml.InputSource.DefaultFactory.fromString(str(xml_data), "uri"))
            processor.reset()
            result_html = os.path.join(result_dir, "%s.html" % outfile_prefix)
            htmlfile = open(result_html, "w")
            htmlfile.write(result)
            htmlfile.close()

I haven't tested it recently to see if it still works.  It worked with FT under Python 2.1.


Jeremy Jones





More information about the Python-list mailing list