Re: [xslt 2.0] Difference betwen functions and templat
I think I believed the wrong term, I meant method overloading instead of polymorphism. I don't agree with your statement that single polymorphism is what is offered by XSLT. I
POLYMORPHISM If such a thing would exist it might look something like this:
So to recreate your example using named templates and import precedence:
Animal.xslt <xsl:template name="sayName"> <xsl:value-of select="$name"/> </xsl:template>
And then Dog.xslt: <xsl:import href="animal.xslt"/>
<xsl:variable name="name" select="'Dog'"/> <xsl:template match="/"> <xsl:call-template name="sayName"/> </xsl:template>
And the equivalent Cat.xslt would just have the different variable: <xsl:variable name="name" select="'Cat'"/>
The Animal stylesheet is kind-of abstract in that it won't run on it's own because it lacks a declaration for $name.
Perhaps in the future if "compiled stylesheet modules" become a reality then abstract and final modifiers for templates and functions will be included too.
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format