<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet SYSTEM "http://commons.omniupdate.com/dtd/standard.dtd">
<!-- 
	
Nested Navigation

Last Updated 11/7/2013
-->
<xsl:stylesheet version="3.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:ou="http://omniupdate.com/XSL/Variables"
    xmlns:fn="http://omniupdate.com/XSL/Functions"
    xmlns:ouc="http://omniupdate.com/XSL/Variables"
    exclude-result-prefixes="ou xsl xs fn ouc">


	
<!-- THIS TEMPLATE WILL OUTPUT a <UL> and include the section nav of each section -->
<!-- YOU MAY HAVE TO CHANGE THE INCLUDE SYNTAX FOR THE SECTION NAV INCLUDE -->
<!-- Javascript must be used to nest the lists. -->
    

    
	<xsl:variable name="root" as="xs:string" select="concat($ou:root,$ou:site)" />
     
	<xsl:variable name="section-index-filename" select="concat($index-file,'.',$extension)"/>
	<xsl:variable name="section-nav-filename" select="'_nav.inc'"/> 
     
    
    
    <xsl:template name="emp-nav-builder">
        <!-- initiates parameters, sets a default value if no parameters were passed in -->
        <xsl:param name="top-level" as="xs:string">/</xsl:param>
        <xsl:param name="path" as="xs:string">/</xsl:param>
        <xsl:param name="last_crumb" as="xs:string">last</xsl:param>
        
        
        <xsl:call-template name="nav">
            <xsl:with-param name="top-level" select="$top-level"/>
            <xsl:with-param name="path" select="$path"/>
            <xsl:with-param name="last_crumb" select="$last_crumb"/>
        </xsl:call-template>
        
        
    </xsl:template>
    
    <xsl:template name="nav">
    <xsl:param name="top-level" as="xs:string" />
    <xsl:param name="path" as="xs:string" required="yes"/>
    <xsl:param name="last_crumb" as="xs:string" required="yes"/>
        
        <!-- Check if the current path has parent directories. If it does, send the path of the parent directory to the template again. -->
        <xsl:if test="$path != $top-level and $path != '/'">
            <xsl:variable name="list" select="tokenize(substring($path, 2), '/')"/>
            <xsl:variable name="parent" select="concat('/', string-join(remove($list, count($list)), '/'))"/>
            
            <xsl:call-template name="nav">
                <xsl:with-param name="top-level" select="$top-level"/>
                <xsl:with-param name="path" select="$parent"/>
                <xsl:with-param name="last_crumb" select="$ou:dirname"/>
            </xsl:call-template>
			
        </xsl:if>
		
		<!-- changed to only show li items from root section - SH 4-3-2020 -->
		<xsl:variable name="href" select="if ($path = '/') then $path else concat($path, '/')"/>
		<xsl:variable name="cnt" select="string-length(concat($path, '/')) - string-length(translate(concat($path,'/'), '/', ''))"/>
		
		<xsl:if test="$cnt = 3 and $path != '/'">
			<script language="javascript">
				console.log("<xsl:value-of select="$path" />");
			</script>
			<xsl:comment> accordion-holder </xsl:comment>
			<div class="maincard-header-grey">
           <h2 class="cardheader" data-name="{$dirtest}" data-value="{$navigationParentTitle}"><xsl:value-of select="$navigationParentTitle"/></h2>
        </div>
			<nav class="link-holder">
				<!-- <p class="left-nav-title"><xsl:value-of select="$navigationTitle"/></p> -->
				<!-- <hr></hr>-->
				<ul class="left-EO-nav" data-nav-path="{$href}{$section-index-filename}" >
					<xsl:copy-of select="ou:standardInclude(concat($href,$section-nav-filename))"/>
				</ul>
			</nav>						
		</xsl:if>
		
		<!-- HTML OUTPUT FOR EACH SECTION -->      
        
     
     
     
    </xsl:template>
    
</xsl:stylesheet>

