Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use custom template name in <xsl:apply-templates>

Tags:

xslt

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.

like image 277
ThiefMaster Avatar asked Jan 10 '11 14:01

ThiefMaster


2 Answers

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.

like image 98
Dimitre Novatchev Avatar answered Sep 20 '22 06:09

Dimitre Novatchev


why not use xsl:call-template ?

like image 30
dvhh Avatar answered Sep 20 '22 06:09

dvhh