Testing XML stylesheets from unix or cygwin with xsltproc
Facts - XSLT
Thursday, 03 June 2010 22:12

From the cygwin or unix command line prompt it is easy to test your xsl files. The program to use is xsltproc. Use the following command line to transform an xml file with your stylesheet:

$ xsltproc your-transform.xsl your-xml.xml

It is in the user help but don't forget to add extra quotes to the value of any parameters. Or use option stringparam instead of option param. Surrounding the parameter name with extra quotes does not matter. With the following command lines xsltproc pick up the value testvalue for the parameter:

$  xsltproc.exe --param 'testparam' "'testvalue'" test.xslt test.xml
$  xsltproc.exe --param testparam "'testvalue'" test.xslt test.xml
$  xsltproc.exe --stringparam 'testparam' "testvalue" test.xslt test.xml
$  xsltproc.exe --stringparam testparam 'testvalue' test.xslt test.xml
$  xsltproc.exe --stringparam testparam testvalue test.xslt test.xml

With the following command lines xsltproc does not pick up any value of the parameter:

$  xsltproc.exe --param testparam 'testvalue' test.xslt test.xml
$  xsltproc.exe --param testparam "testvalue" test.xslt test.xml
$  xsltproc.exe --param testparam testvalue test.xslt test.xml

At this moment (August 2011) xsltproc only deals with XSLT 1.0. Use the latest platform independent Saxon XSLT engine from Sourceforge to transform xml with XSLT 2.