<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8"/>
<xsl:template match="/">
<h2><a name="main_navigation">Main navigation</a></h2>
<ul id="nav-main" class="navigation">
<xsl:apply-templates select="//tree/page"/>
</ul>
<h2><a name="sub_navigation">Sub navigation</a></h2>
<ul id="nav-sub" class="navigation">
<xsl:apply-templates select="//tree/page[current_page_ancestor or @current_page]/page"/>
</ul>
</xsl:template>
<xsl:template match="page">
<li>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="position()=1">link first</xsl:when>
<xsl:when test="position()=last()">link last</xsl:when>
<xsl:otherwise>link</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<a href="{href}" title="{title}">
<xsl:if test="@current_page='true' or current_page_ancestor"><xsl:attribute name="class">active</xsl:attribute></xsl:if>
<xsl:value-of select="name" disable-output-escaping="yes"/>
</a>
</li>
</xsl:template>
</xsl:stylesheet>