<?xml version='1.0'?>

<xsl:stylesheet version="2.0"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:fn="http://www.w3.org/2005/xpath-functions"
    xmlns:csc="http://csclub.uwaterloo.ca/xslt">

<xsl:template match="directory">
  <xsl:variable name="href">
    <xsl:choose>
      <xsl:when test="@href != ''"><xsl:value-of select="@href"/></xsl:when>
      <xsl:otherwise>index.html</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <a class="diritem headdir" href="{$href}">
    <xsl:value-of select="@title" />
  </a>
  <xsl:apply-templates select="diritem" />
</xsl:template>

<xsl:template match="diritem">
  <a class="diritem" href="{@href}">
    <xsl:value-of select="@title" />
  </a>
</xsl:template>

</xsl:stylesheet>
