[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] minimally overriding functions in XSLT 2.0

Subject: Re: [xsl] minimally overriding functions in XSLT 2.0
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Wed, 09 Jan 2013 17:31:34 +0000

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 Kay

On 09/01/2013 16:56, Louis-Dominique Dubeau wrote:
Dear List Members,

I've searched the FAQ and the archive but did not find this specific
topic discussed.

The general issue here is customizing the behavior of stylesheets while
avoiding as much as possible code duplication. The way I typically
customize the behavior of a stylesheet that I should not alter (for
whatever reason) is to create a new stylesheet which imports the base
stylesheet, and then I override what I need.

Minimally overriding the functionality of templates imported from the
base stylesheet is trivial: it amounts to detecting the condition I care
about, producing the right output for this case, and calling
<xsl:apply-imports/> for all cases where the base stylesheet does the
right thing. (And it can be even simpler than this.)

There does not seem to be an equivalent way to achieve this when it
comes to overriding functions. I can override a function defined in the
base stylesheet but there is no mechanism that I can see that would
allow the overriding function to call the overridden function. So I have
to copy most of the overridden function into the overriding function if
I want to preserve functionality for most but not all cases that the
overridden function already handles. So I can override, but not

Maybe there's something I've missed somewhere in the XSLT specs? I
believe the issue is with XSLT 2.0 itself but in case it matters I'm
using teitodocx, which in turn uses Saxon-HE from Saxonica to
do the XSLT processing.

Thank you,

Current Thread