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!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s