Reputation: 2193
I'm learning XSLT and I find that Xalan is really helpful. I know that Xalan can be used through commandline commands, like:
java -classpath .;%XALAN_JAR% org.apache.xalan.xslt.Process -IN input.xml -XSL transform.xsl -OUT output.xml
However, how can I call this method from java code? Just like:
process(input.xml, transform.xsl, result.xml)
Thanks!
Upvotes: 0
Views: 429
Reputation: 76943
callFunction seems to be the function you are looking for.
Params
Try it by passing the name of the function you want to call and the arguments you intend to pass.
Upvotes: 0
Reputation: 163587
Java supports a transformation API sometimes referred to as JAXP. There's a tutorial on it here:
http://docs.oracle.com/javase/tutorial/jaxp/index.html
JAXP has also been implemented by other Java-based XSLT engines, though the only two in really common use are now Xalan and Saxon.
If you're new to XSLT, you need to be aware that the language has come on a long way since XSLT 1.0, which is what Xalan implements. XSLT 2.0 provides many useful enhancements such as user-written functions, date and time handling, regular expressions, multiple output files, and grouping. To use those features you'll need to move from Xalan to Saxon. The open-source version of Saxon (Saxon-HE 9.7) can be found via http://saxon.sf.net/.
Upvotes: 0