Custom XSLT offline with xslt-facade

Creating Custom XSLT Files Offline

The process of working with XSLT files for Portfolio Templates and Forms can be laborious to implement when needing to continually upload materials and preview them in a running Sakai installation. U-M has developed a utility to help make this process more manageable. It is called xslt-facade since it provides a façade for the runtime support of Sakai/OSP (by way of the XsltFunctions extension). It allows the XSL files to be created and run offline without any changes, to accelerate the process and afford the use of tools like a debugger.

Note that a document that walks you through the process of creating alternate form renderers (custom renderers) using xslt-facade is available at Creating Custom Renderers.

The Problem

Stylesheets used for OSP typically include the XsltFunctions extension like this (note xmlns:sakaifn):

<xsl:stylesheet version="1.0"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:sakaifn="org.sakaiproject.metaobj.utils.xml.XsltFunctions"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xmlns:osp="http://www.osportfolio.org/OspML"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

These stylesheets then use the extension for things like looking up URLs for materials from resources, inserting the code for loading the rich text editor, and some others. Here is an example call to load the editor:

<xsl:value-of select="sakaifn:getRichTextScript($name, $currentSchemaNode)" disable-output-escaping="yes" />

When running within a Sakai instance, these work fine. However, when working with these files offline within, e.g., <oXygen/>, the extension is not available and causes any attempted transformations to fail. Removing the extension declaration and the calls to the various functions to test offline is tedious and error prone when uploading the files back to the server to test online.

The Solution

The xslt-facade JAR is a single file that provides an offline replacement for the runtime infrastructure of a Sakai instance. It is easy to use the extension from <oXygen/> or other Java-based methods of transformation (such as a custom Xalan loader). The code is licensed under the ECL v2 (the same as Sakai) and is available in contrib. There is also a compiled copy of v1.0 attached to this page.

Source code: https://source.sakaiproject.org/contrib/botimer/xslt-facade/trunk/

Compiled extension JAR: xslt-facade-1.0.jar