Passing parameters to XSLT stylesheets at runtime

Parameter can be passed at runtime when using the built-in XSLTRANSFORM function to convert XML documents.

An important feature of the XSLTRANSFORM function is its ability to accept XSLT parameters at runtime. In the absence of this ability you would need to maintain a large library of XSLT stylesheets, one for each variant of a query against the XML data; or, you would need to manually edit your stylesheets for each new kind of query. Parameter passing allows you to design generic stylesheets that can be left alone, while you accumulate a library of parameter files or potentially build them on the fly.

The XSLT parameters are contained in a separate XML document, for instance:
<?xml version="1.0"?>
<params xmlns="http://www.ibm.com/XSLTransformParameters">
        <param name="headline">BIG BAZAAR super market</param>
        <param name="supermarketname" value="true"/>
</params>
Each <param> element names a parameter and contains its values, either within the value attribute or for longer values, within the element itself. The preceding example shows both variations.
The parameters allowed by the XSLT template file are defined as variables using the <xsl:param> element, as follows:
<xsl:param name="headline"/>
<xsl:param name="supermarketname"/>
In this example you can call the $headline or $supermarketname variables anywhere inside the stylesheet and they will contain the data defined in the parameter file (in this case the string "BIG BAZAAR super market" and the value "true", respectively.