<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:rs='urn:schemas-microsoft-com:rowset'
 	xmlns:z='#RowsetSchema'
	xmlns:date="http://www.ora.com/XSLTCookbook/NS/dates"
    xml:space="default" 
    xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" 
	version="1.0">

	<xsl:strip-space elements="true" />
	<xsl:output omit-xml-declaration="yes" />
	<xsl:param name="path"></xsl:param>
	<xsl:param name="url"></xsl:param>

	<xsl:template match='//rs:data'>
		<link rel="stylesheet" type="text/css" href="/xslt/footer.css"/>
		<nav role="navigation">
			<ul id="home">
				<li><a href="/actueel/nieuws/">Nieuws</a></li>
				<li><a href="/actueel/agenda/">Agenda &amp; Bijeenkomsten</a></li>
				<li><a href="/webshop/">Webshop</a></li>
				<li><a href="/over/contact/">Contact</a></li>
			</ul>
			<ul id="general">
				<xsl:apply-templates select="*" mode='main' />
			</ul>
		</nav>
	</xsl:template>

	<xsl:template match='*' mode="main">
		<li>
			<xsl:if test="(position() = 1 or @ows_Zone != preceding-sibling::*[1]/@ows_Zone) and @ows_Zone = following-sibling::*[1]/@ows_Zone">
				<xsl:attribute name="aria-haspopup">true</xsl:attribute>
			</xsl:if>
			<a>
				<xsl:attribute name="href"><xsl:value-of select="@ows_URL"></xsl:value-of></xsl:attribute>
				<xsl:choose>
					<xsl:when test="@ows_Volgnummer &lt; 1"><xsl:call-template name="cleanup"><xsl:with-param name="text" select="@ows_Zone"></xsl:with-param></xsl:call-template></xsl:when>
					<xsl:otherwise><xsl:value-of select="@ows_LinkTitle" disable-output-escaping="yes" /></xsl:otherwise>
				</xsl:choose>
			</a>
			<xsl:if test="position() = 1 or @ows_Zone != preceding-sibling::*[1]/@ows_Zone">
				<xsl:text disable-output-escaping="yes">&lt;ul class="dropdown" aria-label="submenu"&gt;</xsl:text>
			</xsl:if>
		</li>
		<xsl:if test="position() = last() or @ows_Zone != following-sibling::*[1]/@ows_Zone"><xsl:text disable-output-escaping="yes">&lt;/ul&gt;</xsl:text></xsl:if>
	</xsl:template>

	<xsl:template name="cleanup">
		<xsl:param name="text"/>
		<xsl:choose>
			<xsl:when test="contains($text, '_')">
				<xsl:value-of select="substring-after($text,'_')"></xsl:value-of>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$text"></xsl:value-of>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

</xsl:stylesheet>