Hiawatha
A secure and advanced webserver

HOWTO: XSLT

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 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, Hiawatha uses a buildin layout to create the index. If a different layout is desired, Hiawatha can use a XSLT file to create the index. Use the path to the XSLT file as the parameter of the ShowIndex setting to use this feature.

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

To see what XML is generated for the directory index, point ShowIndex to a non-existing XSLT file. Hiawatha will send the directory index XML to the client. An example of this XML output can be found below.

<index>
  <hostname>www.example.com</hostname>
  <request_uri>/documents/</request_uri>
  <files>
    <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"
          url_encoded="file.pdf">file.pdf</file>
    <file type="file" timestamp="01 Jul 2009, 20:15:00" size="372.9 kB" extension="txt"
          url_encoded="info.txt">file.txt</file>
  </files>
  <total_size>1.77 MB</total_size>
  <software>Hiawatha v6.18</software>
</index>