Pass a command line parameter to an XSL stylesheet

It’s possible depending on the parser. And Saxon does support it!!!

1) Declare parameter in the stylesheet:

<xsl:param name="x"/> (XSLT version 1.0)

<xsl:param name="x" as="xs:integer" required="yes"/> (version 2.0)

2) Invoke Saxon as

java -jar saxon8.jar source.xml style.xsl x=Atlanta

In my example, I wanted to loop through the list of metro areas and create a separate raw file for each area using only one general fieldmapper XSL. And it worked!

One thought on “Pass a command line parameter to an XSL stylesheet

Leave a comment