<xsl:stylesheet xmlns:xd="http://www.pnp-software.com/XSLTdoc" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:tei="http://www.tei-c.org/ns/1.0" version="1.0" exclude-result-prefixes="tei xd exsl">
    
<!-- eZISS - Mestne prisege  -->
    
<!-- XSLT stylesheet to generate HTML version of TEI document -->
    
<!-- Tomaz Erjavec -->
    
<!-- 2009-05-19 -->

    
<xsl:import href="tei-xsl-5.15/p5/html/tei.xsl" />

    
<xsl:param name="localisation-file">teiLocalise-sl.xml</xsl:param>
    
<xsl:variable name="tei-localisation" select="document($localisation-file)" />

    
<xsl:param name="lang">sl</xsl:param>
    
<xsl:param name="documentationLanguage">slv</xsl:param>
    
<xsl:param name="htmlTitlePrefix">eZISS</xsl:param>
    
<xsl:param name="teiHeaderFile">teiHeader.html</xsl:param>
    
<xsl:param name="feedbackURL">mailto:matija.ogrin@zrc-sazu.si</xsl:param>
    
<xsl:param name="department" />
    
<xsl:param name="homeLabel">eZISS</xsl:param>
    
<xsl:param name="homeURL">../</xsl:param>
    
<xsl:param name="homeWords">Mestne prisege</xsl:param>
    
<xsl:param name="parentWords">Izdaje eZISS</xsl:param>
    
<xsl:param name="parentURL">http://nl.ijs.si/e-zrc/</xsl:param>
    
<xsl:param name="institution">Mestne prisege</xsl:param>
    
<!--xsl:param name="searchURL">http://www.google.com</xsl:param-->
    
<xsl:param name="searchURL" />
    
<xsl:template name="copyrightStatement">Avtorske pravice za besedilo te izdaje določa licenca <a href="http://creativecommons.org/licenses/by-nd/2.5/si/">Creative Commons Priznanje avtorstva–Brez predelav 2.5 Slovenija</a>.</xsl:template>
    
<xsl:param name="cssFile">ezrc.css</xsl:param>
    
<xsl:param name="outputDir">html</xsl:param>
    
<xsl:param name="STDOUT">false</xsl:param>
    
<xsl:param name="outputName">prisege</xsl:param>
    
<xsl:param name="useIDs">true</xsl:param>
    
<xsl:param name="urlChunkPrefix">#</xsl:param>
    
<xsl:param name="outputEncoding">utf-8</xsl:param>
    
<xsl:param name="autoToc">true</xsl:param>
    
<xsl:param name="tocDepth">3</xsl:param>
    
<xsl:param name="subTocDepth">10</xsl:param>
    
<xsl:param name="splitLevel">0</xsl:param>
    
<xsl:param name="verbose" />
    
<xsl:param name="numberHeadings" />
    
<xsl:param name="numberParagraphs">false</xsl:param>
    
<xsl:param name="footnoteBackLink">true</xsl:param>
    
<xsl:param name="footnoteFile" />

    
<xsl:key name="id" match="tei:*" use="@xml:id" />

    
    <xd:doc>
      
<xd:short>Output gloss text from localisation file. Uses exsl:node-set</xd:short>
    
</xd:doc>

  
<xsl:template name="glosstext">
    
<xsl:param name="loc">sl</xsl:param>
    
<xsl:param name="ident" />
    
<xsl:variable name="text" select="exsl:node-set($tei-localisation)//tei:*[@ident=$ident]" />
    
<xsl:choose>
      
<xsl:when test="$loc='sl'">
        
<xsl:value-of select="normalize-space(exsl:node-set($text)/tei:gloss[@xml:lang='sl'])" />
      
</xsl:when>
      
<xsl:when test="$loc='en'">
        
<xsl:choose>
          
<xsl:when test="normalize-space(exsl:node-set($text)/tei:gloss[@xml:lang='en'])">
            
<xsl:value-of select="exsl:node-set($text)/tei:gloss[@xml:lang='en']" />
          
</xsl:when>
          
<xsl:otherwise>
            
<xsl:value-of select="$ident" />
          
</xsl:otherwise>
        
</xsl:choose>
      
</xsl:when>
      
<xsl:otherwise>
        
<xsl:value-of select="$ident" />
      
</xsl:otherwise>
    
</xsl:choose>
  
</xsl:template>

    
    <xd:doc>
        
<xd:short>Process elements tei:divGen[@type='toc']</xd:short>
        
<xd:detail>
            
<p>Table of contents with link to teiHeader in HTML</p>
        
</xd:detail>
    
</xd:doc>

    
<xsl:template match="tei:divGen[@type='toc']">
        
<xsl:if test="normalize-space($teiHeaderFile)">
          
<a href="{$teiHeaderFile}">Kolofon TEI</a>
        
</xsl:if>
        
<a name="TOC"> </a>
        
<h2>
            
<xsl:call-template name="i18n">
                
<xsl:with-param name="word">tocWords</xsl:with-param>
            
</xsl:call-template>
        
</h2>
        
<xsl:call-template name="mainTOC">
          
<xsl:with-param name="force">yes</xsl:with-param>
        
</xsl:call-template>
        
<h2>Razčlenjeno kazalo</h2>
        
<xsl:call-template name="mainTOC" />
        
<br />
    
</xsl:template>

    
<xsl:template match="tei:hi">
        
<xsl:choose>
            
<xsl:when test="@rendition">
                
<span>
                    
<xsl:call-template name="applyRendition" />
                    
<xsl:apply-templates />
                
</span>
            
</xsl:when>
            
<xsl:when test="@rend">
                
<xsl:call-template name="rendering" />
            
</xsl:when>
            
<xsl:otherwise>
                
<i>
                    
<xsl:apply-templates />
                
</i>
            
</xsl:otherwise>
        
</xsl:choose>
    
</xsl:template>

  
    <xd:doc>
    
<xd:short>Process elements tei:sp</xd:short>
  
</xd:doc>

  
<xsl:template match="tei:sp">
    
<dl>
      
<dt>
        
<xsl:call-template name="makeAnchor" />
        
<xsl:apply-templates select="tei:speaker" />
      
</dt>
      
<dd>
        
<!--xsl:apply-templates select="tei:*[name()!=speaker]"/ doesnt work-->
        
<xsl:apply-templates select="tei:p | tei:l | tei:lg | tei:seg | tei:ab | tei:stage | tei:note | tei:pb" />
      
</dd>
    
</dl>
  
</xsl:template>
  
    <xd:doc>
    
<xd:short>Process element tei:stage</xd:short>
    
<xd:detail>Makes an anchor</xd:detail>
  
</xd:doc>

  
<xsl:template match="tei:stage">
    
<p>
      
<xsl:call-template name="makeAnchor" />
      
<span class="stage">
        
<xsl:apply-templates />
      
</span>
    
</p>
  
</xsl:template>
  
<xsl:template match="tei:speaker">
    
<xsl:call-template name="makeAnchor" />
    
<xsl:apply-templates />
  
</xsl:template>

    
    <xd:doc>
        
<xd:short>Process element tei:titlePart.</xd:short>
    
</xd:doc>

    
<xsl:template match="tei:titlePart">
        
<xsl:apply-templates />
        
<br />
    
</xsl:template>

    
    <xd:doc>
        
<xd:short>Process elements tei:l</xd:short>
        
<xd:detail>Show also every fifth line number for @n.</xd:detail>
    
</xd:doc>

    
<xsl:template match="tei:l">
        
<div class="l">
          
<xsl:call-template name="makeAnchor" />
            
<xsl:choose>
                
<xsl:when test="@n and @n mod 5 = 0">
                    
<sup>
                        
<span class="number" title="vrstica {@n}">
                            
<xsl:text>v</xsl:text>
                            
<xsl:value-of select="@n" />
                        
</span>
                    
</sup>
                
</xsl:when>
            
</xsl:choose>
            
<xsl:apply-templates />
        
</div>
    
</xsl:template>

    
    <xd:doc>
        
<xd:short>Process elements tei:list[@rend='none']</xd:short>
        
<xd:detail>Diplay list with no bullets.</xd:detail>
    
</xd:doc>

    
<xsl:template match="tei:list[@type='trans']">
        
<ul class="trans">
            
<xsl:apply-templates />
        
</ul>
    
</xsl:template>

    
    <xd:doc>
        
<xd:short>Process elements tei:docAuthor in "author" mode"</xd:short>
        
<xd:detail> </xd:detail>
    
</xd:doc>

    
<xsl:template match="tei:docAuthor" mode="author">
        
<xsl:if test="preceding::tei:docAuthor">
            
<xsl:text></xsl:text>
        
</xsl:if>
        
<xsl:apply-templates />
    
</xsl:template>

    
    <xd:doc>
        
<xd:short>Write out gap info</xd:short>
    
</xd:doc>

    
<xsl:template match="tei:gap" mode="ezrc-i18n">
      
<xsl:call-template name="glosstext">
        
<xsl:with-param name="ident" select="name()" />
      
</xsl:call-template>
      
<xsl:if test="@reason">
        
<xsl:text></xsl:text>
        
<xsl:call-template name="glosstext">
          
<xsl:with-param name="ident">reason</xsl:with-param>
        
</xsl:call-template>
        
<xsl:text> </xsl:text>
        
<xsl:call-template name="glosstext">
          
<xsl:with-param name="ident" select="@reason" />
        
</xsl:call-template>
      
</xsl:if>
      
<xsl:if test="@extent">
        
<xsl:text> (</xsl:text>  
        
<xsl:call-template name="glosstext">
          
<xsl:with-param name="ident">extent</xsl:with-param>
        
</xsl:call-template>
        
<xsl:text> </xsl:text>  
        
<xsl:value-of select="@extent" />
        
<xsl:text> </xsl:text>
        
<xsl:call-template name="glosstext">
          
<xsl:with-param name="ident" select="@unit" />
        
</xsl:call-template>
        
<xsl:text>)</xsl:text>  
      
</xsl:if>
    
</xsl:template>

    
    <xd:doc>
        
<xd:short>Write out supplied info</xd:short>
    
</xd:doc>

    
<xsl:template match="tei:supplied" mode="ezrc-i18n">
      
<xsl:call-template name="glosstext">
        
<xsl:with-param name="ident" select="name()" />
      
</xsl:call-template>
      
<xsl:if test="@reason">
        
<xsl:text></xsl:text>
        
<xsl:call-template name="glosstext">
          
<xsl:with-param name="ident">reason</xsl:with-param>
        
</xsl:call-template>
        
<xsl:text> </xsl:text>
        
<xsl:call-template name="glosstext">
          
<xsl:with-param name="ident" select="@reason" />
        
</xsl:call-template>
      
</xsl:if>
      
<!--xsl:if test="@resp">
        <xsl:text> (</xsl:text>  
        <xsl:call-template name="glosstext">
          <xsl:with-param name="ident">resp</xsl:with-param>
        </xsl:call-template>
        <xsl:text> </xsl:text>  
        <xsl:value-of select="normalize-space(key('id',substring-after(@resp,'#')))"/>
        <xsl:text>)</xsl:text>  
      </xsl:if
-->
    
</xsl:template>

    
    <xd:doc>
        
<xd:short>Write out one janus tag name(), @hand, @cert, @type, @place in Slovene</xd:short>
    
</xd:doc>

    
<xsl:template match="tei:abbr | tei:expan | tei:sic | tei:corr | tei:add | tei:del" mode="ezrc-i18n">
      
<xsl:call-template name="glosstext">
        
<xsl:with-param name="ident" select="name()" />
      
</xsl:call-template>
      
<xsl:if test="@hand">
        
<xsl:text></xsl:text>  
        
<!--
        <xsl:call-template name="glosstext">
          <xsl:with-param name="ident">hand</xsl:with-param>
        </xsl:call-template>
        <xsl:text> </xsl:text>  
        
-->
        
<xsl:if test="not(key('id',substring-after(@hand,'#'))/@scribe)">
          
<xsl:message>
            
<xsl:text>Missing scribe for</xsl:text>
            
<xsl:value-of select="@hand" />
          
</xsl:message>
        
</xsl:if>
        
<xsl:value-of select="translate(key('id',substring-after(@hand,'#'))/@scribe,'_',' ')" />
      
</xsl:if>
      
<xsl:if test="@cert">
        
<xsl:text> (</xsl:text>
        
<xsl:call-template name="glosstext">
          
<xsl:with-param name="ident" select="@cert" />
        
</xsl:call-template>
        
<xsl:text> </xsl:text>  
        
<xsl:call-template name="glosstext">
          
<xsl:with-param name="ident">cert</xsl:with-param>
        
</xsl:call-template>
        
<xsl:text></xsl:text>
      
</xsl:if>
      
<xsl:choose>
            
<xsl:when test="@type">
                
<xsl:text></xsl:text>
                
<xsl:call-template name="glosstext">
                    
<xsl:with-param name="ident" select="@type" />
                
</xsl:call-template>
            
</xsl:when>
            
<xsl:when test="@place">
                
<xsl:text></xsl:text>
                
<xsl:call-template name="glosstext">
                    
<xsl:with-param name="ident" select="@place" />
                
</xsl:call-template>
            
</xsl:when>
        
</xsl:choose>
    
</xsl:template>
    
    <xd:doc>
        
<xd:short>Process one of Janus elements + supplied</xd:short>
    
</xd:doc>

    
<xsl:template match="tei:abbr | tei:expan | tei:sic | tei:corr | tei:supplied">
        
<xsl:param name="title">
            
<xsl:apply-templates select="self::tei:*" mode="ezrc-i18n" />
        
</xsl:param>
        
<span class="choice" title="{$title}">
            
<xsl:apply-templates />
        
</span>
    
</xsl:template>
    
    <xd:doc>
      
<xd:short>Process elements tei:gap</xd:short>
    
</xd:doc>

    
<xsl:template match="tei:gap">
      
<xsl:param name="title">
        
<xsl:apply-templates select="self::tei:*" mode="ezrc-i18n" />
      
</xsl:param>
      
<span class="choice" title="{$title}">
        
<xsl:text>[...]</xsl:text>
      
</span>
    
</xsl:template>
    
    <xd:doc>
      
<xd:short>Process elements tei:unclear</xd:short>
    
</xd:doc>

    
<xsl:template match="tei:unclear">
      
<xsl:param name="title">
        
<xsl:call-template name="glosstext">
          
<xsl:with-param name="ident">unclear</xsl:with-param>
        
</xsl:call-template>
      
</xsl:param>
      
<span class="unclear" title="{$title}">
        
<xsl:apply-templates />
      
</span>
    
</xsl:template>

    
    <xd:doc>
        
<xd:short>Process element tei:subst</xd:short>
    
</xd:doc>

    
<xsl:template match="tei:subst">
        
<xsl:apply-templates select="tei:*" />
    
</xsl:template>
    
    <xd:doc>
        
<xd:short>Process element tei:del</xd:short>
    
</xd:doc>

    
<xsl:template match="tei:del">
        
<xsl:param name="title">
            
<xsl:apply-templates select="self::tei:*" mode="ezrc-i18n" />
        
</xsl:param>
        
<span class="subst" title="{$title}">
            
<strike>
                
<xsl:apply-templates />
            
</strike>
        
</span>
    
</xsl:template>
    
    <xd:doc>
        
<xd:short>Process element tei:add</xd:short>
    
</xd:doc>

    
<xsl:template match="tei:add">
        
<xsl:param name="title">
            
<xsl:apply-templates select="self::tei:*" mode="ezrc-i18n" />
        
</xsl:param>
        
<xsl:variable name="element">
            
<span class="subst" title="{$title}">
                
<xsl:apply-templates />
            
</span>
        
</xsl:variable>
        
<xsl:choose>
            
<xsl:when test="@place='supralinear'">
                
<sup>
                    
<xsl:copy-of select="$element" />
                
</sup>
            
</xsl:when>
            
<xsl:when test="@place='infralinear'">
                
<sub>
                    
<xsl:copy-of select="$element" />
                
</sub>
            
</xsl:when>
            
<xsl:otherwise>
                
<xsl:copy-of select="$element" />
            
</xsl:otherwise>
        
</xsl:choose>
    
</xsl:template>

    
    <xd:doc>
        
<xd:short>Process element tei:choice</xd:short>
        
<xd:detail>Show one option in-line, with alternative as HTML bubble. What is where depends
            on diplomatic/critical transcription.
</xd:detail>
    
</xd:doc>

    
<xsl:template match="tei:choice">
        
<xsl:choose>
            
<xsl:when test="tei:abbr and tei:expan">
                
<xsl:choose>
                    
<xsl:when test="ancestor::tei:div[@type='dipl']">
                        
<xsl:apply-templates select="tei:abbr">
                            
<xsl:with-param name="title">
                                
<xsl:apply-templates select="tei:abbr" mode="ezrc-i18n" />
                                
<xsl:text> → </xsl:text>
                                
<xsl:apply-templates select="tei:expan" mode="ezrc-i18n" />
                                
<xsl:text></xsl:text>
                                
<xsl:value-of select="tei:expan" />
                            
</xsl:with-param>
                        
</xsl:apply-templates>
                    
</xsl:when>
                    
<xsl:otherwise>
                        
<xsl:apply-templates select="tei:expan">
                            
<xsl:with-param name="title">
                                
<xsl:apply-templates select="tei:expan" mode="ezrc-i18n" />
                                
<xsl:text> ← </xsl:text>
                                
<xsl:apply-templates select="tei:abbr" mode="ezrc-i18n" />
                                
<xsl:text></xsl:text>
                                
<xsl:value-of select="tei:abbr" />
                            
</xsl:with-param>
                        
</xsl:apply-templates>
                    
</xsl:otherwise>
                
</xsl:choose>
            
</xsl:when>
            
<xsl:when test="tei:sic and tei:corr">
                
<xsl:choose>
                    
<xsl:when test="ancestor::tei:div[@type='dipl']">
                        
<xsl:apply-templates select="tei:sic">
                            
<xsl:with-param name="title">
                                
<xsl:apply-templates select="tei:sic" mode="ezrc-i18n" />
                                
<xsl:text></xsl:text>
                                
<xsl:apply-templates select="tei:corr" mode="ezrc-i18n" />
                                
<xsl:text>:</xsl:text>
                                
<xsl:value-of select="tei:corr" />
                            
</xsl:with-param>
                        
</xsl:apply-templates>
                    
</xsl:when>
                    
<xsl:otherwise>
                        
<xsl:apply-templates select="tei:corr">
                            
<xsl:with-param name="title">
                                
<xsl:apply-templates select="tei:corr" mode="ezrc-i18n" />
                                
<xsl:text></xsl:text>
                                
<xsl:apply-templates select="tei:sic" mode="ezrc-i18n" />
                                
<xsl:text>:</xsl:text>
                                
<xsl:value-of select="tei:sic" />
                            
</xsl:with-param>
                        
</xsl:apply-templates>
                    
</xsl:otherwise>
                
</xsl:choose>
            
</xsl:when>
            
<xsl:otherwise>
                
<xsl:apply-templates select="tei:*" />
            
</xsl:otherwise>
        
</xsl:choose>
    
</xsl:template>

    
    <xd:doc>
        
<xd:short>Process element tei:handShift</xd:short>
    
</xd:doc>

    
<xsl:template match="tei:handShift">
        
<span class="handShift">
            
<xsl:attribute name="title">
                
<xsl:value-of select="normalize-space(key('id',substring-after(@new,'#')))" />
            
</xsl:attribute>
            
<xsl:call-template name="glosstext">
              
<xsl:with-param name="ident">hand</xsl:with-param>
            
</xsl:call-template>
            
<xsl:text> </xsl:text>  
            
<xsl:value-of select="key('id',substring-after(@new,'#'))/@scribe" />
            
<xsl:text> →</xsl:text>
        
</span>
    
</xsl:template>

    
    <xd:doc>
        
<xd:short>Process element tei:pb</xd:short>
        
<xd:detail>If @facs then show image with link to large version</xd:detail>
    
</xd:doc>

    
<xsl:template match="tei:pb">
        
<span class="pagebreak">
            
<xsl:if test="@facs">
                
<xsl:variable name="facs" select="substring-after(@facs,'#')" />
                
<xsl:if test="not(key('id',$facs))">
                  
<xsl:message>
                    
<xsl:text>Cannot find tei:facs for ID </xsl:text>
                    
<xsl:value-of select="$facs" />
                  
</xsl:message>
                  
<xsl:value-of select="$facs" />
                
</xsl:if>
                
<table>
                    
<caption>
                      
<xsl:choose>
                        
<xsl:when test="key('id',$facs)/tei:desc">
                          
<xsl:value-of select="key('id',$facs)/tei:desc" />
                        
</xsl:when>
                        
<xsl:otherwise>
                          
<xsl:value-of select="$facs" />
                        
</xsl:otherwise>
                      
</xsl:choose>
                    
</caption>
                    
<tr>
                        
<td align="center">
                            
<table width="80%">
                                
<tr>
                                    
<td align="left">
                                        
<a href="{key('id',$facs)/tei:graphic[@n='small']/@url}" target="facsimile">
                                            
<xsl:text>60%</xsl:text>
                                        
</a>
                                    
</td>
                                    
<td align="right">
                                        
<a href="{key('id',$facs)/tei:graphic[@n='large']/@url}" target="facsimile">
                                            
<xsl:text>120%</xsl:text>
                                        
</a>
                                    
</td>
                                
</tr>
                            
</table>
                        
</td>
                    
</tr>
                    
<tr>
                        
<td align="center">
                            
<a href="{key('id',$facs)/tei:graphic[@n='small']/@url}" target="facsimile">
                                
<img src="{key('id',$facs)/tei:graphic[@n='thumb']/@url}" />
                            
</a>
                        
</td>
                    
</tr>
                
</table>
            
</xsl:if>
            
<xsl:call-template name="makeAnchor" />
        
</span>
    
</xsl:template>

    
<xsl:template match="tei:note[@place='margin-left']">
        
<span class="leftnote">
            
<xsl:apply-templates />
        
</span>
    
</xsl:template>
    
<xsl:template match="tei:note[@place='margin-right']">
        
<span class="rightnote">
            
<xsl:apply-templates />
        
</span>
    
</xsl:template>
    
<xsl:template match="tei:note[@place='margin-bot']">
        
<span class="bottomnote">
            
<xsl:apply-templates />
        
</span>
    
</xsl:template>

    
<!--
    <xd:doc>
        <xd:short>Process SP specific elements tei:note</xd:short>
    </xd:doc>
    <xsl:template match="tei:note[@place='foot']">
        <br/>
        <span class="footnote">
            <xsl:apply-templates/>
        </span>
        <br/>
    </xsl:template>
    
-->
    
    <xd:doc>
        
<xd:short>Process editorial note</xd:short>
        
<xd:detail> </xd:detail>
    
</xd:doc>

    
<xsl:template match="tei:note[@place='end'] | tei:note[@place='foot']">
        
<xsl:variable name="identifier">
            
<xsl:text>Note</xsl:text>
            
<xsl:call-template name="noteID" />
        
</xsl:variable>
        
<xsl:call-template name="makeAnchor">
            
<xsl:with-param name="name" select="concat($identifier,'_return')" />
        
</xsl:call-template>
        
<xsl:choose>
            
<xsl:when test="$footnoteFile='true'">
                
<a class="notelink" href="{$masterFile}-notes.html#{$identifier}">
                    
<xsl:attribute name="title">
                        
<xsl:value-of select="substring(normalize-space(.),1,100)" />
                        
<xsl:text>...</xsl:text>
                    
</xsl:attribute>
                    
<sup>
                        
<xsl:call-template name="noteN" />
                    
</sup>
                
</a>
            
</xsl:when>
            
<xsl:otherwise>
                
<a class="notelink" href="#{$identifier}">
                    
<!-- ET added -->
                    
<xsl:attribute name="title">
                        
<xsl:value-of select="substring(normalize-space(descendant-or-self::text()),1,40)" />
                        
<xsl:text>...</xsl:text>
                    
</xsl:attribute>
                    
<sup>
                        
<xsl:call-template name="noteN" />
                    
</sup>
                
</a>
            
</xsl:otherwise>
        
</xsl:choose>
    
</xsl:template>

    
    <xd:doc>
        
<xd:short>Print Notes, [html] </xd:short>
        
<xd:detail> </xd:detail>
    
</xd:doc>

    
<xsl:template name="printNotes">
        
<xsl:choose>
            
<xsl:when test="$footnoteFile='true' and ancestor-or-self::tei:TEI/tei:text/descendant::tei:note[@place='end']">
                
<xsl:variable name="BaseFile">
                    
<xsl:value-of select="$masterFile" />
                    
<xsl:call-template name="addCorpusID" />
                
</xsl:variable>
                
<xsl:call-template name="outputChunk">
                    
<xsl:with-param name="ident">
                        
<xsl:value-of select="concat($BaseFile,'-notes')" />
                    
</xsl:with-param>
                    
<xsl:with-param name="content">
                        
<xsl:call-template name="writeNotes" />
                    
</xsl:with-param>
                
</xsl:call-template>
            
</xsl:when>
            
<xsl:when test="self::tei:div">
                
<xsl:variable name="depth">
                    
<xsl:apply-templates mode="depth" select="." />
                
</xsl:variable>
                
<xsl:choose>
                    
<xsl:when test="$depth &lt; $splitLevel">
                        
<xsl:if test="child::*[not(self::tei:div)]/descendant::tei:note[@place='end']">
                            
<div class="notes">
                                
<div class="noteHeading">
                                    
<xsl:call-template name="i18n">
                                        
<xsl:with-param name="word">noteHeading</xsl:with-param>
                                    
</xsl:call-template>
                                
</div>
                                
<xsl:apply-templates mode="printnotes" select="child::*[not(self::tei:div)]/descendant::tei:note[@place='end']" />
                            
</div>
                        
</xsl:if>
                    
</xsl:when>
                    
<xsl:otherwise>
                        
<xsl:if test="descendant::tei:note[@place='end']">
                            
<div class="notes">
                                
<div class="noteHeading">
                                    
<xsl:call-template name="i18n">
                                        
<xsl:with-param name="word">noteHeading</xsl:with-param>
                                    
</xsl:call-template>
                                
</div>
                                
<xsl:apply-templates mode="printnotes" select="descendant::tei:note[@place='end']" />
                            
</div>
                        
</xsl:if>
                    
</xsl:otherwise>
                
</xsl:choose>
            
</xsl:when>
            
<xsl:when test="$splitLevel &gt;-1 and $requestedID='' and $STDOUT='true'">
                
<xsl:for-each select="descendant-or-self::text/*[1]/*[1]">
                    
<xsl:call-template name="printNotes" />
                
</xsl:for-each>
            
</xsl:when>
            
<xsl:when test="$splitLevel &gt;-1 and (self::tei:TEI or self::tei:text)" />
            
<xsl:otherwise>
                
<xsl:if test="descendant::tei:note[@place='end']">
                    
<xsl:value-of select="name()" />
                    
<div class="notes">
                        
<div class="noteHeading">
                            
<xsl:call-template name="i18n">
                                
<xsl:with-param name="word">noteHeading</xsl:with-param>
                            
</xsl:call-template>
                        
</div>
                        
<xsl:apply-templates mode="printnotes" select="descendant::tei:note[@place='end']" />
                    
</div>
                
</xsl:if>
            
</xsl:otherwise>
        
</xsl:choose>
    
</xsl:template>
    
    
    <xd:doc>
        
<xd:short>Process elements tei:note</xd:short>
        
<xd:detail> </xd:detail>
    
</xd:doc>

    
<xsl:template match="tei:note">
        
<xsl:variable name="identifier">
            
<xsl:text>Note</xsl:text>
            
<xsl:call-template name="noteID" />
        
</xsl:variable>
        
<xsl:choose>
            
<xsl:when test="@place='marg'">
                
<span class="margnote">
                    
<xsl:call-template name="makeAnchor">
                        
<xsl:with-param name="name" select="$identifier" />
                    
</xsl:call-template>
                    
<xsl:apply-templates />
                
</span>
            
</xsl:when>
            
<xsl:when test="@place='inline'">
                
<xsl:call-template name="makeAnchor">
                    
<xsl:with-param name="name" select="$identifier" />
                
</xsl:call-template>
                
<xsl:text> (</xsl:text>
                
<xsl:apply-templates />
                
<xsl:text>)</xsl:text>
            
</xsl:when>
            
<xsl:when test="@place='display'">
                
<xsl:call-template name="makeAnchor">
                    
<xsl:with-param name="name" select="$identifier" />
                
</xsl:call-template>
                
<blockquote>
                    
<xsl:choose>
                        
<xsl:when test="@rend">
                            
<xsl:attribute name="class">
                                
<xsl:value-of select="@rend" />
                            
</xsl:attribute>
                        
</xsl:when>
                        
<xsl:when test="@rendition">
                            
<xsl:call-template name="applyRendition" />
                        
</xsl:when>
                        
<xsl:otherwise>
                            
<xsl:attribute name="class">
                                
<xsl:text>note</xsl:text>
                            
</xsl:attribute>
                        
</xsl:otherwise>
                    
</xsl:choose>
                    
<p>
                        
<xsl:apply-templates />
                    
</p>
                
</blockquote>
            
</xsl:when>
            
<xsl:when test="@place='end' or $autoEndNotes='true'">
                
<xsl:call-template name="makeAnchor">
                    
<xsl:with-param name="name" select="concat($identifier,'_return')" />
                
</xsl:call-template>
                
<xsl:choose>
                    
<xsl:when test="$footnoteFile='true'">
                        
<a class="notelink" title="Na opombo" href="{$masterFile}-notes.html#{$identifier}">
                            
<sup>
                                
<xsl:call-template name="noteN" />
                            
</sup>
                        
</a>
                    
</xsl:when>
                    
<xsl:otherwise>
                        
<a class="notelink" title="Na opombo" href="#{$identifier}">
                            
<sup>
                                
<xsl:call-template name="noteN" />
                            
</sup>
                        
</a>
                    
</xsl:otherwise>
                
</xsl:choose>
            
</xsl:when>
            
<xsl:when test="ancestor::tei:bibl"> (<xsl:apply-templates /></xsl:when>
            
<xsl:otherwise>
                
<xsl:call-template name="makeAnchor">
                    
<xsl:with-param name="name" select="$identifier" />
                
</xsl:call-template>
                
<xsl:text> [</xsl:text>
                
<xsl:call-template name="i18n">
                    
<xsl:with-param name="word">Note</xsl:with-param>
                
</xsl:call-template>
                
<xsl:text></xsl:text>
                
<xsl:apply-templates />
                
<xsl:text>]</xsl:text>
            
</xsl:otherwise>
        
</xsl:choose>
    
</xsl:template>

    
    <xd:doc>
        
<xd:short>Process elements tei:note</xd:short>
        
<xd:detail> </xd:detail>
    
</xd:doc>

    
<xsl:template match="tei:note" mode="printnotes">
        
<!--xsl:if test="not(ancestor::tei:bibl)"-->
            
<xsl:variable name="identifier">
                
<xsl:text>Note</xsl:text>
                
<xsl:call-template name="noteID" />
            
</xsl:variable>
            
<xsl:variable name="parent">
                
<xsl:call-template name="locateParentdiv" />
            
</xsl:variable>
            
<xsl:if test="$verbose='true'">
                
<xsl:message>Note <xsl:value-of select="$identifier" />
                    
<xsl:text> with parent </xsl:text>
                    
<xsl:value-of select="$parent" /></xsl:message>
            
</xsl:if>
            
<div class="note">
                
<xsl:call-template name="makeAnchor">
                    
<xsl:with-param name="name" select="$identifier" />
                
</xsl:call-template>
                
<span class="noteLabel">
                  
<a class="link_return" title="Nazaj na besedilo" href="#{concat($identifier,'_return')}">
                    
<xsl:call-template name="noteN" />
                  
</a>
                  
<xsl:text></xsl:text>
                
</span>
                
<div class="noteBody">
                    
<xsl:apply-templates />
                    
<!--xsl:if test="@resp">
                        <xsl:text> (</xsl:text>
                        <xsl:value-of select="key('id',substring-after(@resp,'#'))"/>
                        <xsl:text>)</xsl:text>
                    </xsl:if
-->
                
</div>
                
<!--xsl:if test="$footnoteBackLink= 'true'">
                    <br/>
                    <span class="small">
                    <xsl:text>[</xsl:text>
                    <a class="link_return" title="Nazaj na besedilo"
                        href="#{concat($identifier,'_return')}">
                        <xsl:text>Nazaj na besedilo &#8593;</xsl:text>
                    </a>
                    <xsl:text>]</xsl:text>
                    </span>
                </xsl:if
-->
            
</div>
        
<!--/xsl:if-->
    
</xsl:template>

    
<xsl:template match="text()">
        
<xsl:choose>
            
<xsl:when test="ancestor::tei:note[@place='end'] or ancestor::tei:abbr or ancestor::tei:expan or ancestor::tei:sic or ancestor::tei:corr or ancestor::tei:add or ancestor::tei:del or ancestor::tei:supplied or ancestor::tei:gap or ancestor::tei:unclear">
                
<xsl:value-of select="." />
            
</xsl:when>
            
<xsl:when test="ancestor::tei:*[@type='dipl'] and normalize-space(.)">
                
<span class="dipl">
                    
<xsl:value-of select="." />
                
</span>
            
</xsl:when>
            
<xsl:when test="ancestor::tei:*[@type='crit'] and normalize-space(.)">
                
<span class="crit">
                    
<xsl:value-of select="." />
                
</span>
            
</xsl:when>
            
<xsl:otherwise>
                
<xsl:value-of select="." />
            
</xsl:otherwise>
        
</xsl:choose>
    
</xsl:template>

  
    <xd:doc>
    
<xd:short>Process element tei:head in plain mode</xd:short>
    
<xd:detail>Doesn't seem to do much of anything!</xd:detail>
  
</xd:doc>

  
<xsl:template match="tei:head" mode="plain">
    
<xsl:if test="preceding-sibling::tei:head">
      
<xsl:text> · </xsl:text>
    
</xsl:if>
    
<xsl:apply-templates mode="plain" />
    
<xsl:text> </xsl:text>
  
</xsl:template>

  
    <xd:doc>
    
<xd:short>[common] Making a heading for something</xd:short>
    
<xd:param name="minimal">whether to display headings</xd:param>
    
<xd:param name="toc">whether this is making a TOC entry</xd:param>
    
<xd:param name="display">detail of display (full, simple, plain), ie
    whether markup is followed
</xd:param>
    
<xd:detail>eZISS: trying to make it put some space between successive heads</xd:detail>
  
</xd:doc>

  
<xsl:template name="header">
    
<xsl:param name="minimal">false</xsl:param>
    
<xsl:param name="toc" />
    
<xsl:param name="display">full</xsl:param>
    
<xsl:variable name="depth">
      
<xsl:apply-templates mode="depth" select="." />
    
</xsl:variable>
    
<xsl:call-template name="formatHeadingNumber">
      
<xsl:with-param name="toc">
        
<xsl:value-of select="$toc" />
      
</xsl:with-param>
      
<xsl:with-param name="text">
    
<xsl:choose>
      
<xsl:when test="local-name(.) = 'TEI'" />
      
<xsl:when test="local-name(.) = 'TEI.2'" />
      
<xsl:when test="$depth &gt; $numberHeadingsDepth"> </xsl:when>
      
<xsl:when test="ancestor::tei:back">
        
<xsl:if test="not($numberBackHeadings='')">
          
<xsl:call-template name="i18n">
            
<xsl:with-param name="word">appendixWords</xsl:with-param>
          
</xsl:call-template>
          
<xsl:text> </xsl:text>
          
<xsl:call-template name="numberBackDiv" />
          
<xsl:if test="$minimal='false'">
            
<xsl:value-of select="$numberSpacer" />
          
</xsl:if>
        
</xsl:if>
      
</xsl:when>
      
<xsl:when test="ancestor::tei:front">
        
<xsl:if test="not($numberFrontHeadings='')">
          
<xsl:call-template name="numberFrontDiv">
            
<xsl:with-param name="minimal">
              
<xsl:value-of select="$minimal" />
            
</xsl:with-param>
          
</xsl:call-template>
        
</xsl:if>
      
</xsl:when>
      
<xsl:when test="$numberHeadings ='true'">
        
<xsl:choose>
          
<xsl:when test="$prenumberedHeadings='true'">
            
<xsl:value-of select="@n" />
          
</xsl:when>
          
<xsl:otherwise>
            
<xsl:call-template name="numberBodyDiv" />
          
</xsl:otherwise>
        
</xsl:choose>
        
<xsl:if test="$minimal='false'">
          
<xsl:value-of select="$headingNumberSuffix" />
        
</xsl:if>
      
</xsl:when>
    
</xsl:choose>
      
</xsl:with-param>
    
</xsl:call-template>
    
<xsl:if test="$minimal='false'">
      
<xsl:choose>
        
<xsl:when test="local-name(.) = 'TEI' or local-name(.)='TEI.2'">
          
<xsl:apply-templates select="tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:title[1]" />
        
</xsl:when>
        
<xsl:when test="not(tei:head) and @n">
          
<xsl:value-of select="@n" />
        
</xsl:when>
        
<xsl:when test="not($toc='')">
          
<xsl:call-template name="makeInternalLink">
            
<xsl:with-param name="dest">
              
<xsl:value-of select="$toc" />
            
</xsl:with-param>
            
<xsl:with-param name="class">
              
<xsl:value-of select="$class_toc" />
              
<xsl:text> </xsl:text>
              
<xsl:value-of select="concat($class_toc,'_',$depth)" />
            
</xsl:with-param>
            
<xsl:with-param name="body">
              
<xsl:choose>
                
<xsl:when test="$autoHead='true'">
                  
<xsl:call-template name="autoMakeHead" />
                
</xsl:when>
                
<xsl:otherwise>
                     
<xsl:apply-templates mode="plain" select="tei:head" />
                
</xsl:otherwise>
              
</xsl:choose>
            
</xsl:with-param>
          
</xsl:call-template>
        
</xsl:when>
        
<xsl:when test="$autoHead='true'">
          
<xsl:call-template name="autoMakeHead" />
        
</xsl:when>
        
<xsl:when test="$display='plain'">
          
<xsl:apply-templates mode="plain" select="tei:head" />
          
<!--xsl:for-each select="tei:head">
            <xsl:apply-templates mode="plain"/>
          </xsl:for-each
-->
        
</xsl:when>
        
<xsl:when test="$display='simple'">
          
<xsl:apply-templates mode="plain" select="tei:head" />
          
<!--xsl:for-each select="tei:head">
            <xsl:apply-templates mode="plain"/>
          </xsl:for-each
-->
        
</xsl:when>
        
<xsl:otherwise>
          
<xsl:for-each select="tei:head">
            
<xsl:apply-templates />
            
<xsl:text> </xsl:text>
            
<br />
          
</xsl:for-each>
        
</xsl:otherwise>
      
</xsl:choose>
    
</xsl:if>
  
</xsl:template>

  
<xsl:template name="makeTEILink">
    
<xsl:param name="ptr" />
    
<!-- is this a ptr or a ref? -->
    
<xsl:choose>
      
<!-- If there is a target attribute starting with #, it is always a local reference -->
      
<xsl:when test="@target and starts-with(@target,'#')">
        
<xsl:call-template name="makeInternalLink">
          
<xsl:with-param name="target" select="substring-after(@target,'#')" />
          
<xsl:with-param name="ptr" select="$ptr" />
          
<xsl:with-param name="dest">
            
<xsl:call-template name="generateEndLink">
              
<xsl:with-param name="where">
                
<xsl:value-of select="substring-after(@target,'#')" />
              
</xsl:with-param>
            
</xsl:call-template>
          
</xsl:with-param>
          
<!-- ET: added call to body parameter -->
          
<xsl:with-param name="body">
            
<xsl:if test="$ptr='true'">
              
<sup>
                
<xsl:text></xsl:text>
              
</sup>
            
</xsl:if>
          
</xsl:with-param>
        
</xsl:call-template>
      
</xsl:when>
      
<!-- other uses of target means it is external -->
      
<xsl:when test="@target">
        
<xsl:call-template name="makeExternalLink">
          
<xsl:with-param name="ptr" select="$ptr" />
          
<xsl:with-param name="dest">
            
<xsl:value-of select="@target" />
          
</xsl:with-param>
        
</xsl:call-template>
      
</xsl:when>
      
<!-- If there is a url attribute starting with #, it is a local
       reference 
-->
      
<xsl:when test="@url and starts-with(@url,'#')">
        
<xsl:call-template name="makeInternalLink">
          
<xsl:with-param name="target" select="substring-after(@url,'#')" />
          
<xsl:with-param name="ptr" select="$ptr" />
          
<xsl:with-param name="dest">
            
<xsl:call-template name="generateEndLink">
              
<xsl:with-param name="where">
                
<xsl:value-of select="substring-after(@url,'#')" />
              
</xsl:with-param>
            
</xsl:call-template>
          
</xsl:with-param>
        
</xsl:call-template>
      
</xsl:when>
      
<!-- otherwise it is an external URL -->
      
<xsl:when test="@url">
        
<xsl:call-template name="makeExternalLink">
          
<xsl:with-param name="ptr" select="$ptr" />
          
<xsl:with-param name="dest">
            
<xsl:value-of select="@url" />
          
</xsl:with-param>
        
</xsl:call-template>
      
</xsl:when>
      
<xsl:otherwise>
        
<xsl:apply-templates />
      
</xsl:otherwise>
    
</xsl:choose>
  
</xsl:template>
  
    <xd:doc>
    
<xd:short>[html] create an internal link</xd:short>
    
<xd:param name="target">target</xd:param>
    
<xd:param name="ptr">ptr</xd:param>
    
<xd:param name="dest">dest</xd:param>
    
<xd:param name="body">body</xd:param>
    
<xd:param name="class">class</xd:param>
    
<xd:detail>ET: changed not to display text with ptr but only an arrow</xd:detail>
  
</xd:doc>

  
<xsl:template name="makeInternalLink">
    
<xsl:param name="target" />
    
<xsl:param name="ptr" />
    
<xsl:param name="dest" />
    
<xsl:param name="body" />
    
<xsl:param name="class">
      
<xsl:text>link_</xsl:text>
      
<xsl:value-of select="local-name(.)" />
    
</xsl:param>
    
<xsl:variable name="W">
      
<xsl:choose>
        
<xsl:when test="$target">
          
<xsl:value-of select="$target" />
        
</xsl:when>
        
<xsl:when test="contains($dest,'#')">
          
<xsl:value-of select="substring-after($dest,'#')" />
        
</xsl:when>
        
<xsl:otherwise>
          
<xsl:value-of select="$dest" />
        
</xsl:otherwise>
      
</xsl:choose>
    
</xsl:variable>
    
<!--xsl:message>
      <xsl:text> ptr: </xsl:text><xsl:value-of select="$ptr"/>
      <xsl:text> dest: </xsl:text><xsl:value-of select="$dest"/>
      <xsl:text> body: </xsl:text><xsl:value-of select="$body"/>
      <xsl:text> class: </xsl:text><xsl:value-of select="$class"/>
      <xsl:text> W: </xsl:text><xsl:value-of select="$W"/>
    </xsl:message
-->
    
<xsl:choose>
      
<xsl:when test="$dest=''">
        
<xsl:choose>
          
<xsl:when test="not($body='')">
            
<xsl:copy-of select="$body" />
          
</xsl:when>
          
<xsl:when test="$ptr='true'">
            
<xsl:apply-templates mode="xref" select="key('IDS',$W)">
              
<xsl:with-param name="minimal" select="$minimalCrossRef" />
            
</xsl:apply-templates>
          
</xsl:when>
          
<xsl:otherwise>
            
<xsl:apply-templates />
          
</xsl:otherwise>
        
</xsl:choose>
      
</xsl:when>
      
<xsl:otherwise>
        
<a>
          
<xsl:call-template name="htmlAttributes" />
            
<xsl:choose>
              
<xsl:when test="@rend">
                
<xsl:attribute name="class">
                  
<xsl:value-of select="@rend" />
                
</xsl:attribute>
              
</xsl:when>
              
<xsl:when test="@rendition">
                
<xsl:call-template name="applyRendition" />
              
</xsl:when>
              
<xsl:otherwise>
                
<xsl:attribute name="class">
                  
<xsl:value-of select="$class" />
                
</xsl:attribute>
              
</xsl:otherwise>
            
</xsl:choose>
          
<xsl:attribute name="href">
            
<xsl:choose>
              
<xsl:when test="starts-with($dest,'#') or contains($dest,'.html') or contains($dest,'ID=')">
                
<xsl:value-of select="$dest" />
              
</xsl:when>
              
<xsl:otherwise>
                
<xsl:apply-templates mode="generateLink" select="key('IDS',$W)" />
              
</xsl:otherwise>
            
</xsl:choose>
          
</xsl:attribute>
          
<xsl:for-each select="key('IDS',$W)">
            
<xsl:attribute name="title">
              
<xsl:variable name="title">
                
<xsl:choose>
                  
<xsl:when test="starts-with(local-name(.),'div')">
                    
<!--xsl:value-of select="normalize-space(tei:head)"/-->
                    
<xsl:apply-templates mode="xref" select=".">
                      
<xsl:with-param name="minimal" select="$minimalCrossRef" />
                    
</xsl:apply-templates>
                  
</xsl:when>
                  
<xsl:otherwise>
                    
<xsl:value-of select="normalize-space(text())" />
                  
</xsl:otherwise>
                
</xsl:choose>
              
</xsl:variable>
              
<xsl:value-of select="normalize-space($title)" />
            
</xsl:attribute>
          
</xsl:for-each>
          
<xsl:choose>
            
<xsl:when test="not($body='')">
              
<xsl:copy-of select="$body" />
            
</xsl:when>
            
<xsl:when test="$ptr='true' and count(key('IDS',$W))&gt;0">
              
<xsl:apply-templates mode="xref" select="key('IDS',$W)">
                
<xsl:with-param name="minimal" select="$minimalCrossRef" />
              
</xsl:apply-templates>
            
</xsl:when>
            
<xsl:when test="$ptr='true'">
              
<xsl:text>??</xsl:text>
            
</xsl:when>
            
<xsl:otherwise>
              
<xsl:apply-templates />
            
</xsl:otherwise>
          
</xsl:choose>
        
</a>
      
</xsl:otherwise>
    
</xsl:choose>
  
</xsl:template>

  
    <xd:doc>
    
<xd:short>Process elements tei:note</xd:short>
    
<xd:detail>ET: corrected, but still doesn't work if note referred to in some other file!</xd:detail>
  
</xd:doc>

  
<xsl:template match="tei:note" mode="generateLink">
    
<xsl:text>#</xsl:text>
    
<!--xsl:call-template name="noteN"/-->
    
<xsl:text>Note</xsl:text>
    
<xsl:call-template name="noteID" />
  
</xsl:template>
</xsl:stylesheet>






































v