Today I needed to tweak (i.e. maintain) an XML Stylesheet (XSL-T) that was written by some team mate. Since the stylesheet runs inside a Java and XML application, it uses Xalan and some Java function-calls, like so:
I wanted to make the changes with XMLSpy, since that would allow me to have the test-instance, the source- and target-schema and the stylesheet all open at once and be able to do transformation and validation of the result with a keypress – which is a good thing, when you’re incrementally changing and checking. (Yes, I would find my way round on the command-line, but for some tasks IDEs are just nicer, and this I consider one of them.)
The problem now is that XMLSpy 2004 does have an internal XSL-T transformer, but this doesn’t know about the Java parts. Luckily, XMLSpy can be configured to use an external transformer, the option is under
Tools > Options : XSL, and looks like this:
As you perhaps already guessed from the screenshot, we need to make Xalan callable on the command-line. To achieve this, I wrote a small
.cmd-File that hides the Java setup from the world and calls the appropriate class with the correct parameters. Here, Xalan is quite supportive, as it provides a class to call from the command-line. Thus, we only need to wrap up the libraries and be done! Here’s the
@echo off setlocal set XALAN_LIBS=D:\jars\xalan-j_2_7_0 java -cp %XALAN_LIBS%\serializer.jar;%XALAN_LIBS%\xalan.jar;%XALAN_LIBS%\xercesimpl.jar;%XALAN_LIBS%\xml-apis.jar org.apache.xalan.xslt.Process -IN %1 -OUT %2 -XSL %3 endlocal
I sorted the input parameters in the order XMLSpy expects them, so in XMLSpy we can go straight forward with %1 %2 %3.
And with this you can use Xalan as a transformation engine in XMLSpy 2004. Newer versions of XMLSpy, I hear, come with Xalan preconfigured, but in case you’re still at 2004 this will do.