XSLT PI Parameters
Overview
XSLT supports the concept of passing parameters to a stylesheet when executing it. This is currently possible when using the XSLTProcessor in javascript. However when using an <?xml-stylesheet?> processing instruction (PI) there is currently no way to provide parameters.
To solve this two new PIs are proposed, <?xslt-param?> and <?xslt-param-namespace?>. Both PIs can contain "pseudo attributes" the same way that the xml-stylesheet PI does.
The following document passes the two parameters "color" and "size" to the stylesheet "style.xsl".
<?xslt-param name="color" value="blue"?> <?xslt-param name="size" select="2"?> <?xml-stylesheet type="text/xsl" href="style.xsl"?>
Processing instructions
The xslt-param PI supports 4 pseudo attributes:
- name
The local-name part of the parameter name. - namespace
The namespace of the parameter name. - value
The value of the parameter. - select
An XPath expression for the parameter. The resulting value can be of any type.