I am on OSX Snow Leopard (10.6.2) I can install anything I need to. I would preferably like a Python or Java solution. I have searched on Google and found lots of information on writing my own program to do this, but this is a just a quick and dirty experiment so I don't want to invest a lot of time on writing a bunch of code to do this, I am sure someone else has done this already.
views:
307answers:
7
+4
A:
Use lxml
. It is very easy to use and very fast. It can work with XPath and includes a XSLT transformer.
nosklo
2010-03-26 20:58:30
+3
A:
If I assume correctly that you want to supply a stylesheet and an XML document then Xalan-J has a command line feature you can use to do this:
http://xml.apache.org/xalan-j/commandline.html
which can be invoked with:
java org.apache.xalan.xslt.Process -IN foo.xml -XSL foo.xsl -OUT foo.out
Jon
2010-03-26 20:59:52
+1
A:
Have you seen XMLStarlet (an XML command line toolset) ? It does lots of XML-related querying transformation, and in particular:
xml tr --help
XMLStarlet Toolkit: Transform XML document(s) using XSLT
Usage: xml tr [<options>] <xsl-file> {-p|-s <name>=<value>} [ <xml-file-or-uri> ... ]
where
<xsl-file> - main XSLT stylesheet for transformation
<xml-file> - input XML document file name (stdin is used if missing)
<name>=<value> - name and value of the parameter passed to XSLT processor
-p - parameter is XPATH expression ("'string'" to quote string)
-s - parameter is a string literal
Further documentation here.
Brian Agnew
2010-03-26 21:01:42
+2
A:
I'd recommend Saxon, which can be run from the command line like so:
java -jar /path/to/saxon.jar xmlfile xslfile
Will McCutchen
2010-03-26 21:02:38
you are right OSX Snow Leopard 10.6.2 already has this installed, so it gets the check mark!
fuzzy lollipop
2010-03-27 19:26:38
A:
I have used Saxon 6.5 for years for command line transformations. (Java, XSLT 1)
An excellent fallback if a native solution is not available.
Thorbjørn Ravn Andersen
2010-03-29 22:46:30