XSLT Library


XSLT Library

xp 6.+ blue

This library provides basic XSLT rendering functionality to create pages and parts using XSLT as the templating language.

dependencies {
  include 'com.enonic.lib:lib-xslt:1.+'


To use this library in your JavaScript code, you first need to require it:

var xsltLib = require('/lib/xslt');

Then, you will need to find the view. For instance, if you have a part, Fruit, you resolve the part with:

var view = resolve('view/fruit.xslt');

All the variables used in the view must be gathered, from request objects, back-end storage or whatever source you want to use. These should be put into a JSon object that is sent to the render function:

var model = {
    fruits: [
            name: 'Apple',
            color: 'Red'
            name: 'Pear',
            color: 'Green'
var result = xsltLib.render(view, model);


This lib have only one method:


This will create a document, based on the template in the view, and the content in the model. Normally this is an HTML-document, but XSL may be used to create text-documents of any type.


  • view (object) Location of the view. Use resolve(..) to resolve a view.

  • model (object) Model that is passed to the view.


This library is a drop-in replacement for the library in Enonic XP released before 6.11.0. It can be used directly since it will work by using /lib/xslt, /lib/xp/xslt and /site/lib/xp/xslt.