Principal XSLT module

The XSLT module that is called directly by Berlioz is the principal module. It is defined by your Berlioz configuration.


Usually, the principal XSLT module simply defines the output type using <xsl:output> and references other XSLT modules using <xsl:import> or <xsl:include>.

It should be kept as simple as possible.

Standard mapping

When using the standard mapping and standard file layout (e.g. with Kickstart), there is a principal module per group of services per output type.

Standard mapping
MatchesMedia typePrincipal XSLT module


Below are some examples taken from Berlioz base.

HTML principal module

This module assembles all the modules needed for an HTML output and defines the overall structure for a web page.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"

<!-- Import library modules first -->
<xsl:import href="lib/psml-beta7-3.xsl"/>

<!-- Import common modules second -->
<xsl:import href="common/app.xsl"/>
<xsl:import href="common/topbar.xsl"/>
<xsl:import href="common/header.xsl"/>
<xsl:import href="common/footer.xsl"/>
<xsl:import href="common/psml.xsl"/>

<!-- Import modules specific to each service last -->
<xsl:import href="default/home.xsl"/>
<xsl:import href="default/specimen.xsl"/>

<!-- General Output properties. -->
<xsl:output method="html" encoding="utf-8" indent="yes" undeclare-prefixes="no" media-type="text/html"/>

  Main HTML structure of every page.

  Each part is using a separate template mode.
  The actual templates for each mode are defined elsewhere to keep this module 
  clean and simple.
<xsl:template match="/">
<!-- Display the HTML5 Doctype -->
<xsl:text disable-output-escaping="yes"><![CDATA[<!doctype html>
]] ></xsl:text>
    <xsl:apply-templates mode="head"/>
    <xsl:apply-templates mode="topbar"/>
    <xsl:apply-templates mode="header"/>
    <xsl:apply-templates mode="main"/>
    <xsl:apply-templates mode="footer"/>
    <xsl:apply-templates mode="bottom"/>


XML principal module

This module returns the same as the source XML.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="2.0"

<!-- XML properties -->
<xsl:output method="xml" media-type="application/xml" indent="no" encoding="utf-8" />

<!-- Default -->
<xsl:template match="/root">
<xsl:sequence select="."/>


JSON principal module

The XML generated by this template should map to a simple JSON tree model following the Aeson format.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"

<!-- JSON output properties -->
<xsl:output method="xml" media-type="application/json" encoding="utf-8"/>

<!-- Default -->
<xsl:template match="/root">

<!-- Match service 'home' -->
<xsl:template match="/root[@service='home']">
  <!-- Return an object with property 'greeting' -->
  <json:object greeting="{//greeting}" />


Created on , last edited on