|
|
1
3
将文本作为
XSL Transformations 11.6 Passing Parameters to Templates
参数使用
此示例为带参数的编号块定义命名模板,以控制编号的格式。
|
|
2
1
可以将其他字符串数据作为参数传递: <xsl:with param name=“pneededtext”选择“'--123abc'”/> 在调用的模板中定义此参数: <xsl:param name=“pneededtext”as=“xs:string”>
或者,你可以定义
全球的
|
|
3
1
> Since the parameter numbers are > undefined (the tables can have > different number of cells) i can't use > a standard parameters for the > templates and used delimited string. 实际上,情况并非如此。 下面是一个 <xsl:with-param/>,其主体是一个节点集,该节点集可以由不同调用上的不同数量的元素组成: <xsl:template match="/">
<xsl:variable name="vrtfTParams">
<p>xxx</p>
<p>yyy</p>
<p>zzz</p>
</xsl:variable>
<xsl:call-template name="makeTable">
<xsl:with-param name="pTParams"
select="msxsl:node-set($vrtfTParams)/*"/>
</xsl:call-template>
</xsl:template>
“maketable”模板可以如此简单: <xsl:template name="makeTable">
<xsl:param name="pTParams"/>
<table>
<tr>
<xsl:for-each select="$pTParams">
<td>
<xsl:value-of select="."/>
</td>
</xsl:for-each>
</tr>
</table>
</xsl:template>
msxsl:node-set()扩展函数可用于Microsoft xslt处理器。大多数其他处理器都支持exslt:node-set()扩展函数(Microsoft的.NET xslt处理器xslcompiledtransform也支持它)。 如果$vrtftparams的内容不是动态生成的(与本例中的情况一样),则不需要xxx:node-set()函数,因为可以这样传递<xsl:variable>的内容: <xsl:with-param name="pTParams"
select="document('')/*/xsl:variable[name()=vrtfTParams)/*"/>
这里必须全局定义$vrtftparams(xsl:template/>的子级)。 在xslt 2.0(和xpath2.0)中,没有rtf类型,根本不需要xxx:node-set()扩展函数。 希望这有帮助。 干杯, 迪米特里诺瓦切夫 |
|
|
J_Cus504 · 在单匹配语句中使用身份变换和多谓词来沉默节点 8 月前 |
|
|
surge3333 · 使用PowerShell构建XML 8 月前 |
|
|
Sandeep · XSLT代码,用于根据条件提取元素值 10 月前 |
|
|
Reto · XSLT 3.0突发流-如何存储/获取另一个分支的值 10 月前 |
|
Ian Kemp · 如何从SelectXml调用本机XPath函数? 10 月前 |