XSLT processing in python


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.