<?xml version="1.0"?>
<xsl:stylesheet
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:ws="http://joachim-breitner.de/2004/Website"
  xmlns:s="http://joachim-breitner.de/2004/Song"
  xmlns:fl="http://joachim-breitner.de/2004/Filelist"
  version="1.0"
  exclude-result-prefixes="ws s fl"
>
<!-- This file is © 2004-2008 Joachim Breitner. All Rights Reserved, but feel free to ask for a Free Licence (MIT, GPL): mail@joachim-breitner.de -->

<xsl:import href="news.xsl"/>
<xsl:import href="bibliography.xsl"/>

<!--
<xsl:output method="html" />
-->
 

<xsl:output method="xml"
  media-type="text/html"
  doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
  omit-xml-declaration="yes"
/>

<xsl:param name="path"/>
<xsl:param name="file"/>

<xsl:template match="/ws:website">
  <html> 
  <head>
   <title><xsl:value-of select="./ws:title"/></title>
   <link rel="stylesheet" type="text/css" href="/styles/website.css"/>
   <link rel="shortcut icon" href="/favicon.ico"/> 
   <link rel="openid.server" href="http://www.myopenid.com/server" />
   <link rel="openid.delegate" href="http://nomeata.myopenid.com/" />
   <link rel="openid2.provider" href="http://www.myopenid.com/server" />
   <link rel="openid2.local_id" href="http://nomeata.myopenid.com/" />
   <link rel="pavatar" href="http://www.joachim-breitner.de/avatars/avatar_80.png"/>
   <meta http-equiv="X-XRDS-Location" content="http://nomeata.myopenid.com/xrds" />
  </head>
  <body>
   <div id="header-img">
    <img id="header-links"  src="/img/links.jpg" height="200" width="205" alt="Swirly"/>
    <img id="header-rechts" src="/img/kopf.jpg" height="200" width="205" title="{$lang.kopfTitle}" alt="{$lang.kopfTitle}"/>
 <!--    <img xml:lang="en" title="Myself" id="header-rechts" src="/img/kopf.jpg" height="200" width="205" alt="Mein Kopf" /> -->
   </div>
   <div id="header">
    <h1><span style="font-size:60%"><xsl:value-of select="$lang.welcomeTo"/></span> <br/>
        <xsl:value-of select="./ws:title"/>
     </h1>
<!--    <xsl:call-template name="navi"/> -->
   </div>
   <xsl:call-template name="navi2"/>

   <xsl:choose>
   <xsl:when test="$path='/template'"> ##CONTENT## </xsl:when>

<!-- 
   <xsl:when test="$file">
     <xsl:apply-templates select="document(concat('../',$file))"/>
   </xsl:when> -->
   
   <xsl:otherwise>
   <!-- <xsl:when test="ws:section[@id=$path]"> -->
    <!-- Content ab hier -->

    <xsl:call-template name="navibox"/>
     
    <xsl:choose>
     <xsl:when test="$path = '/'">
      <xsl:apply-templates /> 
     </xsl:when>
     <xsl:when test="$path != '/'">
      <xsl:apply-templates mode="zoom"/> 
     </xsl:when>
    </xsl:choose>
   

    <xsl:call-template name="footer" />

   <!-- 
   <xsl:otherwise>
    <xsl:message terminate="yes">
    Page <xsl:value-of select="$path"/> not Found.
    </xsl:message>
    -->

   </xsl:otherwise>
   </xsl:choose>
   
<!--    
   <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
   <script type="text/javascript">
     _uacct = "UA-896318-1";
     urchinTracker();
   </script>
-->  

   </body>
   </html>
</xsl:template>

<xsl:template match="s:title">
   <h2 class="section"><xsl:apply-templates /></h2>
</xsl:template>

<xsl:template match="s:comment">
  <p> <xsl:apply-templates /> </p>
</xsl:template>

<xsl:template match="s:dedication">
  <p> <xsl:apply-templates /> </p>
</xsl:template>

<xsl:template match="s:text">
  <pre>
    <xsl:apply-templates />
  </pre>
</xsl:template>

<xsl:template match="s:copyright">
 <div id="footer">
<!--   <xsl:value-of select="$lang.thisWebsiteIs"/><xsl:text> </xsl:text> -->
  <a href="{//ws:footer/ws:copyright/@href}" title="e-Mail senden">
    © <xsl:value-of select="."/>
  </a>.<br/>
  <!-- <xsl:value-of select="$lang.lastChange"/>: <xsl:value-of select="//ws:footer/ws:last-modified" /> -->
  </div>
</xsl:template>

<xsl:template match="s:song">
  <xsl:apply-templates />
  <a class="up-link" href="#top"><xsl:value-of select="$lang.goUp"/></a>
</xsl:template>

<xsl:template match="ws:section">
  
 <xsl:variable name="depth"><xsl:call-template name="section-depth"/></xsl:variable>

 <xsl:choose>
  <!-- Section -->
  <xsl:when test="$depth = 1">
  <a name="{@id}"/>
  <xsl:if test="./ws:title">
   <h2 class="section"><xsl:value-of select="./ws:title"/></h2>
  </xsl:if>
  <xsl:apply-templates />
  <a class="up-link" href="#top"><xsl:value-of select="$lang.goUp"/></a>
  </xsl:when>

  <!-- Subsection -->
  <xsl:when test="$depth = 2">
   <a name="{@id}"/>
   <h3 class="subsection"><xsl:value-of select="./ws:title"/></h3>

   <!-- List of files -->
   <xsl:variable name="files">
    <xsl:for-each select=".//ws:file">
     <xsl:variable name="filedepth"><xsl:call-template name="section-depth"/></xsl:variable>
     <xsl:if test="$filedepth = $depth">
      X
     </xsl:if>
    </xsl:for-each>
   </xsl:variable>
   <xsl:if test="contains($files,'X')">
    <div class="sidebox right filebox">
    <div class="title">
     <xsl:choose>
      <xsl:when test="@navi-title">
       <xsl:value-of select="@navi-title"/>
      </xsl:when>
      <xsl:otherwise>
       <xsl:value-of select="./ws:title"/>
      </xsl:otherwise>
     </xsl:choose>
    – <xsl:value-of select="$lang.files"/>
    </div>
    <ul>
    <xsl:for-each select=".//ws:file">
     <xsl:variable name="filedepth"><xsl:call-template name="section-depth"/></xsl:variable>
     <xsl:if test="$filedepth = $depth">
      <li><a href="{@href}" title="{@date}"><xsl:value-of select="@title"/></a></li>
     </xsl:if>
    </xsl:for-each>
    </ul>
    </div>
   </xsl:if>

   <xsl:apply-templates select="ws:projectlinks" />
   <xsl:apply-templates select="*[not(self::ws:projectlinks)]"/> 
  </xsl:when>

  <!-- Further sections -->
  <xsl:otherwise>
   <a name="{@id}"/>
   <h4 class="subsubsection"><xsl:value-of select="./ws:title"/></h4>
   <xsl:apply-templates />
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="ws:introduction">
  <p class="introduction">
    <xsl:apply-templates />
  </p>
</xsl:template>

<xsl:template match="ws:text">
  <p>
    <xsl:apply-templates />
  </p>
</xsl:template>

<xsl:template match="ws:file">
 <xsl:if test="text()">
  <a>
    <xsl:attribute name="href">
     <xsl:value-of select="@href" />
    </xsl:attribute>
    <xsl:attribute name="title">
     <xsl:value-of select="@title" />
    </xsl:attribute>
    <xsl:apply-templates />
  </a>
 </xsl:if>
</xsl:template>

<xsl:template match="ws:target">
  <a>
    <xsl:attribute name="href">
      <xsl:value-of select="@href" />
    </xsl:attribute>
    <xsl:apply-templates/>
  </a>
</xsl:template>

<xsl:template match="ws:facts">
  <table class="facts">
   <xsl:apply-templates/>
  </table>
</xsl:template>

<xsl:template match="ws:fact">
  <tr><th>
       <xsl:if test="position()=2">
        <xsl:attribute name="class">firstline</xsl:attribute>
       </xsl:if>
       <xsl:value-of select="@what"/>
      </th>
      <td>
       <xsl:if test="position()=2">
        <xsl:attribute name="class">firstline</xsl:attribute>
       </xsl:if>
       <xsl:apply-templates/>
      </td></tr>
</xsl:template>
    
<xsl:template match="ws:links">
  <table class="links">
   <xsl:apply-templates/>
  </table>
</xsl:template>

<xsl:template match="ws:links//ws:link">
  <tr><th>
       <xsl:if test="position()=2">
        <xsl:attribute name="class">firstline</xsl:attribute>
       </xsl:if>
       <xsl:value-of select="@to"/>
      </th>
      <td>
       <xsl:if test="position()=2">
        <xsl:attribute name="class">firstline</xsl:attribute>
       </xsl:if>
       <a>
        <xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>
        <xsl:attribute name="title"><xsl:value-of select="@to"/></xsl:attribute>
        <xsl:apply-templates/>
       </a></td></tr>
</xsl:template>

<xsl:template match="ws:projectlinks">
    <div class="sidebox right filebox">
    <div class="title">
     <xsl:choose>
      <xsl:when test="../@navi-title">
       <xsl:value-of select="../@navi-title"/>
      </xsl:when>
      <xsl:otherwise>
       <xsl:value-of select="../ws:title"/>
      </xsl:otherwise>
     </xsl:choose>
     – Links
    </div>
<!--  <p><strong>Links:</strong> -->
 <ul><xsl:apply-templates/></ul>
<!--  </p> -->
 </div>
</xsl:template>

<xsl:template match="ws:blogentry">
 <li><a>
   <xsl:attribute name="href">
        <xsl:value-of select="@href"/>
   </xsl:attribute>
     <xsl:choose>
      <xsl:when test="* or text()">
        <xsl:apply-templates />
      </xsl:when>
      <xsl:otherwise>
       <xsl:value-of select="$lang.blogEntry"/>
      </xsl:otherwise>
     </xsl:choose>
 </a></li>
</xsl:template>

<xsl:template match="ws:otherlink">
 <li><a>
   <xsl:attribute name="href">
        <xsl:value-of select="@href"/>
   </xsl:attribute>
   <xsl:apply-templates />
 </a></li>
</xsl:template>

<xsl:template match="ws:debian-bin">
 <li><a>
   <xsl:attribute name="href">
        http://packages.debian.org/sid/<xsl:value-of select="@pkg"/>
   </xsl:attribute>
     <xsl:choose>
      <xsl:when test="* or text()">
        <xsl:apply-templates />
      </xsl:when>
      <xsl:otherwise>
       <xsl:value-of select="$lang.debianBinary"/>
      </xsl:otherwise>
     </xsl:choose>
 </a></li>
</xsl:template>

<xsl:template match="ws:debian-src">
 <li><a>
   <xsl:attribute name="href">
        http://packages.qa.debian.org/<xsl:value-of select="@pkg"/>
   </xsl:attribute>
    <xsl:value-of select="$lang.debianSrc"/>
 </a></li>
 <li><a>
   <xsl:attribute name="href">
        http://bugs.debian.org/cgi-bin/pkgreport.cgi?src=<xsl:value-of select="@pkg"/>
   </xsl:attribute>
       <xsl:value-of select="$lang.debianBugs"/>
 </a></li>
</xsl:template>

<xsl:template match="ws:darcsrepo[not(@upstream-separate)]">
 <li>
  <a>
   <xsl:attribute name="href">http://darcs.nomeata.de/<xsl:value-of select="@name"/>/</xsl:attribute>
   <xsl:value-of select="$lang.darcsRepo"/>
 </a>
 (<a>
   <xsl:attribute name="href">http://darcs.nomeata.de/cgi-bin/darcsweb.cgi?r=<xsl:value-of select="@name"/></xsl:attribute>
   <xsl:value-of select="$lang.darcsWebView"/>
 </a>)
 </li>
</xsl:template>

<xsl:template match="ws:darcsrepo[@upstream-separate]">
 <li>
  <a>
   <xsl:attribute name="href">http://darcs.nomeata.de/<xsl:value-of select="@name"/>/</xsl:attribute>
   <xsl:value-of select="$lang.darcsRepo"/>
 </a>
 (<a>
   <xsl:attribute name="href">http://darcs.nomeata.de/cgi-bin/darcsweb.cgi?r=<xsl:value-of select="@name"/></xsl:attribute>
   <xsl:value-of select="$lang.darcsWebView"/>
 </a>),
  <a>
   <xsl:attribute name="href">http://darcs.nomeata.de/<xsl:value-of select="@name"/>.debian/</xsl:attribute>
   <xsl:value-of select="$lang.darcsRepoDebian"/>
 </a>
 (<a>
   <xsl:attribute name="href">http://darcs.nomeata.de/cgi-bin/darcsweb.cgi?r=<xsl:value-of select="@name"/>.upstream</xsl:attribute>
   <xsl:value-of select="$lang.darcsWebView"/>
 </a>),
 </li>
</xsl:template>

<xsl:template match="ws:gitorious">
 <li>
  <a>
   <xsl:attribute name="href">https://gitorious.org/<xsl:value-of select="@project"/></xsl:attribute>
   <xsl:value-of select="$lang.gitoriousRepo"/>
 </a>
 </li>
</xsl:template>

<xsl:template match="ws:gitrepo">
 <li>
  <a>
   <xsl:attribute name="href">http://git.nomeata.de/?p=<xsl:value-of select="@name"/>.git</xsl:attribute>
   <xsl:value-of select="$lang.gitRepo"/>
 </a>
 </li>
</xsl:template>

<xsl:template match="ws:releaselink">
 <li>
  <a>
   <xsl:attribute name="href">/archive/<xsl:value-of select="@name"/>/<xsl:value-of select="@name"/>-<xsl:value-of select="@version"/>.tar.gz</xsl:attribute>
   <xsl:value-of select="$lang.downloadLink"/> (<xsl:value-of select="@version"/>)
 </a>
 </li>
</xsl:template>

<xsl:template match="ws:windows-installer">
 <li>
  <a>
   <xsl:attribute name="href">/archive/<xsl:value-of select="@name"/>/<xsl:value-of select="@name"/>-setup-<xsl:value-of select="@version"/>.exe</xsl:attribute>
   <xsl:value-of select="$lang.windowsDownloadLink"/> (<xsl:value-of select="@version"/>)
 </a>
 </li>
</xsl:template>

<xsl:template match="ws:contact">
   <xsl:apply-templates/>
</xsl:template>

<xsl:template match="ws:where">
  <h3 class="subsection"><xsl:value-of select="@place"/></h3>
  <ul>
  <xsl:apply-templates/>
  </ul>
</xsl:template>

<xsl:template match="ws:via">
  <li><strong>Via <xsl:value-of select="@medium"/></strong>:<br />
<!--    <xsl:apply-templates/> -->
    <xsl:for-each select="*">
      <xsl:apply-templates select="."/>
      <xsl:if test="position()!=last()">
       <br />
      </xsl:if>
    </xsl:for-each>
  </li>
</xsl:template>

<xsl:template match="ws:email">
  <a>
    <xsl:attribute name="href">mailto:<xsl:value-of select="."/></xsl:attribute>
    <xsl:value-of select="."/>
   </a>
</xsl:template>
    
<xsl:template match="ws:icq">
  <xsl:value-of select="."/>
  <br/>
  <img>
    <xsl:attribute name="alt"><xsl:value-of select="$lang.onlineStatusOf"/> <xsl:value-of select="."/> </xsl:attribute>
    <xsl:attribute name="src">http://wwp.icq.com/scripts/online.dll?icq=<xsl:value-of select="."/>&amp;img=2 </xsl:attribute>
  </img>
</xsl:template>
    
<xsl:template match="ws:jid">
  <xsl:value-of select="."/>
  <xsl:if test="@status-url">
  <br/>
  <img>
    <xsl:attribute name="alt"><xsl:value-of select="$lang.onlineStatusOf"/> <xsl:value-of select="."/> </xsl:attribute>
    <xsl:attribute name="src"><xsl:value-of select="@status-url" /></xsl:attribute>
  </img>
  </xsl:if>
</xsl:template>
    
<xsl:template match="ws:indicator">
  <img alt="Jabber-Status">
  <xsl:attribute name="src"><xsl:value-of select="."/></xsl:attribute>
  </img>
</xsl:template>
    
<xsl:template match="ws:telefone">
 <xsl:value-of select="ws:number"/> (<xsl:value-of select="ws:location"/>)
</xsl:template>

<xsl:template match="ws:address">
 <xsl:value-of select="ws:name"/><br />
 <xsl:if test="ws:co">
  <xsl:value-of select="ws:co"/><br />
 </xsl:if>
 <xsl:if test="ws:room">
   <xsl:value-of select="$lang.room"/> <xsl:value-of select="ws:room"/><br />
 </xsl:if>
 <xsl:value-of select="ws:street"/><br />
 <xsl:if test="ws:plz">
  <xsl:value-of select="ws:plz"/><xsl:text> </xsl:text>
 </xsl:if>
 <xsl:value-of select="ws:city"/>
 <xsl:if test="ws:country">
  <br />
  <xsl:value-of select="ws:country"/>
 </xsl:if>
</xsl:template>

<xsl:template match="ws:CVE">
 <a>
  <xsl:attribute name="href">
   http://cve.mitre.org/cgi-bin/cvename.cgi?name=<xsl:value-of select="."/>
  </xsl:attribute>
  <xsl:value-of select="."/>
 </a>
</xsl:template>

<!-- 
<xsl:template match="ws:filelisting">
<ul>
 <xsl:for-each select="document(@path)/fl:filelist/fl:file">
 <li>
  <a>
   <xsl:attribute name="href">
    <xsl:value-of select="substring-before(.,'.xml')"/>
   </xsl:attribute>
   <xsl:value-of select="document(concat('../xmls/',.))//s:title"/>
  </a>
 </li>
 </xsl:for-each>
</ul>
</xsl:template>
-->

<xsl:template name="footer">
 <div id="footer">
<!--   <xsl:value-of select="$lang.thisWebsiteIs"/><xsl:text> </xsl:text> -->
  <a href="{ws:footer/ws:copyright/@href}" title="e-Mail senden">
    © <xsl:value-of select="ws:footer/ws:copyright"/>
  </a>.<br/>
  <xsl:value-of select="$lang.lastChange"/>: <xsl:value-of select="ws:footer/ws:last-modified" />
  </div>
</xsl:template>

<xsl:template name="navi2">
 <div id="navi2">
  <xsl:for-each select="ws:section[./ws:title]">
   <a href="/{@id}">
    <xsl:if test="starts-with($path,concat('/',@id))">
      <xsl:attribute name="class">current</xsl:attribute>
    </xsl:if>
    <xsl:choose>
     <xsl:when test="./ws:navi-title">
      <xsl:attribute name="title"><xsl:value-of select="./ws:title"/></xsl:attribute>
      <xsl:value-of select="./ws:navi-title"/>
     </xsl:when>
     <xsl:otherwise>
      <xsl:value-of select="./ws:title"/>
     </xsl:otherwise>
    </xsl:choose>
   </a>
  </xsl:for-each>

  <!-- <span/> -->

  <xsl:for-each select="ws:subsite[@title]">
   <a class="subsite">
   <xsl:attribute name="title"> <xsl:value-of select="@title"/> </xsl:attribute>
   <xsl:attribute name="href"> <xsl:value-of select="@href"/> </xsl:attribute>
   <img class="linkimg" src="/img/extern.gif" width="12" height="9" alt="ext.">
    <xsl:attribute name="title"> <xsl:value-of select="$lang.externalLink"/></xsl:attribute>
   </img>
    <xsl:choose>
     <xsl:when test="@navi-title">
      <xsl:value-of select="@navi-title"/>
     </xsl:when>
     <xsl:otherwise>
      <xsl:value-of select="@title"/>
     </xsl:otherwise>
    </xsl:choose>
   </a>
  </xsl:for-each>
 </div>
</xsl:template>

<xsl:template name="navibox">
 <xsl:for-each select="ws:section[starts-with($path,concat('/',@id))]">
  <xsl:if test="ws:section | ws:more/ws:section">
   <div class="sidebox left navibox">
    <div class="title">
      <xsl:choose>
        <xsl:when test="@navi-title">
          <xsl:value-of select="@navi-title"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="./ws:title"/>
        </xsl:otherwise>
      </xsl:choose>
      – Navi
    </div>
    <ul>
     <xsl:for-each select="ws:section | ws:more/ws:section">
      <li><a class="subsection">
       <xsl:attribute name="href"><xsl:text>/</xsl:text>
        <!-- this assumes that the subsections are wrapped in a <more> -->
        <xsl:value-of select="../../@id"/>
        <xsl:choose>
         <!-- this only works if the more element is a direct child of the section -->
         <xsl:when test="ws:more">/</xsl:when>
         <xsl:otherwise>#</xsl:otherwise>
        </xsl:choose>
        <xsl:value-of select="@id"/>
       </xsl:attribute>
       <xsl:choose>
        <xsl:when test="@navi-title">
         <xsl:value-of select="@navi-title"/>
        </xsl:when>
        <xsl:otherwise>
         <xsl:value-of select="./ws:title"/>
        </xsl:otherwise>
       </xsl:choose>
      </a></li>
     </xsl:for-each>
    </ul>
   </div>
  </xsl:if>
 </xsl:for-each>
</xsl:template>


<xsl:template name="navi">
  <table><tr>
  <xsl:for-each select="ws:section[./ws:title]">
    <td>
    <div class="section">
     <a class="title" href="/{@id}">
     <xsl:choose>
       <xsl:when test="@navi-title">
         <xsl:value-of select="@navi-title"/>
       </xsl:when>
       <xsl:otherwise>
         <xsl:value-of select="./ws:title"/>
       </xsl:otherwise>
     </xsl:choose>
    </a>
    <xsl:if test="ws:section">
     <xsl:for-each select="ws:section">
      <a class="subsection" href="/{../@id}#{@id}">
     <xsl:choose>
       <xsl:when test="@navi-title">
         <xsl:value-of select="@navi-title"/>
       </xsl:when>
       <xsl:otherwise>
         <xsl:value-of select="./ws:title"/>
       </xsl:otherwise>
     </xsl:choose>
      </a>
     </xsl:for-each>
    </xsl:if>
    </div>
    </td>
  </xsl:for-each>
  </tr></table>
</xsl:template>

<!-- xsl:template match="*|@*">
 <xsl:copy>
  <xsl:apply-templates select="*|@*|node()" />
 </xsl:copy>
</xsl:template -->

<!-- <xsl:template  match="*|@*">
 <xsl:copy>
  <xsl:apply-templates select="*|@*|node()" />
 </xsl:copy>
 <xsl:message terminate="yes">Found unknown node</xsl:message>
</xsl:template> -->

<xsl:template match="ws:link">
  <xsl:if test="@type='old'">
   <span class="oldlink"> 
    <xsl:attribute name="title"> <xsl:value-of select="$lang.oldLink"/></xsl:attribute>
   <xsl:apply-templates /> </span>
  </xsl:if>
  <xsl:if test="@type!='old'">
 <a href="{@href}">
  <xsl:if test="@title">
   <xsl:attribute name="title"> <xsl:value-of select="@title"/> </xsl:attribute>
  </xsl:if>
  <xsl:apply-templates />
  <xsl:if test="@type='external'">
   <img class="linkimg" src="/img/extern.gif" width="12" height="9" alt="ext.">
    <xsl:attribute name="title"> <xsl:value-of select="$lang.externalLink"/></xsl:attribute>
   </img>
  </xsl:if>
 </a>
  </xsl:if>
</xsl:template>

<!-- Subpage handling -->
<xsl:template match="ws:morelist">
<ul>
 <xsl:for-each select="ws:more">
 <li>
  <a>
   <xsl:attribute name="href">
    <xsl:call-template name="calcpath"/>
   </xsl:attribute>
   <xsl:value-of select="s:song/s:title"/>
  </a>
 </li>
 </xsl:for-each>
</ul>
</xsl:template>

<xsl:template name="calcpath">
 <xsl:choose>
  <xsl:when test="ancestor-or-self::*[@id]">
   <xsl:for-each select="ancestor-or-self::*[@id]">
    <xsl:text>/</xsl:text>
    <xsl:value-of select="@id"/>
   </xsl:for-each>
  </xsl:when>
  <xsl:otherwise>
   <xsl:text>/</xsl:text>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<!-- How many sections have been displayed so far? -->
<xsl:template name="section-depth">
 <xsl:variable name="sections">
  <xsl:for-each select="ancestor-or-self::*[self::ws:section or self::ws:website]">
   <xsl:variable name="subpath"><xsl:call-template name="calcpath"/></xsl:variable>
    <xsl:if test="starts-with($subpath,$path)">
     X
    </xsl:if>
   </xsl:for-each> 
  </xsl:variable>
  <xsl:value-of select="string-length(translate(normalize-space($sections),'X ','X'))"/>
</xsl:template>

<xsl:template match="text()" mode="zoom" />

<xsl:template match="*" mode="zoom">
 <xsl:variable name="subpath"><xsl:call-template name="calcpath"/></xsl:variable>

 <xsl:choose>
  <xsl:when test="$path = $subpath">
   <xsl:apply-templates select="." />
  </xsl:when>
  <xsl:otherwise>
   <xsl:apply-templates mode="zoom" />
  </xsl:otherwise>
 </xsl:choose>

</xsl:template>

<xsl:template match="ws:more">
 <xsl:variable name="subpath"><xsl:call-template name="calcpath"/></xsl:variable>
 <xsl:choose>
  <xsl:when test="$path = $subpath">
   <xsl:apply-templates />
  </xsl:when>
  <xsl:otherwise>
   <p><a>
    <xsl:attribute name="href"><xsl:value-of select="$subpath"/></xsl:attribute>
     <xsl:value-of select="$lang.clickForMore"/>
   </a></p>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="ws:less">
 <xsl:variable name="subpath"><xsl:call-template name="calcpath"/></xsl:variable>
 <xsl:choose>
  <xsl:when test="$path = $subpath">
   <!-- skipped -->
  </xsl:when>
  <xsl:otherwise>
   <xsl:apply-templates />
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>


<!-- Do not show unmatched elements -->
<xsl:template match="ws:*"/>
<xsl:template match="s:*"/>

</xsl:stylesheet>
