In the past year I have worked a lot with AspDotNetStorefront which relies very heavily on the use of XSLT and XSLT extensions. When I first started working with it I found that the extensions provided with the product were insufficient. I added the ability to define additional extension assemblies in the web.config file. It is fairly easy to implement this pattern and it allows you to define as many extension assemblies as you need. In this case I would recommend not making this a web.config setting but instead using custom module settings. To make it work, you essentially need to gather 2 pieces of data for the extension: The extension class and the namespace to associate with the extension. Here is an example of one web.config entry for the DotNetNuke Marketplace:
<add name="DotNetNuke Extensions" type="DotNetNukeExtensions.DnnExtensions, DotNetNukeExtensions" namespace="urn:dnn" />
Again, keep in mind that the web.config storage is not important, just that we have an assembly qualified type name and an associated namespace. Now that we have a typename and namespace we can use
obj = Activator.CreateInstance(objType);
m_TransformArgumentList.AddExtensionObject(ext.Attributes["namespace"], obj);
to add the extension object (note: obviously there is more code associated with these two lines and it is a grossly simplified example).
The reason I prefer extension objects over scripts is that the compiled classes allow you full access to the entire DotNetNuke framework. It also means that I can use other extension classes like those defined in the EXSLT.net project.
In my XSLT files it is a simple matter to define my stylesheet to reference the namespace:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aspdnsf="urn:aspdnsf" xmlns:dnn="urn:dnn" exclude-result-prefixes="aspdnsf">
Then in my stylesheet I am free to call my custom extension methods at will:
< xsl:variable name="Images" select="dnn:GetImageUrls($ProductID, 'medium')" />
If I return an XpathNodeIterator from my extension method then I can further process the method results using XSLT. Typically I use this technique when I want to get some XML that I can further manipulate with my XSLT.
I have found that extensions allow you to do things with XSLT that would just be too difficult to do with pure XSLT, or to access data in a format that can be easily used in the XSLT.