75 lines
2.6 KiB
XML
75 lines
2.6 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<xsl:stylesheet version="1.0"
|
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
xmlns:rss="http://purl.org/rss/1.0/"
|
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
xmlns:date="http://exslt.org/dates-and-times"
|
|
xmlns:str="http://exslt.org/strings"
|
|
exclude-result-prefixes="xsl rss rdf date str">
|
|
|
|
<!--
|
|
# Templates used for generation of navigation elements.
|
|
#
|
|
# TODO: Remove duplicate code within navitems- and subnavigation-template.
|
|
-->
|
|
|
|
<xsl:template name="navitem">
|
|
<xsl:param name="file"/>
|
|
<xsl:variable name="xml_file" select="document(concat($file, '.xml'))" />
|
|
<xsl:variable name="title">
|
|
<!-- Use nav_title-attribute if possible or fallback to
|
|
page title -->
|
|
<xsl:choose>
|
|
<xsl:when test="$xml_file/page/@nav_title">
|
|
<xsl:value-of select="$xml_file/page/@nav_title" />
|
|
</xsl:when>
|
|
<xsl:when test="$xml_file/page/@title">
|
|
<xsl:value-of select="$xml_file/page/@title" />
|
|
</xsl:when>
|
|
<xsl:otherwise>MISSING TITLE</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:variable>
|
|
<a href="{$file}.html" title="{$title}">
|
|
<xsl:value-of select="$title" />
|
|
</a>
|
|
</xsl:template>
|
|
|
|
<xsl:template name="navitems">
|
|
<xsl:variable name="active" select="string(/page/@id)"/>
|
|
<nav id="navigation">
|
|
<ul>
|
|
<xsl:for-each select="document('navigation.xml')/navigation/file">
|
|
<li>
|
|
<!-- Check if this page is the active one -->
|
|
<xsl:if test=". = $active">
|
|
<xsl:attribute name="class">active</xsl:attribute>
|
|
</xsl:if>
|
|
<xsl:call-template name="navitem">
|
|
<xsl:with-param name="file" select="."/>
|
|
</xsl:call-template>
|
|
</li>
|
|
</xsl:for-each>
|
|
</ul>
|
|
</nav>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="/page/subnavigation">
|
|
<xsl:variable name="active" select="string(/page/@id)"/>
|
|
<nav id="subnavigation">
|
|
<ul>
|
|
<xsl:for-each select="file">
|
|
<li>
|
|
<!-- Check if this page is the active one -->
|
|
<xsl:if test=". = $active">
|
|
<xsl:attribute name="class">active</xsl:attribute>
|
|
</xsl:if>
|
|
<xsl:call-template name="navitem">
|
|
<xsl:with-param name="file" select="."/>
|
|
</xsl:call-template>
|
|
</li>
|
|
</xsl:for-each>
|
|
</ul>
|
|
</nav>
|
|
</xsl:template>
|
|
</xsl:stylesheet>
|