[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: [xslt 2.0] Difference betwen functions and templat

Subject: Re: [xslt 2.0] Difference betwen functions and templates
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Thu, 19 Jul 2007 09:42:32 +0100
Re:  [xslt 2.0] Difference betwen functions and templat
On 7/19/07, Abel Braaksma <abel.online@xxxxxxxxx> wrote:
   6. If you want polymorphism (partially, only nr of arguments) you
must use a function

You can use import precedence with named templates to get single polymorphism eg:

"Specific.xslt" :

<xsl:import href="common.xslt"/>
	
<xsl:template match="/">
	<xsl:call-template name="commonTemplate"/>
</xsl:template>

<xsl:template name="poly">Specfic</xsl:template>


and then "Common.xslt" :


<xsl:template name="commonTemplate">
	<xsl:call-template name="poly"/>
</xsl:template>	

<xsl:template name="poly">Common</xsl:template>

The output is "Specific" because the named template "poly" in the
specific stylesheet has a higher import precedence than that in the
common stylesheet.

You can make the poly template in common pseudo-abstract by doing
something like:

<xsl:template name="poly">
 <xsl:message terminate="yes" select="'This stylesheet must be
imported by another stylesheet and cannot be run on its own...'"/>

cheers
andrew

--
http://andrewjwelch.com

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.