Standard mapping

The standard mapping defines which file extensions are associated with Berlioz in a Web application.  It is the Servlet mapping used by Kickstart.

Rationale

The standard mapping assumes that

  • a group of services will share the same templates and should therefore
  • HTML, XML and JSON output may be generated from Berlioz
  • Output types should be based on the file extension
  • The raw service output may be needed for development

Mapping 

Standard mapping
MatchesMedia typePrincipal XSLT module
*.htmltext/html/WEB-INF/xslt/html/[group].xsl
*.jsonapplication/json/WEB-INF/xslt/json/[group].xsl
*.xmlapplication/xml/WEB-INF/xslt/xml/[group].xsl
*.srcapplication/xmlno transformation

 

Alternatives

The alternative configurations requires editing the Web descriptor /WEB-INF/web.xml

Prefix based mapping

The most common configuration is to map the Berlioz servlet to file extensions, so that it will be invoked whenever the request URL has that extension. But Berlioz would also be mapped to a prefix instead.

<!-- HTML servlet mapped to prefix -->
<servlet-mapping>
  <servlet-name>BerliozHTML</servlet-name>
  <url-pattern>/html/*</url-pattern>
</servlet-mapping>

Other extensions

The Berlioz servlet can also be mapped to other extensions:

<!-- XML source servlet -->
<servlet-mapping>
  <servlet-name>BerliozSource</servlet-name>
  <url-pattern>*.source</url-pattern>
</servlet-mapping>

Different principal modules

The standard mapping assumes that services under a the same group of services are likely to have similar output and share templates. This is why the principal module is typically based on the group of services. This leaves developers free to organise the XSLT modules for the services within a group at their discretion.

Global

In some cases, it is simpler to use the same template globally.

In the example below, we have a single principal module 'app.xsl' for all the services when outputting HTML.

  <servlet>
    <servlet-name>BerliozHTML</servlet-name>
    <servlet-class>org.pageseeder.berlioz.servlet.BerliozServlet</servlet-class>
    <init-param>
      <param-name>stylesheet</param-name>
      <param-value>/xslt/html/app.xsl</param-value>
    </init-param>
  </servlet>

Service based

But there are cases when it is more suitable to have a more fine-grained control over the templates.

In the example below, we assume that each service outputting JSON will have its own principal module:

  <servlet>
    <servlet-name>BerliozJSON</servlet-name>
    <servlet-class>org.pageseeder.berlioz.servlet.BerliozServlet</servlet-class>
    <init-param>
      <param-name>stylesheet</param-name>
      <param-value>/xslt/json/{GROUP}/{SERVICE}.xsl</param-value>
    </init-param>
  </servlet>

Created on , last edited on