Another config file (check here for /config/Dashboard.config) that can be found in the /config folder of umbraco is the xslExtensions.config.

This file can be used to setup custom xslt extensions.

If you are not familiar with xslt extensions here is a brief intro:

With xslt extensions you can call static .net methods from xslt.

When editing an xslt file and inserting a value.


You get the option to “get extensions”.


Hitting the button will display a new modal that will list all xslt extensions and their methods.

Default umbraco has a couple of xslt extensions .


The most used one would probably be umbraco.library:NiceUrl(Int32 nodeID) , this takes a node id and will output the url of that node.



Using /config/xslExtensions.config you can also add custom xslt extensions.

Lets look at an example, the blog package for umbraco 4 comes with an xslt extension to get the gravatar image based on an email address.

So step 1 is to write the .net code that can be used. This is just a static method.


using System;
using System.Collections.Generic;
using System.Web;
namespace Umlaut.Umb.Blog
    public class BlogLibrary
        /// <summary>
        /// Gets the gravatar.
        /// </summary>
        /// <param name=”email”>The email.</param>
        /// <param name=”size”>The size.</param>
        /// <param name=”defaultImage”>The default image.</param>
        /// <returns></returns>
        public static string getGravatar(string email, int size, string defaultImage)
            System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] result = md5.ComputeHash(System.Text.Encoding.ASCII.GetBytes(email));
            System.Text.StringBuilder hash = new System.Text.StringBuilder();
            for (int i = 0; i < result.Length; i++)
            System.Text.StringBuilder image = new System.Text.StringBuilder();
            image.Append(“gravatar_id=” + hash.ToString());
            image.Append(“&amp;size=” + size.ToString());
            return image.ToString();


Next step (after dropping the assembly in the bin) is to setup the xslExtensions.config file.

<?xml version=”1.0″ encoding=”utf-8″?>
  <ext assembly=”\bin\Umlaut.Umb.Blog” type=”Umlaut.Umb.Blog.BlogLibrary” alias=”BlogLibrary”>

So you need a new ‘ext’ node with the following attributes:

  • assembly
  • type
  • alias

If the settings are correct it should appear (with the alias setup in the config file) in the xslt extensions modal


Last thing todo before you can use it is to declare the namespace.

    exclude-result-prefixes=”msxml umbraco.library BlogLibrary”>

3 Comments so far

  1. Thomas Höhler on March 11th, 2009

    Hi Tim,

    another really usefull addon. Thanks for shareing.


  2. Aaron Powell on March 11th, 2009

    Just a note to people who like to have closed class design, you cannot hide the default constructor of an XSLT extension, you must ensure that you have constructor which takes 0 arguments (and is public).

    Made that mistake myself! :P

  3. Ismail on March 12th, 2009


    I got caught with when doing xslt extension by making my class static. The members have to be static but not the class!


Leave a Reply