yahuxo’s blog

Using Mallard tools for generating a static website

After more than ten years I finally managed to update my personal homepage. I have searched a bit for some static website generator tool and finally selected Mallard together with mallard-site-tool. Installation was quite easy as most things (yelp-tools, yelp-xsl, itstool) were packaged for my distribution (Ubuntu), only mallard-site-tool needs to be installed from sources.

It took me some time to realize the difference between “Mallard” as a generic specification and the behavior of the actual implementation in Yelp tools. With the help of Shaun McCance I managed to get HTML pass-through working in mallard-site-tool by implementing Mallard’s support for external namespaces. This allows one to embed HTML elements within Mallard pages like in the following small example:

<page xmlns="http://projectmallard.org/1.0/"
   xmlns:html="http://www.w3.org/1999/xhtml"
   type="topic" id="external">
<title>External Namespaces</title>
<p>
   <html:input type="button" value="Hello" onclick="alert('Hello World!');"/>
</p>
</page>

For future reference the solution is to use some custom XSL during site generation by including it in “index.site”:

<?xml version="1.0"?>
<site xmlns="http://projectmallard.org/site/1.0/">
   <link type="site-root" href="."/>
   <link type="site-custom-xsl" href="custom.xsl"/>
</site>

The stylesheet file “custom.xsl” then contains the following template to pass-through HTML elements together with their attributes:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.w3.org/1999/xhtml"
   version="1.0">

<!-- pass-through of inline HTML -->
<xsl:template mode="mal2html.inline.mode" match="html:*">
  <xsl:element name="{local-name(.)}" namespace="{$html.namespace}">
      <xsl:for-each select="./@*">
         <xsl:attribute name="{name()}">
            <xsl:value-of select="."/>
         </xsl:attribute>
      </xsl:for-each>
    <xsl:apply-templates mode="mal2html.inline.mode"/>
  </xsl:element>
</xsl:template>

</xsl:stylesheet>

The site looks quite nice now and editing Mallard pages is fun. So hopefully the next update will take less than ten years.

One Response to “Using Mallard tools for generating a static website”

  1. greeceview Says:

    http://www.greeceview.com/

Leave a Reply