<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xh="http://www.w3.org/1999/xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	exclude-result-prefixes="xh"
>

	<xsl:output encoding="utf-8"/>
	<xsl:template match="@*|*|text()">
		<xsl:copy>
			<xsl:apply-templates select="@*|*|text()"/>
			<xsl:if test="local-name() = 'body'">
				<xsl:call-template name="navigation-link"/>
			</xsl:if>
		</xsl:copy>
	</xsl:template>

	<xsl:template name="navigation-link">
		<ul id="navigation">
		<xsl:for-each select="//xh:link">
			<xsl:if test="not(contains(translate(@rel, 'STYLEH', 'styleh'), 'stylesheet'))">
				<li>
					<a href="{@href}">
						<xsl:choose>
							<xsl:when test="@title">
								<xsl:value-of select="@title"/>
							</xsl:when>
							<xsl:when test="@rel">
								<xsl:value-of select="@rel"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="@href"/>
							</xsl:otherwise>
						</xsl:choose>
					</a>
					<xsl:if test="@title and @rel">
						<xsl:text> (</xsl:text>
						<xsl:value-of select="@rel"/>
						<xsl:text>)</xsl:text>
					</xsl:if>
				</li>
			</xsl:if>
		</xsl:for-each>
		</ul>
	</xsl:template>

</xsl:stylesheet>

