Posted By

sukantahazra on 09/08/10


Tagged

xslt python xml


Versions (?)

XSLT processing in python


 / Published in: Python
 

  1. import libxml2
  2. import libxslt
  3. import sys
  4.  
  5. if (len(sys.argv) != 4):
  6. print "Usage: "+sys.argv[0]+" xsltfile xmlfile outputfile"
  7. sys.exit(1)
  8.  
  9. styledoc = libxml2.parseFile(sys.argv[1])
  10. style = libxslt.parseStylesheetDoc(styledoc)
  11. doc = libxml2.parseFile(sys.argv[2])
  12. result = style.applyStylesheet(doc, None)
  13. style.saveResultToFilename(sys.argv[3], result, 0)
  14. style.freeStylesheet()
  15. doc.freeDoc()
  16. result.freeDoc()

Report this snippet  

You need to login to post a comment.