Skip to content
xsl:with-param

xsl:with-param

Passes a parameter to an xsl:call-template, xsl:apply-templates, xsl:next-match, xsl:apply-imports, or xsl:next-iteration instruction.

<xsl:call-template name="t">
  <xsl:with-param name="title" select="'Hello'"/>
</xsl:call-template>

The parameter value is supplied either via the select attribute (an XPath expression) or via a sequence constructor in the body. The receiving template, function, or iteration must declare a matching xsl:param with the same name; otherwise the value is silently ignored.

Attributes

Attribute Description
name Parameter name. Required.
select XPath expression for the value. If absent, the body of xsl:with-param provides the value.
as Sequence type the value is coerced to.
tunnel yes to mark the parameter as a tunnel parameter, passing through templates that don’t declare it.

Examples

Value as XPath expression:

<xsl:with-param name="count" select="count(item)"/>

Value as a sequence constructor (useful for fragments):

<xsl:with-param name="header">
  <h1>Generated</h1>
  <p>by goxslt</p>
</xsl:with-param>

Tunnel parameter passes through intermediate templates that don’t declare it:

<xsl:apply-templates select="section">
  <xsl:with-param name="theme" select="'dark'" tunnel="yes"/>
</xsl:apply-templates>