Use custom template name in

2019-06-22 05:07发布

问题:

Currently I have this code which calls the "user" template for each user node.

<xsl:for-each select="./user|./UnformatedUser">
  <xsl:apply-templates select=".">
    <xsl:with-param name="span"/>
  </xsl:apply-templates>
</xsl:for-each>

However, I now want to use a template named "fulluser" for all users. I've tried adding name="fulluser" to the <xsl:apply-templates> tag but it didn't work.

回答1:

The <xsl:apply-templates> instruction doesn't use a template name to select a template for execution on a particular node. It only uses the match pattern of templates when deciding which template to select.

To select for execution a template by name, use the <xsl:call-template> instruction.



回答2:

why not use xsl:call-template ?



标签: xslt