Created
August 16, 2012 13:26
-
-
Save lawlesst/3370069 to your computer and use it in GitHub Desktop.
XSLT with saxon in Jython
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
""" | |
Use saxon to do XSLT with Jython | |
See http://codingwithpassion.blogspot.com/2011/03/saxon-xslt-java-example.html | |
Pass in arguments | |
- 1 xslt | |
- 2 xml source | |
- 3 xml output | |
""" | |
from java.io import File; | |
from javax.xml.transform import Transformer; | |
from javax.xml.transform import TransformerFactory; | |
from javax.xml.transform.stream import StreamResult; | |
from javax.xml.transform.stream import StreamSource; | |
import os | |
import sys | |
xslt = File(sys.argv[1]) | |
tFactory = TransformerFactory.newInstance() | |
transformer = tFactory.newTransformer(StreamSource(xslt)) | |
out = transformer.transform( | |
StreamSource(File( | |
sys.argv[2] | |
)), | |
StreamResult( | |
File(sys.argv[3]) | |
) | |
) | |
print out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment