Is it possible to pass a parameter to a stylesheet

I have a xslt stylesheet ready at design time. At runtime, I may want a little different stylesheet based on a runtime parameter. I could write the original stylesheet so that the output is determined by a xsl:variable. But how could I set the variable value at runtime? Is it possible? Any other way to do so?


XSLT processors do enable parameters setting at runtime. Syntax depends on code language (Java ? .net ? php ?).

In your xsl :

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version=“1.0” xmlns:xsl=“”>

<xsl:param name="myParam" select="'default value if no parameter is set" />

<xsl:template match="/">
	<xsl:value-of select="$myParam" />


Java :

javax.xml.transform.Transformer.setParameter(String name, Object value)



Hope this helps