HOWTO: Customized directory and XML layout

Hiawatha has support for XSLT. It can transform XML files via XSLT and show customized directory indexes via XSLT.

XML files

Requested XML files can be transformed via XSLT. If a virtual host has XSLT support enabled, Hiawatha will look for a .xslt file that matches the .xml filename. For example, if file.xml is requested, Hiawatha will look for file.xslt and use it to transform the XML file.

If a matching XSLT file is not found, Hiawatha will look for an index.xslt file in the same directory. If not found, Hiawatha will finally look for an index.xslt in the webroot directory.

If no XSLT file is found, the XML file itself is sent to the client.

To enable XSLT support for a virtual host, use the following setting:

VirtualHost {
  UseXSLT = yes

Directory index

When a directory index is requested and ShowIndex is set to 'yes', Hiawatha creates a XML file of the directory content and uses it with a XSLT file to create the index. The default XSLT file can be found in the Hiawatha configuration directory. If you want to use a different XSLT file, use the path to that XSLT file as the parameter of the ShowIndex option.

VirtualHost {
  ShowIndex = /path/to/layout.xslt

An example of the XML generated by Hiawatha can be found below.

    <file type="dir" timestamp="13 Jun 2009, 12:00:00" url_encoded="..">../</file>
    <file type="file" timestamp="20 Jun 2009, 15:30:00" size="1.4 MB" extension="pdf"
    <file type="file" timestamp="01 Jul 2009, 20:15:00" size="372.9 kB" extension="txt"
  <total_size>1.77 MB</total_size>
  <software>Hiawatha v7.3</software>