Subject: Re: [xsl] minimally overriding functions in XSLT 2.0 From: Louis-Dominique Dubeau <ldd@xxxxxxxxxxxx> Date: Wed, 09 Jan 2013 13:29:01 -0500 |
On Wed, 2013-01-09 at 17:31 +0000, Michael Kay wrote: > Unfortunately there is no equivalent of super() that allows you to > invoke an overridden function from an overriding function. > > This omission is being rectified in XSLT 3.0 (but not yet implemented in > Saxon). Michael, thank you for the information. I do not know how fast we'll get to stable implementations of XSLT 3.0 and how fast TEI will move to XSLT 3.0. So for the sake of seeing how someone who has to work with 2.0 could try to work around this limitation, let me list the solutions that came to my mind. I'm going to posit the following case: - base.xsl defines a function named foo - derived.xsl wants to override foo minimally. I'm not dealing here with copyright issues, which could be problematic with some of the solutions I'm listing. In the following, the XML is all typed without the benefit of any validation whatsoever. I've reread myself but egregious errors could have slipped by. 1. The foo function in derived.xsl opens base.xsl and searches for the foo function, parses it, and ... Ok, this won't work without using extension functions or require so much work that it would amount to writing an XSLT parser in XSLT. 2. Preprocessing. Create a file named derived-in.xsl which (roughly speaking) contains something like: <xsl:import href="base.xsl"/> <xsl:function name="foo-base"/> <xsl:function name="foo"> ... do the work ... ... call foo-base when we want to use the old behavior of foo as defined in base.xsl ... </xsl:function>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] minimally overriding func, Michael Kay | Thread | [no subject], Unknown |
Re: [xsl] minimally overriding func, Michael Kay | Date | Re: [xsl] Re: Pearls of XSLT and XP, Wolfgang Laun |
Month |