以下 (a) 是否允许 (b) 有用
<xsl:template match="foo" name="bar">
</xsl:template>
(这意味着模板可以通过递归模板处理或直接从
<xsl:call-template name="bar"/>
触发。
最佳答案
简单地说,是的。我经常命名身份模板并使用 <xsl:call-template name="identity" />
直接调用它。 .
它是一种继承形式的有用工具;您可以定义一个模板来匹配一个节点,另一个处理该节点的派生,执行特定操作,然后调用更通用的模板。
例如:
<xsl:template match="animal" name="animal">
<!-- handle any animal related stuff here -->
</xsl:template>
<xsl:template match="dog">
<xsl:call-template name="animal" />
<!-- handle any dog specific stuff here -->
</xsl:template>
关于xslt - xslt 模板可以同时携带 name 和 match 属性吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6478163/