Setting parameters

The most common use of a customization layer is to consistently set parameter values without having to enter them on the command line. Notice in the previous example how simple the command line is, even though two parameters are being set. If you have more than a couple of parameters you regularly use, you might be better off putting them into a customization layer. It simplifies the typing, and ensures you will not forget one.

The XSL syntax for setting parameter values within the stylesheet comes in two forms:

<xsl:param name="parametername" select="'parametervalue'"/>
<xsl:param name="parametername">parametervalue</xsl:param>

In the first form, the xsl:param element is empty and you enter the parameter value as the attribute value of the select attribute. As with all XML attribute values, it is enclosed in quotes (double quotes here). But it also has a second set of inner single quotes. That's to indicate that the parameter value is a string. This is necessary because an XSL parameter can also contain XML elements (called nodes in this context), and an unquoted string is treated as an element name that is expected to have some element content.


The most common mistake when specifying parameter values as select attribute values in a customization layer is to omit the inner quotes for a string value. You will not necessarily see any error message, and you'll be wondering why your parameter did not work. The second form avoids that mistake.

In the second form, the select attribute is not used. Instead, the content of the xsl:param element is the parameter value. It does not need to be enclosed in single quotes because content text is already treated as a string value.