XSLT <xsl:param> 元素
定义和用法
<xsl:param> 元素用于声明局部或全局参数。
注释:如果在模板内声明参数,就是局部参数,如果作为顶层元素来声明,就是全局参数。
语法
<xsl:paramname="name"select="expression"><!-- Content:template --></xsl:param>
属性
| 属性 | 值 | 描述 |
|---|---|---|
| name | name | 必需。规定参数的名称。 |
| select | expression | 可选。规定 XPath 表达式,该表达式是参数的默认值。 |
实例
例子 1
<?xml version="1.0" encoding="utf-8"?><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>