<?xml version="1.0" encoding="UTF-8"?>

<!--
    Project: KONDE Weißbuch
    Company: ZIM-ACDH (Zentrum für Informationsmodellierung - Austrian Centre for Digital Humanities)
    Author: Selina Galka
    Last update: 2021
-->

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" xmlns="http://www.w3.org/1999/xhtml"
    xmlns:t="http://www.tei-c.org/ns/1.0" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
    xmlns:oai="http://www.openarchives.org/OAI/2.0/" xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    exclude-result-prefixes="#all">
    <xsl:include href="konde-static.xsl"/>
    <xsl:output method="xml" doctype-system="about:legacy-compat" encoding="UTF-8" indent="no"/>

    <xsl:strip-space elements="t:hi"/>
    

    <xsl:template name="content">

        <section class="row ">
            <article class="col-md-8">
                <div class="panel panel-border">

                    <div class="row">

                        <h3 class="col-md-11">
                            <xsl:value-of select="//t:body/t:div/t:head"/>
                            <xsl:text> </xsl:text>
                            <span class="TEI">
                                <a href="/archive/objects/{$teipid}/datastreams/TEI_SOURCE/content"
                                    target="_blank">
                                    <xsl:text/>
                                    <img width="20" height="21" title="TEI Download"
                                        alt="TEI Download" src="{$gamsdev}/konde/img/tei_icon.gif"/>
                                </a>
                            </span>
                            <!-- PDF-Ausgabe momentan nur bei den Weißbuchartikeln, nicht bei den Projektbeschreibungen (enthalten 'p' im PID) -->
                            <xsl:if test="not(contains($teipid, 'p'))">
                                <xsl:text> </xsl:text>
                                <span class="TEI">
                                    <a
                                        href="/archive/objects/{$teipid}/methods/sdef:TEI/getLaTeXPDF"
                                        target="_blank">
                                        <xsl:text/>
                                        <img width="20" height="21" title="PDF Download"
                                            alt="PDF Download"
                                            src="{$gamsdev}/konde/img/pdf-icon.png"/>
                                    </a>
                                </span>
                            </xsl:if>
                        </h3>

                        <button type="button" class="btn btn-link btn-sm" style="color:#04B4AE"
                            onclick="goBack()">zurück</button>
                        <script>
                            function goBack() {
                            window.history.back();
                            }
                        </script>

                    </div>

                    <!-- Workflow Digitalisierung -->
                    <xsl:if test="//t:facsimile">
                        <div class="panel">
                            <xsl:value-of select="$teipid"/>
                            <!-- Test -->
                            <xsl:call-template name="simple_osd_viewer">
                                <xsl:with-param name="pid" select="concat('/', $teipid)"/>
                            </xsl:call-template>
                        </div>
                    </xsl:if>

                    <!-- Ausgabe des Artikeltextes -->
                    <h4>
                        <xsl:value-of select="//t:body/t:div/t:div/t:head"/>
                     
                    </h4>
                   <xsl:if test="//t:revisionDesc//t:ab/contains(., 'Überarbeitung')">
                       <p><i> <xsl:text>Dieser Artikel basiert</xsl:text>
                        <a>
                            <xsl:attribute name="href"><xsl:value-of select="concat('/', $teipid)"/>
                                <xsl:value-of select="document(concat('/', $teipid, '/VERSIONING'))/rdf:RDF/rdf:Description[2]/substring-after(@rdf:about, $teipid)"/>
                            </xsl:attribute>
                            auf der älteren Version
                        </a><xsl:text>von N.N.</xsl:text></i></p>
                    </xsl:if>

                    <xsl:choose>
                        <!-- Projektbeschreibung -->
                        <xsl:when test="contains(//t:sourceDesc/t:p, 'Projektbeschreibung')">
                            <xsl:apply-templates select="//t:div[@type = 'text']"/>
                        </xsl:when>
                        <!-- Weißbuchartikel -->
                        <xsl:when test="//t:sourceDesc/t:p, 'Weißbuchartikel'">
                            <xsl:apply-templates
                                select="//t:body/t:div/t:div/t:p | //t:body/t:div/t:div/t:list | //t:body/t:div/t:div/t:table"
                            />
                        </xsl:when>
                    </xsl:choose>

                    <!-- Fußnoten in Projektbeschreibungen -->
                    <xsl:if test="//t:note/@xml:id">
                        <xsl:if test="//@xml:lang = 'de'">
                            <h5>Anmerkungen:</h5>
                        </xsl:if>
                        <xsl:if test="//@xml:lang = 'en'">
                            <h5>Notes:</h5>
                        </xsl:if>
                        <xsl:apply-templates mode="footnote" select="//t:note"/>
                    </xsl:if>

                    <!-- Hinweise bei den Klagenfurter-Weißbucheinträgen -->
                    <xsl:if test="//t:note[@type = 'entry']">
                        <div class="alert alert-info">
                            <p>
                                <xsl:value-of select="//t:note[@type = 'entry']"/>
                            </p>
                        </div>
                    </xsl:if>

                    <!-- wenn es Literaturliste gibt (Projektbeschreibungen)  -->
                    <xsl:if test="//t:div[@type = 'literature']">
                        <xsl:if test="//@xml:lang = 'de'">
                            <h3>Literatur:</h3>
                        </xsl:if>
                        <xsl:if test="//@xml:lang = 'en'">
                            <h3>References:</h3>
                        </xsl:if>
                        <xsl:apply-templates select="//t:listBibl"/>
                    </xsl:if>

                </div>

            </article>

            <!-- rechte Box mit weiterführenden Links, einzelne Unterblöcke werden nur angezeigt, wenn sie im TEI auch vorhanden sind, 
            otherwise wird auf die Projektbeschreibungen angewandt-->

            <article class="col-md-4">

                <xsl:choose>
                    <xsl:when test="contains(//t:sourceDesc/t:bibl/t:title, 'Weißbuchartikel')">

                        <div class="panel panel-border">

                            <xsl:if test="//t:div[@xml:id = 'links']">
                                <h3>Weiter bei...</h3>
                                <div>
                                    <xsl:apply-templates select="//t:div[@xml:id = 'links']"
                                        mode="weiteres"/>
                                </div>
                            </xsl:if>

                            <xsl:if test="//t:div[@xml:id = 'lexica']">
                                <h3>Lexika</h3>
                                <div>
                                    <xsl:apply-templates select="//t:div[@xml:id = 'lexica']"
                                        mode="weiteres"/>
                                </div>
                            </xsl:if>

                            <xsl:if test="//t:div[@xml:id = 'software']">
                                <h3>Software</h3>
                                <div>
                                    <xsl:apply-templates select="//t:div[@xml:id = 'software']"
                                        mode="weiteres"/>
                                </div>
                            </xsl:if>

                            <xsl:if test="//t:div[@xml:id = 'projects']">
                                <h3>Projekte</h3>
                                <div>
                                    <xsl:apply-templates select="//t:div[@xml:id = 'projects']"
                                        mode="weiteres"/>
                                </div>
                            </xsl:if>
                            <xsl:if test="//t:div[@xml:id = 'topics']">
                                <h3>Mehr zum Thema...</h3>
                                <div>
                                    <ul>
                                        <xsl:for-each
                                            select="//t:div[@xml:id = 'topics']/t:list/t:item">

                                            <li>
                                                <a style="color:orangeM">
                                                  <xsl:attribute name="href">
                                                  <xsl:if test="contains(., 'Einführung')">
                                                  <xsl:text>/archive/objects/context:konde/methods/sdef:Context/get?mode=themes#T1</xsl:text>
                                                  </xsl:if>
                                                  <xsl:if test="contains(., 'Digitalisierung')">
                                                  <xsl:text>/archive/objects/context:konde/methods/sdef:Context/get?mode=themes#T2</xsl:text>
                                                  </xsl:if>
                                                  <xsl:if test="contains(., 'Metadaten')">
                                                  <xsl:text>/archive/objects/context:konde/methods/sdef:Context/get?mode=themes#T3</xsl:text>
                                                  </xsl:if>
                                                  <xsl:if
                                                  test="contains(., 'Annotation und Modellierung')">
                                                  <xsl:text>/archive/objects/context:konde/methods/sdef:Context/get?mode=themes#T4</xsl:text>
                                                  </xsl:if>
                                                  <xsl:if
                                                  test="contains(., 'Natural Language Processing')">
                                                  <xsl:text>/archive/objects/context:konde/methods/sdef:Context/get?mode=themes#T5</xsl:text>
                                                  </xsl:if>
                                                  <xsl:if test="contains(., 'Interfaces')">
                                                  <xsl:text>/archive/objects/context:konde/methods/sdef:Context/get?mode=themes#T6</xsl:text>
                                                  </xsl:if>
                                                  <xsl:if test="contains(., 'Datenanalyse')">
                                                  <xsl:text>/archive/objects/context:konde/methods/sdef:Context/get?mode=themes#T7</xsl:text>
                                                  </xsl:if>
                                                  <xsl:if test="contains(., 'Archivierung')">
                                                  <xsl:text>/archive/objects/context:konde/methods/sdef:Context/get?mode=themes#T8</xsl:text>
                                                  </xsl:if>
                                                  <xsl:if
                                                  test="contains(., 'Digitale Editionswissenschaft')">
                                                  <xsl:text>/archive/objects/context:konde/methods/sdef:Context/get?mode=themes#T9</xsl:text>
                                                  </xsl:if>
                                                  <xsl:if test="contains(., 'Institutionen')">
                                                  <xsl:text>/archive/objects/context:konde/methods/sdef:Context/get?mode=themes#T10</xsl:text>
                                                  </xsl:if>
                                                  <xsl:if
                                                  test="contains(., 'Software und Softwareentwicklung')">
                                                  <xsl:text>/archive/objects/context:konde/methods/sdef:Context/get?mode=themes#T11</xsl:text>

                                                  </xsl:if>
                                                  <xsl:if test="contains(., 'Rechtliche Aspekte')">
                                                  <xsl:text>/archive/objects/context:konde/methods/sdef:Context/get?mode=themes#T12</xsl:text>

                                                  </xsl:if>
                                                  </xsl:attribute>
                                                  <!-- <xsl:attribute name="href">
                                                        <xsl:value-of select="concat('http://glossa.uni-graz.at/archive/objects/context:konde/methods/sdef:Context/get?mode=themes#', .)"/>
                                                    </xsl:attribute>-->
                                                  <xsl:value-of select="."/>
                                                </a>

                                            </li>
                                        </xsl:for-each>
                                    </ul>

                                </div>
                            </xsl:if>


                        </div>
                    </xsl:when>

                    <!-- Projektbeschreibungen -->
                    <xsl:otherwise>
                        <div class="panel panel-border">
                            <xsl:if test="//@xml:lang = 'de'">
                                <h3>Informationen:</h3>
                            </xsl:if>
                            <xsl:if test="//@xml:lang = 'en'">
                                <h3>Metadata:</h3>
                            </xsl:if>
                            <xsl:apply-templates select="//t:div[@type = 'info']"/>
                        </div>
                    </xsl:otherwise>
                </xsl:choose>

                <!-- Zitiervorschlag -->
                <div class="panel panel-border">
                    <div>
                        <xsl:if test="//@xml:lang = 'de'">
                            <h3>Zitiervorschlag:</h3>
                        </xsl:if>
                        <xsl:if test="//@xml:lang = 'en'">
                            <h3>Suggested citation:</h3>
                        </xsl:if>

                        <xsl:choose>
                            <xsl:when test="//t:idno[@type = 'PID'] = 'o:konde.p25'">
                                <!-- Projektbeschreibung mit eigenem Zitiervorschlag -->
                                <p>Zitiervorschlag: Roman Bleier, Eva Ortlieb, Florian Zeilinger.
                                    “Der Regensburger Reichstag 1576 - digital.” In: Digitale
                                    Edition in Österreich, hg. von Roman Bleier und Helmut W. Klug
                                    (Schriften des Instituts für Dokumentologie und Editorik 16).
                                    Norderstedt: Books on Demand, im Druck.</p>
                            </xsl:when>
                            <xsl:otherwise>
                                <!-- alle anderen Zitiervorschläge bei den Artikeln + Projekten -->
                                <p>
                                    <xsl:for-each select="//t:titleStmt/t:author">
                                        <xsl:value-of select="t:persName/t:surname"/>
                                        <xsl:text>, </xsl:text>
                                        <xsl:value-of select="t:persName/t:forename"/>
                                        <xsl:choose>
                                            <xsl:when test="position() = last()">
                                                <xsl:choose>
                                                  <!-- Namen die keinen abgekürzten zweiten Vornamen enthalten -->
                                                  <xsl:when
                                                  test="not(contains(t:persName/t:forename, '.'))">
                                                      <xsl:choose>
                                                          <xsl:when test="//t:publicationStmt/t:date = '2024'">
                                                              <xsl:text> 2024. </xsl:text>
                                                          </xsl:when>
                                                          <xsl:otherwise>
                                                              <xsl:text> 2021. </xsl:text>
                                                          </xsl:otherwise>
                                                      </xsl:choose>
                                                  </xsl:when>
                                                  <!-- alle anderen Namen -->
                                                  <xsl:otherwise>
                                                      <xsl:choose>
                                                          <xsl:when test="//t:publicationStmt/t:date = '2024'">
                                                              <xsl:text> 2024. </xsl:text>
                                                          </xsl:when>
                                                          <xsl:otherwise>
                                                              <xsl:text> 2021. </xsl:text>
                                                          </xsl:otherwise>
                                                      </xsl:choose>
                                                  </xsl:otherwise>
                                                </xsl:choose>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:text>; </xsl:text>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:for-each>
                                    <i>
                                        <xsl:value-of select="//t:title[@type = 'main']"/>
                                    </i>
                                    
                                   <xsl:choose>
                                       <xsl:when test="//t:publicationStmt/t:date = '2024'">
                                           <xsl:text>. In: KONDE Weißbuch. Hrsg. v. Selina Galka und Helmut W. Klug unter Mitarbeit von Susanne Höfer im Projekt "Enlarging 'Weißbuch Digitale Edition'".</xsl:text>
                                       </xsl:when>
                                       <xsl:otherwise>
                                           <xsl:text>. In: KONDE Weißbuch. Hrsg. v. Helmut W. Klug unter Mitarbeit von Selina Galka und Elisabeth Steiner im HRSM Projekt "Kompetenznetzwerk Digitale Edition".</xsl:text>
                                       </xsl:otherwise>
                                   </xsl:choose>
                                    <xsl:text> Aufgerufen am: </xsl:text>
                                    <span id="datetime">
                                        <xsl:text> </xsl:text>
                                    </span>
                                    <xsl:text>. Handle: hdl.handle.net/</xsl:text>
                                    <xsl:value-of
                                        select="substring-after(document(concat('/', $teipid, '/RELS-EXT'))//oai:itemID, 'hdl:')"/>
                                    <xsl:text>. PID: </xsl:text>
                                    <xsl:value-of select="$teipid"/>



                                    <script>
                                        var dt = new Date();
                                        document.getElementById("datetime").innerHTML = dt.toLocaleDateString();
                                    </script>

                                </p>
                            </xsl:otherwise>
                        </xsl:choose>
                    </div>
                </div>
                
                
                <div class="panel panel-border">
                    <div>
                      
                            <h3>Metadata:</h3>
                       <p>Hier finden Sie umfangreiche Metadaten; außerdem auch ältere Versionen der Weißbucheinträge:<a
                            href="/archive/objects/{$teipid}/methods/sdef:Object/getDC"
                            target="_blank">
                            <xsl:text> Metadaten</xsl:text>
                        </a></p>
                        <xsl:if test="doc-available(concat('/', $teipid, '/VERSIONING'))">
                            
                            
                            
                            <a>
                                <xsl:attribute name="href"><xsl:value-of select="concat('/', $teipid)"/>
                                    <xsl:value-of select="document(concat('/', $teipid, '/VERSIONING'))/rdf:RDF/rdf:Description[2]/substring-after(@rdf:about, $teipid)"/>
                                </xsl:attribute>
                                Für diesen Artikel existiert eine ältere Version, die Sie hier einsehen können.
                            </a>
                            <p></p>
                           
                          
                          
                            
                           
                        </xsl:if>
                        
                        


                    </div>
                </div>
            </article>
        </section>

    </xsl:template>

    <!-- bibl-Element im Fließtext der Weißbuchartikel -->
    <xsl:template match="//t:bibl">
        <xsl:apply-templates/>
    </xsl:template>


    <!-- Verweise, Software und Projekte in Weißbuchartikeln -->
    <xsl:template match="//t:list" mode="weiteres">
        <xsl:if test="t:head">
            <h5>
                <xsl:value-of select="t:head"/>
            </h5>
        </xsl:if>
        <ul>
            <xsl:for-each select="t:item">
                <xsl:sort
                    select="translate(., 'abcdefghijklmnopqrstuvwxyzäöü', 'ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜ')"/>
                <li>
                    <xsl:apply-templates/>
                </li>
            </xsl:for-each>
        </ul>
    </xsl:template>


    <xsl:template match="//t:list">
        <xsl:choose>
            <!-- Ausgabe der Liste der Hybrideditionen in o:konde.117 -->
            <xsl:when test="contains(t:head, 'Liste der Hybrideditionen')">
                <ul>
                    <xsl:for-each select="t:item">
                        <li style="margin-bottom:14px">
                            <strong>
                                <xsl:value-of select="t:name"/>
                                <xsl:text> (</xsl:text>
                                <xsl:value-of select="t:date"/>
                                <xsl:text>)</xsl:text>
                            </strong>
                            <br/>
                            <xsl:text>URL: </xsl:text>
                            <a>
                                <xsl:attribute name="href">
                                    <xsl:value-of select="t:ref/@target"/>
                                </xsl:attribute>
                                <xsl:value-of select="t:ref/@target"/>
                            </a>
                            <br/>
                            <xsl:for-each select="t:biblStruct">
                                <xsl:call-template name="create_bibl"/>
                            </xsl:for-each>
                        </li>
                    </xsl:for-each>
                </ul>
            </xsl:when>

            <!-- alle anderen Listen -->
            <xsl:otherwise>
                <ul>
                    <xsl:for-each select="t:item">
                        <li>
                            <xsl:apply-templates/>
                        </li>
                    </xsl:for-each>
                </ul>
            </xsl:otherwise>
        </xsl:choose>

    </xsl:template>


    <!-- Literaturverzeichnis der Weißbuchartikel -->

    <xsl:template match="t:listBibl">
        <xsl:if test="t:head">
            <h5>
                <xsl:value-of select="t:head"/>
            </h5>
        </xsl:if>
        <ul>
            <xsl:for-each select="t:bibl">
                <!-- bibliographische Zitate in Projektbeschreibungen -->
                <li>
                    <xsl:apply-templates/>
                </li>
            </xsl:for-each>

            <xsl:for-each select="t:biblStruct">
                <!-- bibliographische Zitate in den Artikeln -->
                <li>
                    <xsl:call-template name="create_bibl"/>
                </li>
            </xsl:for-each>
        </ul>
    </xsl:template>

    <!-- template create_bibl = Literaturreferenzen in den Weißbuchartikeln -->

    <xsl:template name="create_bibl">
        <xsl:if test="not(contains(., @ana))">
            <!-- URLS die zu lang sind, haben Attribut ana=linebreak -->
            <xsl:attribute name="style">
                <xsl:text>line-break:anywhere</xsl:text>
            </xsl:attribute>
        </xsl:if>

        <xsl:choose>

            <xsl:when
                test="@type = 'book' or @type = 'report' or @type = 'document' or @type = 'thesis' or @type = 'blogPost'">
                <xsl:if test="t:monogr/t:author != ''">
                    <xsl:for-each select="t:monogr/t:author">
                        <xsl:call-template name="author"/>
                    </xsl:for-each>
                </xsl:if>
                <xsl:if test="t:monogr/t:editor != '' and not(t:monogr/t:author)">
                    <xsl:for-each select="t:monogr/t:editor">
                        <xsl:call-template name="editor"/>
                    </xsl:for-each>
                </xsl:if>
                <xsl:if test="t:monogr/t:imprint/t:date != ''">
                    <xsl:if test="t:monogr/t:author != ''">
                        <xsl:text>. </xsl:text>
                    </xsl:if>
                    <xsl:value-of select="t:monogr/t:imprint/t:date"/>
                </xsl:if>
                <xsl:if test="t:monogr/t:title != ''">
                    <xsl:text>. </xsl:text>
                    <i>
                        <xsl:value-of select="t:monogr/t:title"/>
                    </i>
                </xsl:if>
                <xsl:if test="t:monogr//t:imprint/t:pubPlace != ''">
                    <xsl:text>. </xsl:text>
                    <xsl:value-of select="t:monogr/t:imprint/t:pubPlace"/>
                </xsl:if>
                <xsl:if test="t:monogr/t:series != ''">
                    <xsl:text>, </xsl:text>
                    <xsl:value-of select="t:monogr/t:series"/>
                </xsl:if>
                <xsl:if test="@type = 'thesis'">
                    <xsl:if test="t:monogr/t:imprint/t:note[@type = 'thesisType']">
                        <xsl:text>, </xsl:text>
                        <xsl:value-of select="t:monogr/t:imprint/t:note[@type = 'thesisType']"/>
                    </xsl:if>
                </xsl:if>

                <xsl:if test="t:monogr/t:imprint/t:note[@type = 'url'] != ''">
                    <xsl:call-template name="url"/>
                </xsl:if>
                <xsl:text>.</xsl:text>
            </xsl:when>
            
            <xsl:when
                test="@type = 'computerProgram'">
                <xsl:if test="t:monogr/t:respStmt/t:persName != ''">
                    <xsl:for-each select="t:monogr/t:respStmt/t:persName">
                        <xsl:call-template name="author"/>
                    </xsl:for-each>
                </xsl:if>
                <xsl:if test="t:monogr/t:editor != '' and not(t:monogr/t:author)">
                    <xsl:for-each select="t:monogr/t:editor">
                        <xsl:call-template name="editor"/>
                    </xsl:for-each>
                </xsl:if>
                <xsl:if test="t:monogr/t:imprint/t:date != ''">
                    <xsl:if test="t:monogr/t:respStmt/t:persName != ''">
                        <xsl:text>. </xsl:text>
                    </xsl:if>
                    <xsl:value-of select="t:monogr/t:imprint/t:date"/>
                </xsl:if>
                <xsl:if test="t:monogr/t:title != ''">
                    <xsl:text>. </xsl:text>
                    <i>
                        <xsl:value-of select="t:monogr/t:title"/>
                    </i>
                </xsl:if>
                <xsl:if test="t:monogr//t:imprint/t:pubPlace != ''">
                    <xsl:text>. </xsl:text>
                    <xsl:value-of select="t:monogr/t:imprint/t:pubPlace"/>
                </xsl:if>
                <xsl:if test="t:monogr/t:series != ''">
                    <xsl:text>, </xsl:text>
                    <xsl:value-of select="t:monogr/t:series"/>
                </xsl:if>
                <xsl:if test="@type = 'thesis'">
                    <xsl:if test="t:monogr/t:imprint/t:note[@type = 'thesisType']">
                        <xsl:text>, </xsl:text>
                        <xsl:value-of select="t:monogr/t:imprint/t:note[@type = 'thesisType']"/>
                    </xsl:if>
                </xsl:if>
                
                <xsl:if test="t:monogr/t:imprint/t:note[@type = 'url'] != ''">
                    <xsl:call-template name="url"/>
                </xsl:if>
                <xsl:text>.</xsl:text>
            </xsl:when>


            <xsl:when test="@type = 'presentation'">
                <xsl:if test="t:monogr/t:respStmt/t:persName != ''">
                    <xsl:for-each select="t:monogr/t:respStmt/t:persName">
                        <xsl:value-of select="t:surname"/>
                        <xsl:text>, </xsl:text>
                        <xsl:value-of select="t:forename"/>
                        <xsl:choose>
                            <xsl:when test="position() = last()"> </xsl:when>
                            <xsl:otherwise>
                                <xsl:text>; </xsl:text>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:for-each>
                </xsl:if>
                <xsl:if test="t:monogr/t:imprint/t:date != ''">
                    <xsl:text>. </xsl:text>
                    <xsl:value-of select="t:monogr/t:imprint/t:date"/>
                </xsl:if>
                <xsl:if test="t:monogr/t:title != ''">
                    <xsl:text>. </xsl:text>
                    <i>
                        <xsl:value-of select="t:monogr/t:title"/>
                    </i>
                </xsl:if>
                <xsl:if test="t:monogr/t:editor != ''">
                    <xsl:text>, </xsl:text>
                    <xsl:value-of select="t:monogr/t:editor"/>
                </xsl:if>
                <xsl:if test="t:monogr//t:imprint/t:pubPlace != ''">
                    <xsl:text>. </xsl:text>
                    <xsl:value-of select="t:monogr/t:imprint/t:pubPlace"/>
                </xsl:if>
                <xsl:if test="t:monogr/t:series != ''">
                    <xsl:text>, </xsl:text>
                    <xsl:value-of select="t:monogr/t:series"/>
                </xsl:if>
                <xsl:if test="t:monogr/t:imprint/t:note[@type = 'url'] != ''">
                    <xsl:call-template name="url"/>
                </xsl:if>
                <xsl:text>.</xsl:text>
            </xsl:when>


            <xsl:when test="@type = 'webpage'">
                <xsl:if test="t:analytic/t:author != ''">
                    <xsl:for-each select="t:analytic/t:author">
                        <xsl:call-template name="author"/>
                    </xsl:for-each>
                    <xsl:text>. </xsl:text>
                </xsl:if>
                <!-- <xsl:if test="t:monogr/t:imprint/t:date != ''">
                    <xsl:value-of select="t:monogr/t:imprint/t:date"/>          
                </xsl:if>-->
                <xsl:choose>
                    <xsl:when test="ends-with(t:analytic/t:title[@level = 'a'], '?')">
                        <xsl:value-of select="translate(t:analytic/t:title, '?', '')"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="t:analytic/t:title[@level = 'a']"/>
                    </xsl:otherwise>

                </xsl:choose>

                <xsl:call-template name="url"/>
            </xsl:when>


            <!-- Beiträge in Sammelbänden, Zeitschriftenartikel usw. -->

            <xsl:otherwise>
                <xsl:if test="t:analytic/t:author != ''">
                    <xsl:for-each select="t:analytic/t:author">
                        <xsl:call-template name="author"/>
                    </xsl:for-each>
                </xsl:if>
                <xsl:if test="t:monogr/t:imprint/t:date != ''">
                    <xsl:if test="t:analytic/t:author != ''">
                        <xsl:text>. </xsl:text>
                    </xsl:if>
                    <xsl:value-of select="t:monogr/t:imprint/t:date"/>
                </xsl:if>
                <xsl:if test="t:analytic/t:title != ''">
                    <xsl:if test="t:analytic/t:author != ''">
                        <xsl:text>. </xsl:text>
                    </xsl:if>
                    <i>
                        <xsl:choose>
                            <xsl:when test="ends-with(t:analytic/t:title[@level = 'a'], '?')">
                                <xsl:value-of
                                    select="translate(t:analytic/t:title[@level = 'a'], '?', '')"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="t:analytic/t:title[@level = 'a']"/>
                            </xsl:otherwise>

                        </xsl:choose>
                    </i>
                </xsl:if>
                <xsl:if test="t:monogr/t:title != ''">
                    <xsl:text>. In: </xsl:text>
                    <xsl:value-of select="t:monogr/t:title"/>
                </xsl:if>
                <xsl:if test="t:monogr/t:imprint/t:biblScope[@unit = 'volume'] != ''">
                    <xsl:text> </xsl:text>
                    <xsl:value-of select="t:monogr/t:imprint/t:biblScope[@unit = 'volume']"/>
                </xsl:if>
                <xsl:if test="t:monogr/t:editor != ''">
                    <xsl:choose>
                        <xsl:when test="count(t:monogr/t:editor) = 1">
                            <xsl:text>. Hrsg. von </xsl:text>
                            <xsl:choose>
                                <xsl:when test="t:monogr/t:editor/t:name">
                                    <xsl:value-of select="t:monogr/t:editor/t:name"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="t:monogr/t:editor/t:forename"/>
                                    <xsl:text> </xsl:text>
                                    <xsl:value-of select="t:monogr/t:editor/t:surname"/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:text>. Hrsg. von </xsl:text>
                            <xsl:for-each select="t:monogr/t:editor">
                                <xsl:choose>
                                    <xsl:when test="position() = last()">
                                        <xsl:text> und </xsl:text>
                                    </xsl:when>
                                    <xsl:when test="position() != last() and position() != 1">
                                        <xsl:text>, </xsl:text>
                                    </xsl:when>
                                </xsl:choose>
                                <xsl:value-of select="t:forename"/>
                                <xsl:text> </xsl:text>
                                <xsl:value-of select="t:surname"/>
                            </xsl:for-each>
                        </xsl:otherwise>
                    </xsl:choose>

                </xsl:if>
                <xsl:if test="t:monogr/t:imprint/t:pubPlace != ''">
                    <xsl:text>. </xsl:text>
                    <xsl:value-of select="t:monogr/t:imprint/t:pubPlace"/>
                </xsl:if>
                <xsl:if test="t:monogr/t:imprint/t:biblScope[@unit = 'page'] != ''">
                    <xsl:text>, S. </xsl:text>
                    <xsl:value-of select="t:monogr/t:imprint/t:biblScope[@unit = 'page']"/>
                </xsl:if>
                <xsl:if test="t:monogr/t:series != ''">
                    <xsl:text>, </xsl:text>
                    <xsl:value-of select="t:monogr/t:series"/>
                </xsl:if>
                <xsl:text>.</xsl:text>
            </xsl:otherwise>
        </xsl:choose>

        <!-- Verlinkung zum Zotero-Eintrag -->
        <a target="_blank" style="color:orange;">
            <xsl:attribute name="href">
                <xsl:value-of
                    select="concat('https://www.zotero.org/groups/1332658/konde/items/', substring-after(@corresp, 'items/'))"
                />
            </xsl:attribute>
            <xsl:text> </xsl:text>
            <span class="glyphicon glyphicon-new-window">
                <xsl:text> </xsl:text>
            </span>
        </a>

    </xsl:template>

    <xsl:template name="author">
        <xsl:choose>
            <xsl:when test="t:name">
                <xsl:value-of select="t:name"/>
                <xsl:choose>
                    <xsl:when test="position() = last()"/>
                    <xsl:otherwise>
                        <xsl:text>; </xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="t:surname"/>
                <xsl:text>, </xsl:text>
                <xsl:value-of select="translate(t:forename, '.', '')"/>
                <xsl:choose>
                    <xsl:when test="position() = last()"/>
                    <xsl:otherwise>
                        <xsl:text>; </xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <xsl:template name="editor">
        <xsl:choose>
            <xsl:when test="t:name">
                <xsl:value-of select="t:name"/>
                <xsl:text> (Hrsg.). </xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="t:surname"/>
                <xsl:text>, </xsl:text>
                <xsl:value-of select="t:forename"/>
                <xsl:choose>
                    <xsl:when test="position() = last()"> (Hrsg.). </xsl:when>
                    <xsl:otherwise>
                        <xsl:text>; </xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="url">
        <xsl:text>. URL: </xsl:text>
        <a target="_blank">
            <xsl:attribute name="href">
                <xsl:value-of select="t:monogr/t:imprint/t:note[@type = 'url']"/>
            </xsl:attribute>
            <xsl:value-of select="t:monogr/t:imprint/t:note[@type = 'url']"/>
        </a>
    </xsl:template>

    <!-- template create_bibl ENDE -->


    <xsl:template match="t:email">
        <a>
            <xsl:attribute name="href">
                <xsl:text>mailto:</xsl:text>
                <xsl:value-of select="."/>
            </xsl:attribute>
            <xsl:value-of select="."/>
        </a>
    </xsl:template>

    <xsl:template match="t:code">
        <xsl:choose>

            <!-- Codeblocks in den Weißbuchartikeln-->
            <xsl:when test="@ana = 'block'">
                <pre>
                    <code>
                    <xsl:value-of select="."/>
                        </code>
                </pre>
            </xsl:when>

            <!-- Code, der nicht verlinkt ist auf TEI Guidelines -->
            <xsl:when test="@ana = 'no_link'">
                <code class="code">

                    <xsl:value-of select="."/>
                </code>
            </xsl:when>

            <!-- Code, der verlinkt ist auf TEI Guidelines -->
            <xsl:otherwise>
                <code>
                    <a class="code">
                        <xsl:attribute name="href">
                            <xsl:if test="starts-with(., '&lt;')">
                                <xsl:value-of
                                    select="concat('https://www.tei-c.org/release/doc/tei-p5-doc/de/html/ref-', substring-before(substring-after(., '&lt;'), '&gt;'), '.html')"
                                />
                            </xsl:if>
                            <xsl:if test="starts-with(., '@')">
                                <xsl:value-of select="@ana"/>
                            </xsl:if>
                        </xsl:attribute>
                        <xsl:apply-templates/>
                    </a>
                </code>
            </xsl:otherwise>

        </xsl:choose>

    </xsl:template>



    <xsl:template match="t:note">
        <xsl:variable name="footnote">
            <xsl:number count="t:note" level="any"/>
        </xsl:variable>
        <sup>
            <xsl:attribute name="id">
                <xsl:value-of select="concat('T', @xml:id)"/>
            </xsl:attribute>
            <a>
                <xsl:attribute name="href">
                    <xsl:value-of select="concat('#', @xml:id)"/>
                </xsl:attribute>
                <xsl:value-of select="@n"/>
            </a>
        </sup>
    </xsl:template>



    <xsl:template match="t:note" mode="footnote">
        <xsl:variable name="footnote">
            <xsl:number count="t:note" level="any"/>
        </xsl:variable>
        <p style="font-size:9pt">
            <span style="float:left">
                <sup>
                    <xsl:attribute name="id">
                        <xsl:value-of select="@xml:id"/>
                    </xsl:attribute>
                    <a>
                        <xsl:attribute name="href">
                            <xsl:value-of select="concat('#T', @xml:id)"/>
                        </xsl:attribute>
                        <xsl:value-of select="@n"/>
                    </a>
                </sup>
            </span>
            <span style="display:block;padding-left:2em">
                <xsl:value-of select="."/>
            </span>
        </p>
    </xsl:template>



    <xsl:template name="simple_osd_viewer">
        <xsl:param name="pid"/>
        <xsl:param name="showIiifLabels">false</xsl:param>
        <div id="vwr-content">
            <xsl:text> </xsl:text>
        </div>
        <script type="text/javascript" src="/osdviewer/gamsOsd.js"><xsl:text> </xsl:text></script>
        <script type="text/javascript">
            i
            gamsOsd({
                id: "vwr-content",
                prefixUrl: "/osdviewer/images/",
                showNavigator: true,
                sequenceMode: true,
                showReferenceStrip: true,
                showRotationControl: true,
                showIiifLabels:<xsl:value-of select="$showIiifLabels"/>
,
            referenceStripScroll: "horizontal",
            pid: "<xsl:value-of select="$pid"/>
            "
        });</script>
    </xsl:template>


    <xsl:template match="//t:quote">
        <cite>
            <xsl:apply-templates/>
        </cite>
    </xsl:template>


    <xsl:template match="//t:table">
        <table class="table table-responsive text-center">
            <xsl:for-each select="t:row">
                <tr>
                    <xsl:apply-templates/>
                </tr>
            </xsl:for-each>
        </table>
    </xsl:template>


    <xsl:template match="//t:cell">
        <xsl:for-each select=".">
            <td>
                <xsl:apply-templates/>
            </td>
        </xsl:for-each>
    </xsl:template>

</xsl:stylesheet>
