posted on: 2008-09-05 07:04:06
This is a simple lxml/xml rendering program
>This program will take an .xml, .xsl file from the command line and perform a transform. It defaults to a .html file output but you can add a third argument to have the end anything you want.
#!/usr/bin/env python import sys from lxml import etree """ xsltransform.py ./xsltransform.py [xmlfile] [xslfile] [optional ext] Transfroms an xml file via, xsl. """ if len(sys.argv)<4: ext ='html' else: ext = sys.argv[3] #load xml doc and parse xml_doc = open(sys.argv[1],'r') xml_tree = etree.parse(xml_doc) #load xsl doc parse and create a transform xsl_doc = open(sys.argv[2],'r') xslt_tree = etree.parse(xsl_doc) transform = etree.XSLT(xslt_tree) #write the output to a file. out = open('out.%s'%ext,'w') out.write(str(transform(xml_tree)))
Comments
create comment?