<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
    xmlns:tei="http://www.tei-c.org/ns/1.0"
    xmlns:mets="http://www.loc.gov/METS/"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:mods="http://www.loc.gov/mods/v3"
    xmlns:exist="http://exist.sourceforge.net/NS/exist"
    exclude-result-prefixes="tei mets xlink exist" 
    version="1.0">
    
    <!-- Einbindung der Standard-Templates und Variablen -->
    <xsl:import href="http://diglib.hab.de/rules/styles/param.xsl"/>
    <xsl:import href="http://diglib.hab.de/rules/styles/tei-phraselevel.xsl"/>
  

    <xsl:output encoding="UTF-8" indent="no" method="html"/>
    
    <xsl:strip-space elements="*"/>
    <xsl:param name="dir"/>
    <xsl:param name="q"/>
    <xsl:param name="qtype"/>
    <xsl:param name="distype"/>
    <xsl:param name="pvID"/>
    <xsl:param name="footerXML"/>
    <xsl:param name="footerXSL"/>
    <xsl:param name="view"/>
    <xsl:variable name="metsfile"><xsl:value-of select="concat('http://diglib.hab.de/',$dir,'/mets.xml')"/></xsl:variable>
    <xsl:variable name="smallcase" select="'&#173;'" />
    <xsl:variable name="uppercase" select="'-'" />
    
    
    <xsl:template match="/">

   
   
        

        <html>
            <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <title>WDB</title>
                <link rel="stylesheet" type="text/css" href="http://diglib.hab.de/edoc/ed000211/layout/navigator23.css"/>
                <link rel="stylesheet" type="text/css" media="print" href="http://diglib.hab.de/edoc/ed000211/layout/print.css"/>
                <script src="http://diglib.hab.de/navigator.js" type="text/javascript"><noscript>please activate javascript to enable wdb functions</noscript></script>
                <!-- Steyer: Einbinden des Junicode-Schriftsatzes -->
               
                <style>
                @font-face {
                font-family:'junicode';
                font-style: normal;
                 <!-- Herunterladen eines gleichnamigen lokalen Schriftsatzes verhindern -->
                
                src: local ('Junicode');
                <!-- Einbinden -->
                src: url('http://diglib.hab.de/rules/fonts/Junicode.woff') format('woff');
                
                </style>
                <!-- Ende Ergänzung -->
               
            </head>
            
            <body>
                <!--  Dokumentkopf -->
                <div id="doc_header">
                   <!-- <div style="margin-bottom:0.2em;padding:0;letter-spacing:0.3em;">Text </div> -->
                <hr style="margin:0;padding:0;height:1px;"/>
                    <div class="menue_page" style="font-size:smaller;text-align:right;">
                        <xsl:text>[</xsl:text>
                        <a>
                            <xsl:choose>
                                <xsl:when test="$view = 'orig'">
                                    <xsl:attribute name="href">
                                        <xsl:value-of select="$content"/><xsl:text>?dir=edoc/ed000211&amp;distype=optional&amp;xml=</xsl:text><xsl:value-of select="substring-after($footerXML,'http://diglib.hab.de/edoc/ed000211/')"/><xsl:text>&amp;xsl=</xsl:text><xsl:value-of select="$footerXSL"/><xsl:text></xsl:text>
                                    </xsl:attribute>
                                    <xsl:text>Ansicht mit Zeilenumbrüchen</xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:attribute name="href">
                                        <xsl:value-of select="$content"/><xsl:text>?dir=edoc/ed000211&amp;distype=optional&amp;xml=</xsl:text><xsl:value-of select="substring-after($footerXML,'http://diglib.hab.de/edoc/ed000211/')"/><xsl:text>&amp;xsl=</xsl:text><xsl:value-of select="$footerXSL"/><xsl:text>&amp;view=orig</xsl:text>
                                    </xsl:attribute>
                                    <xsl:text>Ansicht ohne Zeilenumbrüche</xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                        </a>
                        <xsl:text>]</xsl:text>
                    </div>
                    <xsl:choose>  
                                <xsl:when test="document($metsfile)//mets:rightsMD[@ID=document($metsfile)//mets:div[@TYPE='transcripton']/@ADMID]/mets:mdRef/@xlink:href">
                                    <a>
                                       <xsl:attribute name="href">
                                            <xsl:value-of select="document($metsfile)//mets:rightsMD[@ID=document($metsfile)//mets:div[@TYPE='transcripton']/@ADMID]/mets:mdRef/@xlink:href"/>
                                       </xsl:attribute>
                                       copyright
                                    </a>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="document($metsfile)//mets:rightsMD[@ID=document($metsfile)//mets:div[@TYPE='transcripton']/@ADMID]/mets:mdWrap/mets:xmlData"/>
                                </xsl:otherwise>
                            </xsl:choose>
                    </div>
                <!-- Titel -->
                <div id="caption">
                    <div style="font-size:1.2em; font-weight:bold">
                        <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:title"/>
                        <xsl:text> </xsl:text>
                    </div>
                    <div>
                        <xsl:choose>
                            <xsl:when test="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:author/tei:name/tei:forename">
                           
                        <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:author/tei:name/tei:forename"/><xsl:text> </xsl:text><xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:author/tei:name/tei:surname"/>
                        <xsl:text> </xsl:text>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:if test="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:author/tei:name[1]/tei:name">
                                   <xsl:text>verfasst von </xsl:text> <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:author/tei:name[1]/tei:name"/>
                                    <xsl:if test="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:author/tei:name[2]/tei:name"><xsl:text>/ </xsl:text> <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:author/tei:name[2]/tei:name"/><xsl:text> </xsl:text></xsl:if>
                                </xsl:if>
                            </xsl:otherwise>
                        </xsl:choose>
                    </div>
                   
                </div>
             
                <!-- Inhaltsuebersicht -->
                <a href="javascript:switchlayer('headings');">
                    <div style="margin: 1em 0 1em 0;">[Inhaltsverzeichnis]</div>
                </a> 
                <div id="headings" style="display:none;border:1px black solid;background-color:#EEE;">
                    <ul>
                        <xsl:for-each select="/tei:TEI/tei:text/tei:body//tei:div/tei:head">
                            <li>
                                <!--<xsl:number level="multiple" count="tei:div" format="1.1. "/>-->
                                <a>
                                    <xsl:attribute name="href"><xsl:text>#hd</xsl:text><xsl:number level="any"/></xsl:attribute>
                                    <xsl:value-of select="."/>
                                </a>
                                <xsl:apply-templates select="../tei:argument/tei:p">
                                    <xsl:with-param name="caption">true</xsl:with-param>
                                </xsl:apply-templates>
                            </li>
                            
                        </xsl:for-each>
                    </ul>
                
                </div>
            
               <xsl:choose>
                   <xsl:when test="tei:TEI/tei:text/tei:body/tei:div/tei:p/tei:note[@place='margin-right'] |tei:TEI/tei:text/tei:body/tei:div/tei:div/tei:p/tei:note[@place='margin-right'] ">
           
                       <div class="content" style="font-family:'junicode'; text-align:justify;  padding-left: 150px; ">
                           <!-- Haupttext -->
                           <xsl:apply-templates select="tei:TEI/tei:text"/>
                       </div>
                   </xsl:when>
                   <xsl:otherwise>
                       <div class="content" style="font-family:'junicode'; text-align:justify;">
                           <!-- Haupttext -->
                           <xsl:apply-templates select="tei:TEI/tei:text"/>
                       </div> 
                   </xsl:otherwise>
               </xsl:choose>
               
                    
                <!-- Marginalien als Fussnoten ausgeben  -->
   
                <div style="background-color:#EEE;">
                    <xsl:if test="tei:TEI/tei:text/tei:body//tei:note[@place]">
                        <hr style="height:1px;margin:1em 0 1em; 0"/>
                        <div
                            style="font-size:13pt;
                            font-family:junicode,sans-serif;
                            color:black;
                            font-weight:600;
                            text-align:left;"
                            >Marginalien</div>
                    </xsl:if>
                    <div
                        style=" position:relative;
                        margin-left:0px;
                        margin-right:0px;
                        margin-top:0px;
                        margin-bottom:0px;
                        font-family:'junicode',sans-serif;
                        font-size:11pt;">
                        
                        <a name="footnotes"></a>
                        <xsl:choose>
                            <xsl:when test="tei:TEI/tei:text/tei:body/tei:div[@place]">
                                <!--  Wenn es einen Fussnotenbereich gibt -->
                                <xsl:apply-templates select="tei:TEI/tei:text/tei:body/tei:div[@place]"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <!--  andernfalls notes auswerten -->
                                <xsl:for-each select="tei:TEI/tei:text/tei:body//tei:note[@place]">
                                    <div class="footnotes">
                                        <a>
                                            <xsl:attribute name="name">
                                                <xsl:text>mn</xsl:text>
                                                <xsl:number level="any" count="tei:note[@place]" format="a"/>
                                            </xsl:attribute>
                                            <a>
                                                <xsl:attribute name="href">
                                                    <xsl:text>#mna</xsl:text><xsl:number level="any" count="tei:note[@place]" format="a"/>
                                                </xsl:attribute>
                                                <span style="font-size:9pt;vertical-align:super;color:red;"><xsl:number level="any" count="tei:note[@place]" format="a"/></span>
                                            </a>
                                            <xsl:apply-templates/>
                                        </a>
                                    </div>
                                    
                                </xsl:for-each>
                            </xsl:otherwise>
                        </xsl:choose>
                    </div>
                </div>
                
                <!-- Textapparat  -->
                
                <div style="background-color:#EEE;">
                    <xsl:if test="tei:TEI/tei:text/tei:body//tei:note[@type='annotation']">
                        <hr style="height:1px;margin:1em 0 1em; 0"/>
                        <div
                            style="font-size:13pt;
                            font-family:junicode,sans-serif;
                            color:black;
                            font-weight:600;
                            text-align:left;"
                            >Textapparat</div>
                    </xsl:if>
                    <div
                        style=" position:relative;
                        margin-left:0px;
                        margin-right:0px;
                        margin-top:0px;
                        margin-bottom:0px;
                        font-family:junicode,sans-serif;
                        font-size:11pt;">
                        
                        <xsl:choose>
                            <xsl:when test="tei:TEI/tei:text/tei:body/tei:div[@type='annotation']">
                                <!--  Wenn es einen Fussnotenbereich gibt -->
                                <xsl:apply-templates
                                    select="tei:TEI/tei:text/tei:body/tei:div[@type='annotation']"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <!--  andernfalls notes auswerten -->
                                <xsl:for-each
                                    select="tei:TEI/tei:text/tei:body//tei:note[@type='annotation']">
                                    <div>
                                        <a>
                                            <xsl:attribute name="name">
                                                <xsl:text>an</xsl:text>
                                                <xsl:number level="any" format="a"
                                                    count="tei:note[@type ='annotation']"/>
                                            </xsl:attribute>
                                            <a>
                                                <xsl:attribute name="href">
                                                    <xsl:text>#ana</xsl:text>
                                                    <xsl:number level="any" format="a"
                                                        count="tei:note[@type ='annotation']"/>
                                                </xsl:attribute>
                                                <span
                                                    style="font-size:9pt;vertical-align:super;color:blue;">
                                                    <xsl:number level="any" format="a" from="tei:div"
                                                        count="tei:note[@type ='annotation']"/>
                                                </span>
                                            </a>
                                            <xsl:apply-templates/>
                                        </a>
                                    </div>
                                </xsl:for-each>
                            </xsl:otherwise>
                        </xsl:choose>
                    </div>
                </div>
                <!-- Fussnotenbereich  -->
                
                <!-- Kommentare -->
                <div style="background-color:#EEE;">
                    <xsl:if test="tei:TEI/tei:text/tei:body//tei:note[@type='footnote']">
                        <hr style="height:1px;margin:1em 0 1em; 0"/>
                        <div
                            style="font-size:13pt;
                            font-family:junicode,sans-serif;
                            color:black;
                            font-weight:600;
                            text-align:left;"
                            >Kommentar</div>
                    </xsl:if>
                    <div
                        style=" position:relative;
                        margin-left:0px;
                        margin-right:0px;
                        margin-top:0px;
                        margin-bottom:0px;
                        font-family:'junicode',sans-serif;
                        font-size:11pt;">
                    
                    <a name="footnotes"></a>
                    <xsl:choose>
                        <xsl:when test="tei:TEI/tei:text/tei:body/tei:div[@type='footnotes']">
                            <!--  Wenn es einen Fussnotenbereich gibt -->
                            <xsl:apply-templates select="tei:TEI/tei:text/tei:body/tei:div[@type='footnotes']"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <!--  andernfalls notes auswerten -->
                            <xsl:for-each select="tei:TEI/tei:text/tei:body//tei:note[@type='footnote']">
                                <div class="footnotes">
                                    <a>
                                        <xsl:attribute name="name">
                                            <xsl:text>fn</xsl:text>
                                            <xsl:number level="any" count="tei:note[@type ='footnote']"/>
                                        </xsl:attribute>
                                        <a>
                                            <xsl:attribute name="href">
                                                <xsl:text>#fna</xsl:text><xsl:number level="any" count="tei:note[@type ='footnote']"/>
                                            </xsl:attribute>
                                            <span style="font-size:9pt;vertical-align:super;color:blue;"><xsl:number level="any" count="tei:note[@type ='footnote']"/></span>
                                        </a>
                                        <xsl:apply-templates/>
                                      </a>
                                </div>
                               
                            </xsl:for-each>
                          </xsl:otherwise>
                    </xsl:choose>
                    </div>
                </div>
                <div style="margin-top:2%; position:right">   <a href="#" onclick="window.print(); return false"><img src="http://diglib.hab.de/edoc/ed000213/icons/printer.png" hspace="10px"  /> Seite drucken</a></div>
                    <!-- Bibliographie -->
                    <a name="bibliography"><hr style="height:1px;margin:1em 0 1em; 0"/></a>
                    <xsl:apply-templates select="tei:TEI/tei:text/tei:back/tei:div[@type='bibliography']"/>
                    
                    <!-- footer -->
                <div id="doc_footer">
                    <xsl:choose>  
                        <xsl:when test="document($metsfile)//mets:rightsMD[@ID=document($metsfile)//mets:div/@ADMID]/mets:mdRef/@xlink:href">
                            <xsl:choose>
                            <xsl:when test="document($metsfile)//mets:rightsMD[@ID=document($metsfile)//mets:div[@type='bibliography']/@ADMID]/mets:mdRef/@xlink:href">
                            <b>
                                <xsl:text>© </xsl:text>
                                <xsl:for-each select="document($metsfile)//mods:mods/mods:name">
                                    <xsl:if test="position() > 1"><xsl:text>, </xsl:text></xsl:if>
                                    <xsl:value-of select="mods:displayForm"/>
                                </xsl:for-each>
                            </b>
                            </xsl:when>
                            </xsl:choose>
                            <div>
                                <div>
                                    <a>
                                        <xsl:attribute name="href">
                                            <xsl:value-of select="document($metsfile)//mets:rightsMD[@ID=document($metsfile)//mets:div/@ADMID]/mets:mdRef/@xlink:href"/>
                                        </xsl:attribute>
                                        <img src="http://diglib.hab.de/images/dfg_logo_schriftzug_schwarz.png" alt="image DFG" width="250px" align="left" hspace="10px"/>
                                    </a>
                                    <a>
                                        <xsl:attribute name="href">
                                            <xsl:value-of select="document($metsfile)//mets:rightsMD[@ID=document($metsfile)//mets:div/@ADMID]/mets:mdRef/@xlink:href"/>
                                        </xsl:attribute>
                                        <img src="http://diglib.hab.de/images/cc-by-sa.png" alt="image CC BY-SA licence" width="100px" align="right" hspace="10px"/>
                                    </a>
                                    
                                    
                                </div>
                                
                                
                            </div>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="document($metsfile)//mets:rightsMD[@ID=document($metsfile)//mets:div/@ADMID]/mets:mdWrap/mets:xmlData"/>
                            <div><a href="#" onclick="window.print(); return false"><img src="http://diglib.hab.de/edoc/ed000213/icons/printer.png" /> Seite drucken</a></div>
                        </xsl:otherwise>
                    </xsl:choose>
                </div>
                <div style="margin-top:5%">
                <xsl:call-template name="footer">
                    <xsl:with-param name="footerXML">
                        <xsl:value-of select="$footerXML"/>
                    </xsl:with-param>
                    <xsl:with-param name="footerXSL">
                        <xsl:value-of select="$footerXSL"/>
                    </xsl:with-param>
                    
                </xsl:call-template>
                </div>
                 <!-- Ende main -->
            </body>
        </html>
    </xsl:template>
    
    <xsl:template match="tei:body | tei:front">
        <xsl:apply-templates/>
    </xsl:template>
    
    <!--header-->
    <!-- editor, contributer etc. -->
    <xsl:template match="tei:respStmt">
        <xsl:if test="position() != 1">
            <xsl:text>,</xsl:text>
        </xsl:if>
        <xsl:text> </xsl:text>
        <xsl:value-of select="tei:resp"/>
        <xsl:text> </xsl:text>
        <xsl:value-of select="tei:name"/>
    </xsl:template>

    <!-- Front -->
   
    <xsl:template match="tei:titlePage">
        <p class="content">
            <xsl:apply-templates/>
        </p>
    </xsl:template>

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

    <xsl:template match="tei:byline">
        <p class="content">
            <xsl:apply-templates/>
        </p>
    </xsl:template>

    <xsl:template match="tei:imprimatur">
        <p class="content">
            <xsl:apply-templates/>
        </p>
    </xsl:template>

    <xsl:template match="tei:docDate">
        <p class="content">
            <xsl:apply-templates/>
        </p>
    </xsl:template>

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

    <xsl:template match="tei:epigraph">
        <p class="content">
            <xsl:apply-templates/>
        </p>
    </xsl:template>

    <xsl:template match="tei:titlePart">
        <p class="content">
            <xsl:apply-templates/>
        </p>
    </xsl:template>


    <!--body-->
    <!-- main distribution-->
    <xsl:template match="tei:div[not(@type='footnotes')] | tei:div1[not(@type='footnotes')] | tei:div2[not(@type='footnotes')] | tei:div3[not(@type='footnotes')]">
        <a>
            <xsl:attribute name="name">
                <xsl:text>div</xsl:text>
                <xsl:number level="any"/>
            </xsl:attribute>
            <xsl:text> </xsl:text>
        </a>
        <xsl:if test="@xml:id[starts-with(.,'org') or starts-with(.,'ue')]">
            <a>
                <xsl:attribute name="name"><xsl:value-of select="@xml:id"/></xsl:attribute>
                <xsl:text> </xsl:text>
            </a>
        </xsl:if>
        <div>
            <xsl:if test="@type = 'abstract'"><xsl:attribute name="style">font-size:smaller;</xsl:attribute></xsl:if>
            <xsl:apply-templates/>
        </div>
    </xsl:template>
    
<!--    Ueberschriften-->
    
    <xsl:template match="tei:head">
        
        <xsl:if test="@xml:id[starts-with(.,'org') or starts-with(.,'ue')]">
        <a>
            <xsl:attribute name="name"><xsl:value-of select="@xml:id"/></xsl:attribute>
            <xsl:text> </xsl:text>
        </a>
        </xsl:if>
        <a>
            <xsl:attribute name="name"><xsl:text>hd</xsl:text><xsl:number level="any"/></xsl:attribute>
            <xsl:text> </xsl:text>
        </a>
        <h2 style="background-color:#EEE;padding:0.3em;margin-top:1em;position:relative;width:100%;">
            <div style="position:relative;width:90%;"><xsl:apply-templates/></div>
            <div style="position:absolute;right:1.5em;top:0.2em;font-weight:900;"><a href="#">↑</a></div>
        </h2>
    </xsl:template>

    <!-- dictonary entries -->
    <xsl:template match="tei:orth">
        <br/>
        <span class="lemma">
            <a>
                <xsl:attribute name="name">
                    <xsl:text>orth</xsl:text>
                    <xsl:number level="any"/>
                </xsl:attribute>
            </a>
            <xsl:apply-templates/>
        </span>
    </xsl:template>

    <!-- pysical pages     -->
    <xsl:template match="tei:pb">
        <div class="pagebreak">
            <br/>
            <xsl:text> || </xsl:text>
            <a>
                <xsl:attribute name="name">
                    <xsl:value-of select="substring(@facs,2)"/>
                </xsl:attribute>
                <xsl:text> </xsl:text>
            </a>
            <xsl:text> [</xsl:text>
            <xsl:if test="@ed">
                <xsl:value-of select="substring(@ed,4)"/>
                <xsl:text>: </xsl:text>
            </xsl:if>
            <xsl:choose>
                <xsl:when test="@facs and $distype='optional'">
                    <a>
                        <xsl:attribute name="href">
                            <xsl:choose>
                                <xsl:when test="@facs">
                                    <xsl:text>http://diglib.hab.de/</xsl:text><xsl:value-of select="substring-before(substring(@facs,2),'_')"/><xsl:text>/</xsl:text><xsl:value-of select="substring-before(substring-after(substring(@facs,2),'_'),'_')"/><xsl:text>/start.htm?distype=imgs&amp;image=</xsl:text><xsl:value-of select="substring-after(substring-after(substring(@facs,2),'_'),'_')"/>
                                </xsl:when>
                                <xsl:when test="document($metsfile)//mets:file[@ID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@FILEID]/mets:FLocat/@xlink:href">
                                    <xsl:value-of select="document($metsfile)//mets:file[@ID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@FILEID]/mets:FLocat/@xlink:href"/>
                                    <xsl:text>&amp;image=</xsl:text>
                                    <xsl:value-of select="substring-after(substring-after(substring(@facs,2),'_'),'_')"/>
                                </xsl:when>
                                <xsl:when test="starts-with(document($metsfile)//mets:file[@ID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@FILEID]/mets:FLocat/@xlink:href,'http:')">
                                    <xsl:value-of select="document($metsfile)//mets:file[@ID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@FILEID]/mets:FLocat/@xlink:href"/>
                                    <xsl:text>&amp;image=</xsl:text>
                                    <xsl:value-of select="substring-after(substring-after(substring(@facs,2),'_'),'_')"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="$content"/><xsl:text>?dir=</xsl:text><xsl:value-of select="$dir"/> 
                                    <xsl:text>&amp;xml=</xsl:text><xsl:value-of select="document($metsfile)//mets:file[@ID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@FILEID]/mets:FLocat/@xlink:href"/>
                                    <xsl:text>&amp;xsl=</xsl:text><xsl:value-of select="document($metsfile)//mets:behavior[@STRUCTID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@ID]/mets:mechanism/@xlink:href"/>
                                    <xsl:text>#</xsl:text><xsl:value-of select="substring(@facs,2)"/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:attribute>
                        <xsl:attribute name="target">
                            <xsl:text>display2</xsl:text>
                        </xsl:attribute>
                        <xsl:choose>         
                            <xsl:when test="@n">
                                <a>
                                    <xsl:attribute name="target">_blank</xsl:attribute>
                                    <xsl:attribute name="href">
                                        <xsl:text>http://diglib.hab.de/edoc/ed000211/download/controversia_et_confessio_8_Teil</xsl:text>
                                        <xsl:choose>
                                            <xsl:when test="@synch">
                                                <xsl:value-of select="@synch"/>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="@n"/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                        
                                        <xsl:text>.pdf</xsl:text>
                                    </xsl:attribute>
                                    <span>
                                        <xsl:value-of select="@n"/>
                                    </span>
                                </a>
                            </xsl:when>
                            <xsl:when test="@rend">
                                <xsl:value-of select="@rend"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of
                                    select="substring-after(substring-after(substring(@facs,2),'_'),'_')"
                                />
                            </xsl:otherwise>
                        </xsl:choose>
                      </a>
                </xsl:when>
            <xsl:when test="@n">
                    <a>
                        <xsl:attribute name="name">
                            <xsl:text>pb</xsl:text><xsl:value-of select="@n"/>
                        </xsl:attribute>
                    <a>
                        <xsl:attribute name="target">_blank</xsl:attribute>
                        <xsl:attribute name="href">
                            <xsl:text>http://diglib.hab.de/edoc/ed000211/download/controversia_et_confessio_8_Teil</xsl:text>
                            <xsl:choose>
                                <xsl:when test="@synch">
                                    <xsl:value-of select="@synch"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="@n"/>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:text>.pdf</xsl:text>
                        </xsl:attribute>
                        <span>
                            <xsl:value-of select="@n"/>
                        </span>
                    </a>
                        </a>
                </xsl:when>
                <xsl:when test="@rend">
                    <xsl:value-of select="@rend"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>-</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:text>] </xsl:text>
        </div>
    </xsl:template>
    
    <xsl:template match="tei:linkGrp">
        <xsl:choose>
           <xsl:when test="@type='quote'">
           </xsl:when>
        </xsl:choose>
        
    </xsl:template>
    
<!--    Links -->
    <xsl:template match="tei:ref">
        <xsl:param name="caption"/>
        <xsl:choose>
            <xsl:when test="@type='footnote' and $caption != 'true'">
                <a>
                    <xsl:attribute name="name">
                        <xsl:text>fna</xsl:text>
                        <xsl:value-of select="."/>
                    </xsl:attribute>
                    <a>
                        <xsl:attribute name="href">
                            <xsl:value-of select="@target"/>
                        </xsl:attribute>
                        <span style="font-size:9pt;vertical-align:super;color:blue;"><xsl:value-of select="."/></span>
                    </a>
                </a>
            </xsl:when>
            <!-- Klassische Zitate -->
            <xsl:when test="@type='classical'">
                <xsl:choose>
                    <!-- Ammianus -->
                    <xsl:when test="starts-with(@cRef,'Amm_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation_html('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','http://www.thelatinlibrary.com/ammianus/</xsl:text><xsl:value-of select="substring-after(substring-before(@cRef,','),'_')"/><xsl:text>.shtml#</xsl:text><xsl:value-of select="substring-before(substring-after(@cRef,','),',')"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a> 
                    </xsl:when>
                    <!-- Boethius: de consolatione philosophie -->
                    <!-- Boëth_Consol_1,P5 -->
                    <xsl:when test="starts-with(@cRef,'Boëth_Consol_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A1999.02.0121%3Abook%3D',substring-before(substring-after(@cRef,'Boëth_Consol_'),','),'%3Asectio%3D',substring-after(substring-after(@cRef,'Boëth_Consol_'),','))"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>  
                    </xsl:when>
                    <!-- Dio Cassius -->
                    <xsl:when test="starts-with(@cRef,'D.C_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:variable name="section">
                                    <!-- section vorhanden? -->
                                    <xsl:if test="substring-after(substring-after(substring-after(@cRef,'D.C_'),','),',') != ''">
                                        <xsl:value-of select="concat( '%3Asection%3D',substring-after(substring-after(substring-after(@cRef,'D.C_'),','),','))"/>
                                    </xsl:if>
                                </xsl:variable>
                                <xsl:variable name="chapter">
                                    <!-- chapter vorhanden? -->
                                    <xsl:choose>
                                        <xsl:when test="substring-after(substring-after(@cRef,'D.C_'),',') != '' and $section != '' ">
                                            <xsl:value-of select="concat('%3Achapter%3D',substring-before(substring-after(substring-after(@cRef,'D.C_'),','),','))"/>
                                        </xsl:when>
                                        <xsl:when test="substring-after(substring-after(@cRef,'D.C_'),',') != '' and $section = '' ">
                                            <xsl:value-of select="concat('%3Achapter%3D',substring-after(substring-after(@cRef,'D.C_'),','))"/>
                                        </xsl:when>
                                      </xsl:choose>
                                 </xsl:variable>
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A2008.01.0593%3Abook%3D',substring-before(substring-after(@cRef,'D.C_'),','),$chapter,$section)"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>   
                    </xsl:when>
                    <!-- Aulus Gellius -->
                    <xsl:when test="starts-with(@cRef,'Gell_')">
                        <xsl:variable name="abbr">Gell_</xsl:variable>
                        <a>
                            <xsl:attribute name="href">
                                <xsl:variable name="section">
                                    <!-- section vorhanden? -->
                                    <xsl:if test="substring-after(substring-after(substring-after(@cRef,$abbr),','),',') != ''">
                                        <xsl:value-of select="concat( '%3Asection%3D',substring-after(substring-after(substring-after(@cRef,$abbr),','),','))"/>
                                    </xsl:if>
                                </xsl:variable>
                                <xsl:variable name="chapter">
                                    <!-- chapter vorhanden? -->
                                    <xsl:choose>
                                        <xsl:when test="substring-after(substring-after(@cRef,'Gell_'),',') != '' and $section != '' ">
                                            <xsl:value-of select="concat('%3Achapter%3D',substring-before(substring-after(substring-after(@cRef,$abbr),','),','))"/>
                                        </xsl:when>
                                        <xsl:when test="substring-after(substring-after(@cRef,$abbr),',') != '' and $section = '' ">
                                            <xsl:value-of select="concat('%3Achapter%3D',substring-after(substring-after(@cRef,$abbr),','))"/>
                                        </xsl:when>
                                    </xsl:choose>
                                </xsl:variable>
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A2007.01.0071%3Abook%3D',substring-before(substring-after(@cRef,$abbr),','),$chapter,$section)"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>   
                    </xsl:when>
                    <!-- Historia Augusta Aurelians/Flavius Vopiscus  -->
                    <xsl:when test="starts-with(@cRef,'H.A_Aur_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation_html('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','http://www.thelatinlibrary.com/sha/aurel.shtml',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>
                    </xsl:when>
                    <!-- Historia Augusta Firmus/Flavius Vopiscus  -->
                    <xsl:when test="starts-with(@cRef,'H.A_Firm_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation_html('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','http://www.thelatinlibrary.com/sha/firmus.shtml',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>
                    </xsl:when>
                    <!-- Historia Augusta Gordiani/Iulius Capitolinus -->
                    <xsl:when test="starts-with(@cRef,'H.A_Gord_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation_html('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','http://www.thelatinlibrary.com/sha/gord.shtml',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a> 
                    </xsl:when>
                    <!-- Historia Augusta Probus/Flavius Vopiscus-->
                    <xsl:when test="starts-with(@cRef,'H.A_Prob_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation_html('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','http://www.thelatinlibrary.com/sha/probus.shtml',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a> 
                    </xsl:when>
                    <!-- Historia Augusta Tacitus/Flavius Vopiscus  -->
                    <xsl:when test="starts-with(@cRef,'H.A_Tac_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation_html('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','http://www.thelatinlibrary.com/sha/tacitus.shtml',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>
                    </xsl:when>
                    <!-- Horaz, Epistulae-->
                    <xsl:when test="starts-with(@cRef,'Hor_Ep_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:variable name="poem">
                                    <!-- poem vorhanden? -->
                                    <xsl:choose>
                                        <xsl:when test="substring-after(substring-after(@cRef,'Hor_Ep_'),',') != ''">
                                            <xsl:value-of select="concat('%3Apoem%3D',substring-after(substring-after(@cRef,'Hor_Ep_'),','))"/>
                                        </xsl:when>
                                    </xsl:choose>
                                   </xsl:variable>
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A2008.01.0539%3Abook%3D',substring-before(substring-after(@cRef,'Hor_Ep_'),','),$poem)"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>   
                    </xsl:when>
                    <!-- Orosius -->
                    <!-- Form z.B. Oros_7,12 -->
                    <xsl:when test="starts-with(@cRef,'Oros_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation_html('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','http://www.thelatinlibrary.com/orosius/orosius</xsl:text><xsl:value-of select="substring-after(substring-before(@cRef,','),'Oros_')"/><xsl:text>.shtml#</xsl:text><xsl:value-of select="substring-after(@cRef,',')"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a> 
                    </xsl:when>
                    <!--  Pausanias -->
                    <xsl:when test="starts-with(@cRef,'Paus_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A1999.01.0159%3Abook%3D',substring-before(substring-after(@cRef,'Paus_'),','),'%3Achapter%3D',substring-before(substring-after(substring-after(@cRef,'Paus_'),','),','),'%3Asection%3D',substring-after(substring-after(substring-after(@cRef,'Paus_'),','),','))"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>   
                    </xsl:when>
                    
                    <!-- Martial: Epigramma-->
                    <!--  Muster: Mart_7,17 -->
                    <xsl:when test="starts-with(@cRef,'Mart_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A2008.01.0506%3Abook%3D',substring-before(substring-after(@cRef,'Mart_'),','),'%3Apoem%3D',substring-after(substring-after(@cRef,'Mart_'),','))"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>   
                    </xsl:when>
                    <!-- Ovid: Tristia-->
                    <xsl:when test="starts-with(@cRef,'Ov_Tr_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A2008.01.0492%3Abook%3D',substring-before(substring-after(@cRef,'Ov_Tr_'),','),'%3Apoem%3D',substring-after(substring-after(@cRef,'Ov_Tr_'),','))"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>   
                    </xsl:when>
                    <!-- Plinius: Historia Naturalis-->
                    <!--  Muster 2 Stellen -->
                    <xsl:when test="starts-with(@cRef,'Plin_H.N_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A1999.02.0138%3Abook%3D',substring-before(substring-after(@cRef,'Plin_H.N_'),','),'%3Achapter%3D',substring-after(substring-after(@cRef,'Plin_H.N_'),','))"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>   
                    </xsl:when>
                    <!-- Plinius, der juengere: Epistulae-->
                    <!--   -->
                    <xsl:when test="starts-with(@cRef,'Plin_Ep_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A1999.02.0139%3Abook%3D',substring-before(substring-after(@cRef,'Plin_Ep_'),','),'%3Aletter%3D',substring-after(substring-after(@cRef,'Plin_Ep_'),','))"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>   
                    </xsl:when>
                    <!-- Plutarch, Lucullus  -->
                    <xsl:when test="starts-with(@cRef,'Plu_Luc_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A2008.01.0117%3Achapter%3D',substring-before(substring-after(@cRef,'Plu_Luc_'),','),'%3Asection%3D',substring-after(substring-after(@cRef,'Plu_Luc_'),','))"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>  
                    </xsl:when>
                    <!-- Plutarch, Marcellus  -->
                    <xsl:when test="starts-with(@cRef,'Plu_Marc_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A2008.01.0118%3Achapter%3D',substring-before(substring-after(@cRef,'Plu_Marc_'),','),'%3Asection%3D',substring-after(substring-after(@cRef,'Plu_Marc_'),','))"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>  
                    </xsl:when>
                    <!-- Seneca d.J., de tranquilitate -->
                    <!--  z.B. Sen_Tranq_9,5 -->
                    <xsl:when test="starts-with(@cRef,'Sen_Tranq_')">
                        <xsl:variable name="section">
                            <!-- section vorhanden? -->
                            <xsl:choose>
                                <xsl:when test="substring-after(substring-after(@cRef,'Sen_Tranq_'),',') != ''">
                                    <xsl:value-of select="concat('%3Apoem%3D',substring-after(substring-after(@cRef,'Sen_Tranq_'),','))"/>
                                </xsl:when>
                            </xsl:choose>
                        </xsl:variable>
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A2007.01.0021%3Abook%3D9%3A',substring-before(substring-after(@cRef,'Sen_Tranq_'),','),$section)"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>   
                    </xsl:when>
                    <!-- Seneca d.J., ad Lucilium epistulae -->
                    <!--  z.B. Sen_Ep_86,6 -->
                    <xsl:when test="starts-with(@cRef,'Sen_Ep_')">
                        <xsl:variable name="section">
                            <!-- section vorhanden? -->
                            <xsl:choose>
                                <xsl:when test="substring-after(substring-after(@cRef,'Sen_Ep_'),',') != ''">
                                    <xsl:value-of select="concat('%3Asection%3D',substring-after(substring-after(@cRef,'Sen_Ep_'),','))"/>
                                </xsl:when>
                            </xsl:choose>
                        </xsl:variable>
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A2007.01.0080%3Aletter%3D',substring-before(substring-after(@cRef,'Sen_Ep_'),','),$section)"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>   
                    </xsl:when>
                    <!-- Strabo -->
                    <!--  Muster 3 Stellen -->
                    <xsl:when test="starts-with(@cRef,'Str_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A1999.01.0197%3Abook%3D',substring-before(substring-after(@cRef,'Str_'),','),'%3Achapter%3D',substring-before(substring-after(substring-after(@cRef,'Str_'),','),','),'%3Asection%3D',substring-after(substring-after(substring-after(@cRef,'Str_'),','),','))"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                             </xsl:attribute>
                             <xsl:apply-templates/>
                        </a>   
                    </xsl:when>
                    <!-- Sueton, Kaiserviten; Form 2stellig, z.B. Suet_Dom_20,1 -->
                    <!-- Sueton, Augustus  -->
                    <xsl:when test="starts-with(@cRef,'Suet_Aug_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A1999.02.0061%3Alife%3Daug.%3Achapter%3D',substring-before(substring-after(@cRef,'Suet_Aug_'),','),'%3Asection%3D',substring-after(substring-after(@cRef,'Suet_Aug_'),','))"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>  
                    </xsl:when>
                    <!-- Sueton, Caesar  -->
                    <xsl:when test="starts-with(@cRef,'Suet_Caes_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A1999.02.0061%3Alife%3Djul.%3Achapter%3D',substring-before(substring-after(@cRef,'Suet_Caes_'),','),'%3Asection%3D',substring-after(substring-after(@cRef,'Suet_Caes_'),','))"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>  
                    </xsl:when>
                    <!-- Sueton, Domitian -->
                    <xsl:when test="starts-with(@cRef,'Suet_Dom_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A1999.02.0061%3Alife%3Ddom.%3Achapter%3D',substring-before(substring-after(@cRef,'Suet_Dom_'),','),'%3Asection%3D',substring-after(substring-after(@cRef,'Suet_Dom_'),','))"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a>  
                    </xsl:when>
                    <!-- Sueton, de Grammaticis -->
                    <xsl:when test="starts-with(@cRef,'Suet_Gram_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation_html('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','http://www.thelatinlibrary.com/suetonius/suet.gram.html#</xsl:text><xsl:value-of select="substring-after(@cRef,'Suet_Gram_')"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a> 
                    </xsl:when>
                  
                     <xsl:otherwise>
                        <xsl:apply-templates/>
                    </xsl:otherwise>
                </xsl:choose>
             </xsl:when>
            <xsl:when test="@type='pg'">
                <xsl:apply-templates/>
            </xsl:when>
            <xsl:when test="@type='pl'">
                
            </xsl:when>
            <xsl:when test="@type='biblical'">
        
                    <a>
                        <xsl:attribute name="target">_blank</xsl:attribute>
                        <xsl:attribute name="href">
                            <xsl:text>http://www.biblija.net/biblija.cgi?Bible=Bible&amp;m=</xsl:text><xsl:value-of select="translate(translate(translate(@cRef,' ','+'),',',':'),'_',' ')"/><xsl:text>&amp;id12=1&amp;id38=1&amp;pos=0&amp;set=1&amp;l=en&amp;idp0=13&amp;idp1=39</xsl:text>
                        </xsl:attribute>
                        <xsl:apply-templates/></a>
            </xsl:when>
            
                <!-- Vulgata -->
         <!--       <xsl:choose>
               
                <xsl:when test="starts-with(@cRef,'vulgata_')">
                    <a>
                        <xsl:attribute name="href">
                            <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="concat($perseus,'Perseus%3Atext%3A1999.02.0060%3Abook%3DActs%3Achapter%3D3%3Averse%3D21',substring-before(substring-after(@cRef,'act_'),','))"/><xsl:text>','</xsl:text><xsl:value-of select="concat($server,$dir)"/><xsl:text>/show_perseus.xsl','</xsl:text><xsl:value-of select="@cRef"/><xsl:text>',300,500)</xsl:text>
                        </xsl:attribute>
                        <xsl:apply-templates/>
                    </a>  
                </xsl:when>
                <xsl:otherwise>
                    <xsl:apply-templates/>
                </xsl:otherwise>
        </xsl:choose>-->
      
        
            <xsl:when test="@type='medieval'">
                <!-- Zitate aus mittelalterlichen Quellen -->
                <xsl:choose>
                    <xsl:when test="starts-with(@cRef,'Isid_Etym_')">
                        <!-- Isidor, etymologiae  -->
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation_html('</xsl:text><xsl:value-of select="$dir"/><xsl:text>',' http://penelope.uchicago.edu/Thayer/L/Roman/Texts/Isidore/</xsl:text><xsl:value-of select="substring-after(substring-before(@cRef,','),'Isid_Etym_')"/><xsl:text>*.html#</xsl:text><xsl:value-of select="substring-before(substring-after(@cRef,','),',')"/><xsl:text>',300,500)</xsl:text>
                             </xsl:attribute>
                               <xsl:apply-templates/>
                        </a>
                    </xsl:when>
                    <!-- Digesten -->
                    <xsl:when test="starts-with(@cRef,'D_')">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation_html('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','http://www.thelatinlibrary.com/justinian/digest</xsl:text><xsl:value-of select="substring-after(substring-before(@cRef,','),'_')"/><xsl:text>.shtml',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/>
                        </a> 
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:apply-templates/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            <!-- Google Books -->
            <xsl:when test="@type='google_books'">
                <a>
                    <xsl:attribute name="href">
                        <xsl:text>javascript:show_annotation_html('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="@target"/><xsl:text>',400,600)</xsl:text>
                    </xsl:attribute>
                    <xsl:apply-templates/>
                </a> 
            </xsl:when>
            <xsl:when test="@type='bibliography'">
                <a>
                    <xsl:attribute name="href">
                        <xsl:text>javascript:show_annotation('edoc/ed000211','register/register-bibl.xml','show_bibl.xsl','</xsl:text><xsl:value-of select="substring(@target,2)"/><xsl:text>',300,500);</xsl:text>   
                    </xsl:attribute>
                    <xsl:attribute name="title">
                        <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listBibl/tei:bibl[@xml:id =substring(current()/@ref,2)]"/><xsl:text> </xsl:text>
                        <xsl:if test="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listBibl/tei:bibl[@xml:id =substring(current()/@ref,2)]/tei:nameLink"><xsl:text> </xsl:text>
                            <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listBibl/tei:bibl[@xml:id =substring(current()/@ref,2)]/tei:nameLink"/>
                            <xsl:text> </xsl:text>
                        </xsl:if>
                    </xsl:attribute>
                    <xsl:apply-templates/>
                </a>
            </xsl:when>
            <xsl:otherwise>
                <a>
                    <xsl:attribute name="href">
                        <xsl:value-of select="@target"/>
                    </xsl:attribute>
                     <xsl:attribute name="target">_blank</xsl:attribute>
                     <xsl:apply-templates/>
                </a>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:choose>
            <xsl:when test="@n">
            <xsl:text> || </xsl:text>
            <a>
                <xsl:attribute name="name">
                    <xsl:value-of select="substring(@facs,2)"/>
                </xsl:attribute>
                <xsl:text> </xsl:text>
            </a>
            <xsl:text> [</xsl:text>
            <xsl:if test="@ed">
                <xsl:value-of select="substring(@ed,4)"/>
                <xsl:text>: </xsl:text>
            </xsl:if>
            <xsl:choose>
                <xsl:when test="@facs">
                    <a>
                        <xsl:attribute name="href">
                            <xsl:choose>
                                <xsl:when test="@facs">
                                    <xsl:text>http://diglib.hab.de/</xsl:text><xsl:value-of select="substring-before(substring(@facs,2),'_')"/><xsl:text>/</xsl:text><xsl:value-of select="substring-before(substring-after(substring(@facs,2),'_'),'_')"/><xsl:text>/start.htm?distype=imgs&amp;image=</xsl:text><xsl:value-of select="substring-after(substring-after(substring(@facs,2),'_'),'_')"/>
                                </xsl:when>
                                <xsl:when test="document($metsfile)//mets:file[@ID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@FILEID]/mets:FLocat/@xlink:href">
                                    <xsl:value-of select="document($metsfile)//mets:file[@ID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@FILEID]/mets:FLocat/@xlink:href"/>
                                    <xsl:text>&amp;image=</xsl:text>
                                    <xsl:value-of select="substring-after(substring-after(substring(@facs,2),'_'),'_')"/>
                                </xsl:when>
                                <xsl:when test="starts-with(document($metsfile)//mets:file[@ID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@FILEID]/mets:FLocat/@xlink:href,'http:')">
                                    <xsl:value-of select="document($metsfile)//mets:file[@ID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@FILEID]/mets:FLocat/@xlink:href"/>
                                    <xsl:text>&amp;image=</xsl:text>
                                    <xsl:value-of select="substring-after(substring-after(substring(@facs,2),'_'),'_')"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="$content"/><xsl:text>?dir=</xsl:text><xsl:value-of select="$dir"/> 
                                    <xsl:text>&amp;xml=</xsl:text><xsl:value-of select="document($metsfile)//mets:file[@ID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@FILEID]/mets:FLocat/@xlink:href"/>
                                    <xsl:text>&amp;xsl=</xsl:text><xsl:value-of select="document($metsfile)//mets:behavior[@STRUCTID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@ID]/mets:mechanism/@xlink:href"/>
                                    <xsl:text>#</xsl:text><xsl:value-of select="substring(@facs,2)"/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:attribute>
                        <xsl:attribute name="target">
                            <xsl:text>display2</xsl:text>
                        </xsl:attribute>
                        <xsl:choose>
                            <xsl:when test="@n">
                                
                                <xsl:value-of select="@n"/>
                            </xsl:when>
                            <xsl:when test="@rend">
                                <xsl:value-of select="@rend"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of
                                    select="substring-after(substring-after(substring(@facs,2),'_'),'_')"
                                />
                            </xsl:otherwise>
                        </xsl:choose>
                    </a>
                </xsl:when>
                <xsl:when test="@n">
                    <a>
                        <xsl:attribute name="name">
                            <xsl:text>pb</xsl:text><xsl:value-of select="@n"/>
                        </xsl:attribute>
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>#pb</xsl:text><xsl:value-of select="@n"/>
                            </xsl:attribute>
                            <span>
                                <xsl:value-of select="@n"/>
                            </span>
                        </a>
                    </a>
                </xsl:when>
                <xsl:when test="@rend">
                    <xsl:value-of select="@rend"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>-</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:text>] </xsl:text>
            </xsl:when>
        </xsl:choose>
     </xsl:template>
 
    <xsl:template match="tei:ptr">
        <xsl:apply-templates/>
        <xsl:choose>
            <xsl:when test="@type='google_books'">
                [<a>
                    <xsl:attribute name="href">
                        <xsl:text>javascript:show_annotation_html('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','</xsl:text><xsl:value-of select="@target"/><xsl:text>',400,600)</xsl:text>
                    </xsl:attribute>
                    <xsl:text>Google Books</xsl:text></a>]
            </xsl:when>
            <xsl:when test="starts-with(@target,'http://')">
                [<a>
                    <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
                    <xsl:attribute name="target">_blank</xsl:attribute>
                    <xsl:text>Link</xsl:text>
                </a>]
            </xsl:when>
            <xsl:when test="@type='opac' ">
                [<a href="{normalize-space(concat($opac,@cRef))}" target='_blank'>Nachweis im OPAC</a>]
            </xsl:when>
            <xsl:when test="@type='gbv' ">
                [<a href="{normalize-space(concat($gbv,@cRef))}" target='_blank'>Nachweis im GBV</a>]
            </xsl:when>
            <xsl:when test="@type='GettyThesaurus' ">
                [<a href="{normalize-space(concat($GettyThesaurus,(substring-after(@target, '#TGN_'))))}" target='_blank'>TGN</a>]
            </xsl:when>
        </xsl:choose>
    </xsl:template>
 
 
 
    <xsl:template match="tei:listBibl">
        <ul>
            <xsl:apply-templates/>
        </ul>
    </xsl:template>
    
    
    <xsl:template match="tei:bibl[parent::tei:listBibl]">
        <li>
            <a>
                <xsl:attribute name="name">
                    <xsl:value-of select="@xml:id"/>
                </xsl:attribute>
                <xsl:text> </xsl:text>
            </a>
                    <xsl:apply-templates/>
        </li>
    </xsl:template>
    
    <!-- footnotes, annotations -->

    <xsl:template match="tei:note">
        
        <xsl:param name="caption"/>
        <!--  zwei Typen: entweder Fussnoten am Text- oder Seitenende in einem besonderen Abschnitt oder in den Text integriert -->
        <xsl:choose>
            <xsl:when test="parent::tei:div[@type='footnotes' ]">
                <!--   Fussnoten am Text- oder Seitenende -->
                <div class="footnotes">
                <a>
                    <xsl:attribute name="name">
                        <xsl:text>fn</xsl:text>
                         <xsl:value-of select="@n"/>
                    </xsl:attribute>
                    <a>
                        <xsl:attribute name="href">
                            <xsl:text>#fna</xsl:text><xsl:value-of select="@n"/>
                        </xsl:attribute>
                        <span style="font-size:9pt;vertical-align:super;color:blue;margin-right:0.3em;">
                            <xsl:value-of select="@n"/>
                        </span>
                    </a>
                </a>
                    <xsl:apply-templates/>
                </div>
            </xsl:when>
            <xsl:when test="$caption ='true'">
                <!-- keine Anzeige -->
            </xsl:when>
            <xsl:when test="@type='footnoteX'">
                <!--  noch in Bearbeitung, nicht anzeigen -->
             </xsl:when>   
            <xsl:when test="@type='footnote'">
                <!--  in Text integriert, nur Verweis , Fussnotenabschnitt mit foreach generiert -->
                <a> 
                    <xsl:attribute name="name">
                        <xsl:text>fna</xsl:text>
                        <xsl:number level="any" count="tei:note[@type ='footnote']"/>
                    </xsl:attribute>
                    <a>
                        <xsl:attribute name="href">
                            <xsl:text>#fn</xsl:text><xsl:number level="any" count="tei:note[@type ='footnote']"/>
                        </xsl:attribute>
                        <xsl:attribute name="title"><xsl:copy-of select="normalize-space(.)"/></xsl:attribute>
                        <span style="font-size:9pt;vertical-align:super;color:blue; line-height:0;"><xsl:value-of select="$caption"/><xsl:number level="any" count="tei:note[@type ='footnote']"/></span>
                    </a>
                </a>
            </xsl:when> 
         
         <xsl:when test="@place">
                <div style=" width: 120px;
                    font-size: 8pt;
                    display: block;
                    float: left;
                    margin: 0px 10px 0px -130px;
                    line-height:1.2;
                    ">
                    
                    <a> 
                        <xsl:attribute name="name">
                            <xsl:text>mna</xsl:text>
                            <xsl:number level="any" format="a" count="tei:note[@place]"/>
                        </xsl:attribute>
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>#mn</xsl:text><xsl:number level="any" count="tei:note[@place]" format="a"/>
                            </xsl:attribute>
                            <xsl:attribute name="title"><xsl:copy-of select="normalize-space(.)"/></xsl:attribute>
                            <span style="font-size:9pt;vertical-align:super;color:red;"><xsl:number level="any"  format="a" count="tei:note[@place]"/></span>
                            <xsl:if test="@place='margin-right'">
                                
                                <xsl:text> Marginalie am rechten Rand</xsl:text>
                            </xsl:if>
                            <xsl:if test="@place='margin-left'">
                                
                                <xsl:text> Marginalie am linken Rand</xsl:text>
                            </xsl:if>
                        </a>
                    </a>
                </div>
            </xsl:when>
                <xsl:when test="@type='annotation'">
                    <!--  in Text integriert, nur Verweis , Fussnotenabschnitt mit foreach generiert -->
                    <a>
                        <xsl:attribute name="name">
                            <xsl:text>ana</xsl:text>
                            <xsl:number level="any" format="a" count="tei:note[@type ='annotation']"/>
                        </xsl:attribute>
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>#an</xsl:text>
                                <xsl:number level="any" format="a" count="tei:note[@type ='annotation']"
                                />
                            </xsl:attribute>
                            <xsl:attribute name="title"><xsl:copy-of select="normalize-space(.)"/></xsl:attribute>
                            <span style="font-size:9pt;vertical-align:super;color:blue; line-height:0;">
                                
                                <xsl:number level="any" format="a" from="tei:div"
                                    count="tei:note[@type ='annotation']"/>
                            </span>
                        </a>
                    </a>
                </xsl:when>
  
            <xsl:otherwise> </xsl:otherwise>
        </xsl:choose>
        <xsl:text> </xsl:text>
        
    </xsl:template>
    
    
    
<!-- drama    -->
    <xsl:template match="tei:castList">
        <p>
        <xsl:apply-templates/>
        </p>   
    </xsl:template>
    
    <xsl:template match="tei:castitem">
        <dl>
            <xsl:apply-templates/>
        </dl>   
    </xsl:template>
    
    <xsl:template match="tei:role">
        <dt>
            <xsl:apply-templates/>
        </dt>  
  </xsl:template>
    
    <xsl:template match="tei:roleDesc">
        <dd>
            <xsl:apply-templates/>
        </dd>
    </xsl:template>
    
    <xsl:template match="tei:set">
        <p>
            <xsl:apply-templates/>
        </p>
    </xsl:template>
    
    <xsl:template match="tei:stage">
        <xsl:if test="@xml:id[starts-with(.,'org') or starts-with(.,'ue')]">
            <a>
                <xsl:attribute name="name"><xsl:value-of select="@xml:id"/></xsl:attribute>
                <xsl:text> </xsl:text>
            </a>
        </xsl:if>
        <p>
            <i><xsl:apply-templates/></i>
        </p>
    </xsl:template>
    
    <xsl:template match="tei:sp">
        <xsl:if test="@xml:id[starts-with(.,'org') or starts-with(.,'ue')]">
            <a>
                <xsl:attribute name="name"><xsl:value-of select="@xml:id"/></xsl:attribute>
                <xsl:text> </xsl:text>
            </a>
        </xsl:if>
        <p>
            <xsl:apply-templates/>
        </p>
    </xsl:template>
    
    <xsl:template match="tei:speaker">
        <xsl:if test="@xml:id[starts-with(.,'org') or starts-with(.,'ue')]">
            <a>
                <xsl:attribute name="name"><xsl:value-of select="@xml:id"/></xsl:attribute>
                <xsl:text> </xsl:text>
            </a>
        </xsl:if>
        <p style="font-variant:small-caps;text-align:center;">
            <xsl:apply-templates/>
        </p>
    </xsl:template>
    
    <!-- hier erst mal aus    -->
    <xsl:template match="tei:ab"/>
        
    
        
        
    <!-- closer -->
    <xsl:template match="tei:closer">
        <xsl:apply-templates/>
    </xsl:template>
    
    <!-- closer -->
    <xsl:template match="tei:opener">
        <xsl:apply-templates/>
    </xsl:template>
    
    <!-- closer -->
    <xsl:template match="tei:salute">
        <xsl:apply-templates/>
    </xsl:template>
    
    <!-- Namen -->
    <xsl:template match="tei:name">
        <xsl:apply-templates/>
    </xsl:template>
    <!-- Datum -->
    <xsl:template match="tei:dateline">
        <xsl:apply-templates/>
    </xsl:template>
    
    <xsl:template match="tei:date">
        <xsl:apply-templates/>
    </xsl:template>
    
    <!-- index  erst mal auslassen-->
    <xsl:template match="tei:index">
        
    </xsl:template>
    
    <!--  Anker fuer Spruenge im Text -->
    <xsl:template match="tei:anchor">
        <a>
            <xsl:attribute name="name">
                <xsl:value-of select="@xml:id"/>
            </xsl:attribute>
            <xsl:text> </xsl:text>
        </a>
    </xsl:template>
    <!-- lokal ################################################################################################  -->
    
    
   
    <!-- entitaeten -->
    
   
    <!--  Textkritik -->
    
    <xsl:template match="tei:app">
        <xsl:apply-templates/>
    </xsl:template>
    
    <xsl:template match="tei:rdg">
        <xsl:apply-templates/>
    </xsl:template>
    
    <xsl:template match="tei:l">
        <xsl:if test="@xml:id[starts-with(.,'org') or starts-with(.,'ue')]">
            <a>
                <xsl:attribute name="name"><xsl:value-of select="@xml:id"/></xsl:attribute>
                <xsl:text> </xsl:text>
            </a>
        </xsl:if>
        <br/>
        <xsl:apply-templates/>
    </xsl:template>
    
        <xsl:template match="tei:quote | tei:q">
            <xsl:if test="@xml:id[starts-with(.,'org') or starts-with(.,'ue')]">
                <a>
                    <xsl:attribute name="name"><xsl:value-of select="@xml:id"/></xsl:attribute>
                    <xsl:text> </xsl:text>
                </a>
            </xsl:if>
            &#8222;
                <xsl:apply-templates/>
            &#8220;
        </xsl:template>
        
        <xsl:template match="tei:hi | tei:emph | tei:rs/tei:hi">
           <xsl:if test="@xml:id[starts-with(.,'org') or starts-with(.,'ue')]">
               <a>
                   <xsl:attribute name="name"><xsl:value-of select="@xml:id"/></xsl:attribute>
                   <xsl:text> </xsl:text>
               </a>
           </xsl:if>
           <xsl:choose>
               <xsl:when test="@rend ='italics' or @rend ='italic'">
                   <span style="font-style:italic;"><xsl:apply-templates/></span>
               </xsl:when>
               <xsl:when test="@rend ='oesup'">
                   <span>&#58948;</span>
               </xsl:when>
               <xsl:when test="@rend ='uesup'">
                   <span>u&#x0364;</span>
               </xsl:when>
               <xsl:when test="@rend='nmakron'">
                   <span>&#58844;</span>
               </xsl:when>
               <xsl:when test="@rend ='bold'">
                   <span style="font-weight:bold;"><xsl:apply-templates/></span>
               </xsl:when>
               <xsl:when test="@rend ='smallCaps' or @rend ='small-caps'">
                   <span style="font-variant:small-caps;"><xsl:apply-templates/></span>
               </xsl:when>
               <xsl:when test="@rend ='spaced'">
                   <span style="letter-spacing:0.2em;"><xsl:apply-templates/></span>
               </xsl:when>
               <xsl:when test="@rend ='center'">
                   <span style="text-align:center;"><xsl:apply-templates/></span>
               </xsl:when>
               <xsl:when test="@rend ='initiale'">
                   <span style="font-weight:bold;"><xsl:apply-templates/></span>
               </xsl:when>
               <xsl:when test="@rend ='super'">
                   <span style="vertical-align:super; font-size: .83em;"><xsl:apply-templates/></span>
               </xsl:when>
               <xsl:when test="@rend ='dagger'">
                   <span style="font-family:arial;"><xsl:apply-templates></xsl:apply-templates></span>
               </xsl:when>
               
               <xsl:otherwise>
                   <xsl:apply-templates/>
               </xsl:otherwise>
           </xsl:choose>
       </xsl:template>
       
       <!-- hier ggf ausschalten 
       <xsl:template match="tei:lb">
           <xsl:if test="not(@rend) or @rend !='trennstrich'">
               
               <xsl:text> </xsl:text>
            </xsl:if>
         </xsl:template>-->
    
 <!--   <xsl:template match="tei:lb">
        <xsl:choose>
            <xsl:when test="$lokal != 'orig'">
                <xsl:if test="parent::tei:w and not(preceding-sibling::tei:fw or preceding-sibling::tei:pb)">
                    <xsl:text>-</xsl:text>
                </xsl:if> 
                <br/>
            </xsl:when>
            <xsl:when test="parent::tei:w">
                <xsl:text>|</xsl:text>
            </xsl:when>
            <xsl:when test="position()=1 and (parent::tei:hi or parent::tei:head or parent::tei:p or parent::tei:item)">
                <xsl:apply-templates/>
            </xsl:when>
            <xsl:when test="preceding-sibling::tei:pb">
                <xsl:apply-templates/>
            </xsl:when>
            <xsl:when test="@n">
                <span style="position:relative;left:-0.5em;margin-left:2px;font-size:small;">(<xsl:value-of select="@n"/>)</span></xsl:when>
            <xsl:otherwise>
                <xsl:text>| </xsl:text>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>-->
    
    
 <xsl:template match="tei:lb">
<xsl:choose>
   <xsl:when test="$view != 'orig'">
        <xsl:choose>
            <xsl:when test="parent::tei:w"> 
                <xsl:text>-</xsl:text>
                <br/>
            </xsl:when><xsl:when test="@type='hy'"> 
                <xsl:text>-</xsl:text>
                <br/>
            </xsl:when>
            <xsl:otherwise> 
                <br/>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:choose>
            <xsl:when test="@n">
               <span style="position:relative;left:-0.5em;margin-left:2px;font-size:small;">(<xsl:value-of select="@n"/>)</span></xsl:when>
        </xsl:choose>
       </xsl:when>
    <xsl:otherwise>
        <xsl:choose>
        <xsl:when test="$view != 'orig'">
        <xsl:choose>
        <xsl:when test="parent::tei:w">
            <xsl:text>|</xsl:text>
        </xsl:when>
        </xsl:choose>
        </xsl:when>
        </xsl:choose>
    </xsl:otherwise>
</xsl:choose>
        <xsl:apply-templates/>
  
 
 
 </xsl:template>
 
        <xsl:template match="tei:p | tei:seg | tei:lg">
        <xsl:if test="@xml:id[starts-with(.,'org') or starts-with(.,'ue')]">
            <a>
                <xsl:attribute name="name"><xsl:value-of select="@xml:id"/></xsl:attribute>
                <xsl:text> </xsl:text>
            </a>
        </xsl:if>
        <xsl:apply-templates/>
        </xsl:template>
    
    <xsl:template match="exist:match">
        
        <xsl:variable name="divNo">
            <xsl:number count="tei:div" level="any"/>
        </xsl:variable>
        
        <xsl:variable name="hitNo">
            <xsl:number level="multiple"/>
        </xsl:variable>
        
        <xsl:variable name="hitNoAll">
            <xsl:number level="any"/>
        </xsl:variable>
       <a>
            <xsl:attribute name="name">
                <xsl:text>hit</xsl:text><xsl:value-of select="$divNo"/><xsl:text>_</xsl:text><xsl:value-of select="$hitNo"/>
            </xsl:attribute>
           <xsl:text> </xsl:text>
       </a>
        <a>
            <xsl:attribute name="name">
                <xsl:text>hit</xsl:text><xsl:value-of select="$hitNoAll"/>
            </xsl:attribute>
            <xsl:text> </xsl:text>
        </a>
        <span style="background-color:yellow;">
            <xsl:apply-templates/>
        </span>
        <xsl:if test="$hitNoAll &gt; 1">
            <!--<p><xsl:value-of select="count(//exist:match)"/> _<xsl:value-of select="$hitNo"/></p>-->
            <xsl:text> [</xsl:text>
            <a style="font-weight:900;font-size:larger;">
                <xsl:attribute name="href">
                    <xsl:text>#hit</xsl:text>
                    <xsl:value-of select="$hitNoAll - 1"/>
                </xsl:attribute>
                <xsl:attribute name="title"><xsl:text>voriger Treffer</xsl:text></xsl:attribute>
                <xsl:text>←</xsl:text>
            </a>
            <xsl:text>]</xsl:text>
        </xsl:if>
        <xsl:if test="$hitNoAll &lt; count(//exist:match)">
            <!--<p><xsl:value-of select="count(//exist:match)"/> _<xsl:value-of select="$hitNo"/></p>-->
            <xsl:text> [</xsl:text>
            <a style="font-weight:900;font-size:larger;">
                <xsl:attribute name="href">
                    <xsl:text>#hit</xsl:text>
                    <xsl:value-of select="$hitNoAll+1"/>
                </xsl:attribute>
                <xsl:attribute name="title"><xsl:text>nächster Treffer</xsl:text></xsl:attribute>
                <xsl:text>→</xsl:text>
            </a>
            <xsl:text>]</xsl:text>
        </xsl:if>
    </xsl:template>

        <!--  fuer Spruenge zu den Begriffen -->
      <!-- <xsl:template match="tei:term">
           <a>
               <xsl:attribute name="name">
                   <xsl:value-of select="concat('term_',substring(@target,2))"/>
                </xsl:attribute>
               <xsl:text> </xsl:text>
           </a>
            <xsl:apply-templates/>
            </xsl:template>-->
    
    <xsl:template match="tei:term">
        <xsl:choose>
            <xsl:when test="@target=concat('#',$q)">
                <xsl:variable name="hitNo">
                    <xsl:number level="any" count="tei:term[@target=concat('#',$q)]"/>
                </xsl:variable>
                <a>
                    <xsl:attribute name="name">
                        <xsl:text>hit</xsl:text><xsl:value-of select="$hitNo"/>
                    </xsl:attribute>
                    <xsl:text> </xsl:text>
                </a>
                <span style="background-color:yellow;">
                    <xsl:apply-templates/>
                </span>
                <xsl:if test="$hitNo &gt; 1">
                    <!--<p><xsl:value-of select="count(//exist:match)"/> _<xsl:value-of select="$hitNo"/></p>-->
                    <xsl:text> [</xsl:text>
                    <a style="font-weight:900;font-size:larger;">
                        <xsl:attribute name="href">
                            <xsl:text>#hit</xsl:text>
                            <xsl:value-of select="$hitNo - 1"/>
                        </xsl:attribute>
                        <xsl:attribute name="title"><xsl:text>voriger Treffer</xsl:text></xsl:attribute>
                        <xsl:text>←</xsl:text>
                    </a>
                    <xsl:text>]</xsl:text>
                </xsl:if>
                <xsl:if test="$hitNo &lt; count(//tei:term[@target=concat('#',$q)])">
                    <!--<p><xsl:value-of select="count(//exist:match)"/> _<xsl:value-of select="$hitNo"/></p>-->
                    <xsl:text> [</xsl:text>
                    <a style="font-weight:900;font-size:larger;">
                        <xsl:attribute name="href">
                            <xsl:text>#hit</xsl:text>
                            <xsl:value-of select="$hitNo+1"/>
                        </xsl:attribute>
                        <xsl:attribute name="title"><xsl:text>nächster Treffer</xsl:text></xsl:attribute>
                        <xsl:text>→</xsl:text>
                    </a>
                    <xsl:text>]</xsl:text>
                </xsl:if>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template> 
    
    <xsl:template match="tei:rs">
        <xsl:choose>
            <xsl:when test="@ref=concat('#',$q)">
                <xsl:variable name="hitNo">
                    <xsl:number level="any" count="tei:rs[@ref=concat('#',$q)]"/>
                </xsl:variable>
                <a>
                    <xsl:attribute name="name">
                        <xsl:text>hit</xsl:text><xsl:value-of select="$hitNo"/>
                    </xsl:attribute>
                    <xsl:text> </xsl:text>
                </a>
                <span style="background-color:yellow;">
                    <xsl:choose>
                        <xsl:when test="@type='person' or @type='author' or @type='place' or @type='event' or @type='org'">
                            <a>
                                <xsl:attribute name="href">
                                    <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$server"/><xsl:value-of select="$dir"/><xsl:text>','tei-introduction.xml','http://diglib.hab.de/</xsl:text><xsl:value-of select="$dir"/><xsl:text>/show_person.xsl','</xsl:text><xsl:value-of select="substring(@ref,2)"/><xsl:text>',400,600)</xsl:text>
                                </xsl:attribute>
                                <xsl:apply-templates/>
                            </a>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:apply-templates/>
                        </xsl:otherwise>
                    </xsl:choose>
                </span>
                <xsl:if test="$hitNo &gt; 1">
                    <xsl:text> [</xsl:text><a style="font-weight:900;font-size:larger;">
                        <xsl:attribute name="href">
                            <xsl:text>#hit</xsl:text>
                            <xsl:value-of select="$hitNo - 1"/>
                        </xsl:attribute>
                        <xsl:attribute name="title"><xsl:text>voriger Treffer</xsl:text></xsl:attribute>
                        <xsl:text>←</xsl:text>
                    </a><xsl:text>]</xsl:text>
                </xsl:if>
                <xsl:if test="$hitNo &lt; count(//tei:rs[@ref=concat('#',$q)])">
                    <xsl:text> [</xsl:text>
                    <a style="font-weight:900;font-size:larger;">
                        <xsl:attribute name="href">
                            <xsl:text>#hit</xsl:text>
                            <xsl:value-of select="$hitNo + 1"/>
                        </xsl:attribute>
                        <xsl:attribute name="title"><xsl:text>nächster Treffer</xsl:text></xsl:attribute>
                        <xsl:text>→</xsl:text>
                    </a>
                    <xsl:text>]</xsl:text>
                </xsl:if>
            </xsl:when>
            <xsl:otherwise>
                <xsl:choose>
                    <xsl:when test="@type='person' or @type='author'  or @type='org'">
                        <a>
                                <xsl:attribute name="href">
                                    <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','tei-introduction.xml','http://diglib.hab.de/</xsl:text><xsl:value-of select="$dir"/><xsl:text>/show_person.xsl','</xsl:text><xsl:value-of select="substring(@ref,2)"/><xsl:text>',300,500)</xsl:text>
                                </xsl:attribute>
                                <xsl:apply-templates/>
                            </a>
                    </xsl:when>
                    <xsl:when test="@type='place'">
                        <a>
                            <xsl:attribute name="href">
                                <xsl:text>javascript:show_annotation('</xsl:text><xsl:value-of select="$dir"/><xsl:text>','tei-introduction.xml','http://diglib.hab.de/</xsl:text><xsl:value-of select="$dir"/><xsl:text>/show_place.xsl','</xsl:text><xsl:value-of select="substring(@ref,2)"/><xsl:text>',300,500)</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates/> 
                        </a>
                    </xsl:when>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
            
        
    </xsl:template>
    
    <xsl:template match="tei:rs">
        <xsl:choose>
            
            <xsl:when test="@type='person' ">
                <a>
                    <xsl:attribute name="href">
                        <xsl:text>javascript:show_annotation('edoc/ed000211','register/register-person.xml','show_person.xsl','</xsl:text><xsl:value-of select="substring(@ref,2)"/><xsl:text>',400,800);</xsl:text>   
                    </xsl:attribute>
                    <xsl:attribute name="title">
                        <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:person[@xml:id =substring(current()/@ref,2)]/tei:persName/tei:forename"/><xsl:text> </xsl:text>
                        <xsl:if test="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:person[@xml:id =substring(current()/@ref,2)]/tei:persName/tei:nameLink">
                            <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:person[@xml:id =substring(current()/@ref,2)]/tei:persName/tei:nameLink"/>
                            <xsl:text> </xsl:text>
                        </xsl:if>
                        <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:person[@xml:id =substring(current()/@ref,2)]/tei:persName/tei:surname"/>
                        <xsl:if test="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:person[@xml:id =substring(current()/@ref,2)]/tei:birth or /tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:person[@xml:id =substring(current()/@ref,2)]/tei:death">
                            <xsl:text> (</xsl:text>
                        </xsl:if>   
                        <xsl:if test="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:person[@xml:id =substring(current()/@ref,2)]/tei:birth">
                            <xsl:value-of select="normalize-space(/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:person[@xml:id =substring(current()/@ref,2)]/tei:birth/text())"/>
                        </xsl:if>
                        <xsl:if test="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:person[@xml:id =substring(current()/@ref,2)]/tei:birth or /tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:person[@xml:id =substring(current()/@ref,2)]/tei:death">
                            <xsl:text> - </xsl:text>
                        </xsl:if>
                        <xsl:if test="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:person[@xml:id =substring(current()/@ref,2)]/tei:death">
                            <xsl:value-of select="normalize-space(/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:person[@xml:id =substring(current()/@ref,2)]/tei:death/text())"/>
                        </xsl:if>
                        <xsl:if test="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:person[@xml:id =substring(current()/@ref,2)]/tei:birth or /tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:person[@xml:id =substring(current()/@ref,2)]/tei:death">
                            <xsl:text>)</xsl:text>
                        </xsl:if>
                    </xsl:attribute>
                    <xsl:apply-templates/>
                    
                </a>
            </xsl:when>
            <xsl:when test="@type='org' ">
                <a>
                    <xsl:attribute name="href">
                        <xsl:text>javascript:show_annotation('edoc/ed000211','register/register-person.xml','show_person.xsl','</xsl:text><xsl:value-of select="substring(@ref,2)"/><xsl:text>',300,500);</xsl:text>   
                    </xsl:attribute>
                    <xsl:attribute name="title">
                        <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:org[@xml:id =substring(current()/@ref,2)]/tei:orgName/tei:name"/><xsl:text> </xsl:text>
                        <xsl:if test="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:org[@xml:id =substring(current()/@ref,2)]/tei:orgName/tei:name/tei:nameLink">
                            <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:org[@xml:id =substring(current()/@ref,2)]/tei:orgName/tei:name/tei:nameLink"/>
                            <xsl:text> </xsl:text>
                        </xsl:if>
                        <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPerson/tei:org[@xml:id =substring(current()/@ref,2)]/tei:orgName/tei:name"/>        
                    </xsl:attribute>
                    <xsl:apply-templates/>
                    
                </a>
            </xsl:when>
            <xsl:when test="@type='work' ">
                <q>
                    <a href="{@ref}">
                        <xsl:apply-templates/>
                    </a>
                </q>
            </xsl:when>
            <xsl:when test="@type='place' ">
                <a>
                    <xsl:attribute name="href">
                        <xsl:text>javascript:show_annotation('edoc/ed000211','register/register-place.xml','show_place.xsl','</xsl:text><xsl:value-of select="substring(@ref,2)"/><xsl:text>',300,500);</xsl:text>   
                    </xsl:attribute>
                    <xsl:attribute name="title">
                        <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPlace/tei:place[@xml:id =substring(current()/@ref,2)]/tei:placeName"/><xsl:text> </xsl:text>
                        <xsl:if test="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPlace/tei:place[@xml:id =substring(current()/@ref,2)]/tei:placeName/tei:nameLink"><xsl:text> </xsl:text>
                            <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPlace/tei:place[@xml:id =substring(current()/@ref,2)]/tei:placeName/tei:nameLink"/>
                            <xsl:text> </xsl:text>
                        </xsl:if>
                    </xsl:attribute>
                    <xsl:apply-templates/>
                </a>
            </xsl:when>
            
            <xsl:when test="@type='event' ">
                <a>
                    <xsl:attribute name="href">
                        <xsl:text>javascript:show_annotation('edoc/ed000211','register/register-event.xml','show_event.xsl','</xsl:text><xsl:value-of select="substring(@ref,2)"/><xsl:text>',300,500);</xsl:text>   
                    </xsl:attribute>
                    <xsl:attribute name="title">
                        <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listEvent/tei:event[@xml:id =substring(current()/@ref,2)]/tei:label"/><xsl:text> </xsl:text>
                        <xsl:if test="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listEvent/tei:event[@xml:id =substring(current()/@ref,2)]/tei:label/tei:nameLink"><xsl:text> </xsl:text>
                            <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listEvent/tei:event[@xml:id =substring(current()/@ref,2)]/tei:label/tei:nameLink"/>
                            <xsl:text> </xsl:text>
                        </xsl:if>
                    </xsl:attribute>
                    <xsl:apply-templates/>
                </a>
            </xsl:when>
            
            <xsl:when test="@type='pelagios' ">
              
                  <div>
                        <xsl:text>id="WIDGET_ID" data-pleiades_id="PLEIADES_ID" class="pelagios pelagios-place"></xsl:text>   
                  </div>
                    <xsl:attribute name="title">
                        <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPlace/tei:place[@xml:id =substring(current()/@ref,2)]/tei:placeName"/><xsl:text> </xsl:text>
                        <xsl:if test="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPlace/tei:place[@xml:id =substring(current()/@ref,2)]/tei:placeName/tei:nameLink"><xsl:text> </xsl:text>
                            <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listPlace/tei:place[@xml:id =substring(current()/@ref,2)]/tei:placeName/tei:nameLink"/>
                            <xsl:text> </xsl:text>
                        </xsl:if>
                    </xsl:attribute>
                    <xsl:apply-templates/>
                
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates/>
            </xsl:otherwise>
            
        </xsl:choose>

    </xsl:template>
    
    
    <xsl:template match="tei:bibl/tei:ref">
    <xsl:choose> 
        
        <xsl:when test="@type='bibliography'">
            <a>
                <xsl:attribute name="href">
                    <xsl:text>javascript:show_annotation('edoc/ed000211','register/register-bibl.xml','show_bibl.xsl','</xsl:text><xsl:value-of select="substring(@target,2)"/><xsl:text>',300,500);</xsl:text>   
                </xsl:attribute>
                <xsl:attribute name="title">
                    <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listBibl/tei:bibl[@xml:id =substring(current()/@ref,2)]"/><xsl:text> </xsl:text>
                    <xsl:if test="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listBibl/tei:bibl[@xml:id =substring(current()/@ref,2)]/tei:nameLink"><xsl:text> </xsl:text>
                        <xsl:value-of select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:listBibl/tei:bibl[@xml:id =substring(current()/@ref,2)]/tei:nameLink"/>
                        <xsl:text> </xsl:text>
                    </xsl:if>
                </xsl:attribute>
                <xsl:apply-templates/>
            </a>
        </xsl:when>
    </xsl:choose>
    </xsl:template>
    
    <xsl:template match="tei:graphic">
        <div style="position:relative;">
            <div style="float:left;">
                <img border="0" style="height:250px; padding-right: 7%;">
                    <xsl:attribute name="src">
                        <xsl:value-of select="@url"/>
                    </xsl:attribute>
                </img>
          
            </div>
        </div>
            
    </xsl:template>

</xsl:stylesheet>
