RE: Calling a template from within an template

Subject: RE: Calling a template from within an template
From: Mike Brown <mbrown@xxxxxxxxxxxxx>
Date: Fri, 5 Nov 1999 14:36:11 -0700
> Do I have to repeat that code for every single element
> or can I store that code in a seperate (named? )
> template and then include or call that template from
> within the template.
> [...]
> Here is what I really want to do:
> 
> <xsl:template match="h1">
> 	<h1>
>    	    <xsl:call-template name="stdTemplate"/>        	
> 	</h1>
> </xsl:template>
> 
> <xsl:template match="h2">
> 	<h2>
>          <xsl:call-template name="stdTemplate"/>        	
> 	</h2>
> </xsl:template>

Easy. Hopefully you are using an XSLT processor that implements these
instructions:

<xsl:template match="h1|h2|whatever">
   <xsl:element name="name(.)">
      <xsl:call-template name="stdTemplate">
         <xsl:with-param name="currentnode" select="."/>
      </xsl:call-template>
   </xsl:element>
</xsl:template>

<xsl:template name="stdTemplate">
   <xsl:param name="currentnode"/>
   ...stuff that processes currentnode goes here...
</xsl:template>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread