Last active
June 7, 2017 01:52
-
-
Save jitanghu/9386625 to your computer and use it in GitHub Desktop.
Simple script to transform xml doc with specified xslt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import lxml.etree as et | |
import sys | |
USAGE = sys.argv[0] + " <template> <doc>" | |
if len(sys.argv) < 3: | |
print USAGE | |
sys.exit(-1) | |
template_path = sys.argv[1] | |
doc_path = sys.argv[2] | |
template_dom = et.parse(template_path) | |
doc_dom = et.parse(doc_path) | |
transform = et.XSLT(template_dom) | |
transfomed_dom = transform(doc_dom) | |
print(et.tostring(transfomed_dom, pretty_print=True)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment