Latest web development tutorials

XSLT <xsl: with-param> element

XSLT Elements Reference Manual Complete XSLT Element Reference Manual

Definition and Usage

<Xsl: with-param> element defines the parameters passed to the template values.

Note: <xsl: with-param> value of the name attribute of the element must be <xsl: param> element name matches otherwise ignored <xsl: with-param> element.

Note: <xsl: apply-templates> and <xsl: call-template> both allow the use of <xsl: with-param> element.

Tip: You can <xsl: with-param> element or content through select attributes to the parameter assignment!


grammar

<xsl:with-param
name="name"
select="expression">

<!-- Content:template -->

</xsl:with-param>

Attributes

属性 描述
name name 必需。规定参数的名称。
select expression 可选。定义参数的值的 XPath 表达式。

Example 1

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:variable name="xx">
<html>
<body>
<xsl:call-template name="show_title">
<xsl:with-param name="title" />
</xsl:call-template>
</body>
</html>
</xsl:variable>

<xsl:template name="show_title" match="/">
<xsl:param name="title" />
<xsl:for-each select="catalog/cd">
<p>Title: <xsl:value-of select="$title" /></p>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>


XSLT Elements Reference Manual Complete XSLT Element Reference Manual