<?xml version="1.0" encoding="UTF-8"?>
<!-- Ursprüngliche Version von Manuel Abbt; Ergänzungen und Anpassungen von Fabian Schwabe und Kevin Körner
     aktuelle Version vom 9. Februar 2015 -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tei="http://www.tei-c.org/ns/1.0"
    exclude-result-prefixes="xs tei" version="2.0">
    <xsl:output method="html" indent="no" encoding="UTF-8"/>

    <xsl:variable name="localdemo" select="'true'"/>
    <xsl:variable name="projektpathonline" select="'/omeka/projekte/euting'"/>


    <xsl:template match="/">
        <html>
            <head/>

            <body>
                <h1>Personen</h1>

                <xsl:for-each select="tei:TEI/tei:text/tei:back/tei:listPerson/tei:person">
                    <!--Link für die aktuelle Person anlegen-->
                    <a href="demo.html?xmlid={@xml:id}">
                        <xsl:value-of select="@xml:id"/>
                    </a>
                    <br/>

                    <!--Umleitung der HTML-Ausgabe in Datei XML:ID.html-->
                    <xsl:result-document href="html/{@xml:id}.html">
                        <xsl:apply-templates select="."/>
                    </xsl:result-document>
                </xsl:for-each>

                <h1>Orte</h1>

                <xsl:for-each select="tei:TEI/tei:text/tei:back/tei:listPlace/tei:place">
                    <!--Link für die aktuelle Person anlegen-->
                    <a href="demo.html?xmlid={@xml:id}">
                        <xsl:value-of select="@xml:id"/>
                    </a>
                    <br/>

                    <!--Umleitung der HTML-Ausgabe in Datei XML:ID.html-->
                    <xsl:result-document href="html/{@xml:id}.html">
                        <xsl:apply-templates select="."/>
                    </xsl:result-document>
                </xsl:for-each>

                <h1>Ereignisse</h1>
                <xsl:for-each select="tei:TEI/tei:text/tei:back/tei:listEvent/tei:event">
                    <!--Link für das aktuelle Ereignis anlegen.-->
                    <a href="demo.html?xmlid={@xml:id}">
                        <xsl:value-of select="@xml:id"/>
                    </a>
                    <br/>

                    <!--Umleitung der HTML-Ausgabe in Datei XML:ID.html-->
                    <xsl:result-document href="html/{@xml:id}.html">
                        <xsl:apply-templates select="."/>
                    </xsl:result-document>
                </xsl:for-each>

                <h1>Anmerkungen</h1>
                <xsl:for-each select="tei:TEI/tei:text/tei:back/tei:list/tei:item">
                    <!--Link für das aktuelle Ereignis anlegen.-->
                    <a href="demo.html?xmlid={@xml:id}">
                        <xsl:value-of select="@xml:id"/>
                    </a>
                    <br/>

                    <!--Umleitung der HTML-Ausgabe in Datei XML:ID.html-->
                    <xsl:result-document href="html/{@xml:id}.html">
                        <xsl:apply-templates select="."/>
                    </xsl:result-document>
                </xsl:for-each>

                <h1>DIVs</h1>

                <!--Gruppierung nach DIV-Type. Nur wichtig für die Datei output.html-->
                <xsl:for-each-group select="tei:TEI/tei:text[1]/tei:body[1]/tei:div" group-by="@type">
                    <!--Überschrift mit dem DIV-Type-->
                    <h2>
                        <xsl:value-of select="current-grouping-key()"/>
                    </h2>

                    <!--Läuft durch alle DIVs dieser Gruppe-->
                    <xsl:for-each select="current-group()">

                        <!--Link für das aktuelle DIV anlegen-->
                        <a href="demo.html?xmlid=div_{@xml:id}">
                            <xsl:value-of select="@xml:id"/>
                        </a>
                        <br/>

                        <!--Umleitung der HTML-Ausgabe in Datei div_XML:ID.html-->
                        <xsl:result-document href="html/div_{@xml:id}.html">
                            <xsl:apply-templates/>
                        </xsl:result-document>

                    </xsl:for-each>
                </xsl:for-each-group>
            </body>
        </html>
    </xsl:template>

    <xsl:template match="tei:note|tei:item">
        <xsl:apply-templates/>
    </xsl:template>

    <!--    <xsl:template match="tei:p">
        <div class="esc-content">
            <xsl:element name="div">
                <xsl:attribute name="class">
                    <xsl:text>esc-1col-text esc-textblock</xsl:text>
                </xsl:attribute>
                <xsl:apply-templates/>
            </xsl:element>
        </div>
    </xsl:template>-->

    <xsl:template match="tei:ab" mode="Text-gegenüber-Text">
        <xsl:element name="div">
            <xsl:attribute name="class">
                <xsl:text>esc-2col-rtext esc-textblock</xsl:text>
            </xsl:attribute>
            <xsl:apply-templates/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="tei:ab">

        <div class="esc-content">
            <xsl:choose>

                <!-- content-element: single image -->
                <xsl:when test="@facs and not(@corresp) and not(child::node())">
                    <xsl:element name="figure">
                        <xsl:attribute name="class">
                            <xsl:text>esc-1col-image</xsl:text>
                        </xsl:attribute>
                        <xsl:call-template name="esc-create-image">
                            <xsl:with-param name="url" select="id(substring-after(@facs,'#'))/parent::node()/tei:graphic[@n='PAGE']/@url"/>
                            <xsl:with-param name="lrx" select="id(substring-after(@facs,'#'))/@lrx"/>
                            <xsl:with-param name="lry" select="id(substring-after(@facs,'#'))/@lry"/>
                            <xsl:with-param name="ulx" select="id(substring-after(@facs,'#'))/@ulx"/>
                            <xsl:with-param name="uly" select="id(substring-after(@facs,'#'))/@uly"/>
                            <xsl:with-param name="graphicoverview" select="id(substring-after(@facs,'#'))/parent::node()/tei:graphic[@n='OVERVIEW']"/>
                            <xsl:with-param name="overviewtext" select="id(substring-after(@facs,'#'))/parent::node()/tei:desc/text()"/>
                        </xsl:call-template>
                    </xsl:element>
                </xsl:when>

                <xsl:when test="@facs and not(@corresp) and child::node()">
                    <!-- content-element: image and text -->
                    <xsl:element name="figure">
                        <xsl:attribute name="class">
                            <xsl:text>esc-2col-image</xsl:text>
                        </xsl:attribute>
                        <xsl:call-template name="esc-create-image">
                            <xsl:with-param name="url" select="id(substring-after(@facs,'#'))/parent::node()/tei:graphic[@n='PAGE']/@url"/>
                            <xsl:with-param name="lrx" select="id(substring-after(@facs,'#'))/@lrx"/>
                            <xsl:with-param name="lry" select="id(substring-after(@facs,'#'))/@lry"/>
                            <xsl:with-param name="ulx" select="id(substring-after(@facs,'#'))/@ulx"/>
                            <xsl:with-param name="uly" select="id(substring-after(@facs,'#'))/@uly"/>
                            <xsl:with-param name="graphicoverview" select="id(substring-after(@facs,'#'))/parent::node()/tei:graphic[@n='OVERVIEW']"/>
                            <xsl:with-param name="overviewtext" select="id(substring-after(@facs,'#'))/parent::node()/tei:desc/text()"/>
                        </xsl:call-template>
                    </xsl:element>
                    <xsl:element name="div">
                        <xsl:attribute name="class">
                            <xsl:text>esc-2col-text esc-textblock</xsl:text>
                        </xsl:attribute>
                        <xsl:apply-templates/>
                    </xsl:element>
                    <xsl:element name="div">
                        <xsl:attribute name="style">
                            <xsl:text>clear: both;</xsl:text>
                        </xsl:attribute>
                    </xsl:element>
                </xsl:when>

                <!-- content-element: text with figure inside -->
                <xsl:when test="not(@facs) and not(@corresp) and not(@xml:id) and child::node() and tei:figure">
                    <xsl:element name="div">
                        <xsl:attribute name="class">
                            <xsl:text>esc-1col-text esc-textblock</xsl:text>
                        </xsl:attribute>

                        <xsl:element name="figure">
                            <xsl:attribute name="style">
                                <xsl:if test="tei:figure/@place = 'left' or not(tei:figure/@place)">
                                    <xsl:text>float:left; margin-right: 1em; margin-bottom: 1em;</xsl:text>
                                </xsl:if>
                                <xsl:if test="tei:figure/@place = 'right'">
                                    <xsl:text>float:right; margin-left: 1em; margin-bottom: 1em;</xsl:text>
                                </xsl:if>
                            </xsl:attribute>

                            <xsl:call-template name="esc-create-image">
                                <xsl:with-param name="url" select="tei:figure/tei:graphic[@n='PAGE']/@url"/>
                                <xsl:with-param name="lrx" select="tei:figure/tei:graphic/@width"/>
                                <xsl:with-param name="lry" select="tei:figure/tei:graphic/@height"/>
                                <xsl:with-param name="ulx" select="0"/>
                                <xsl:with-param name="uly" select="0"/>
                                <xsl:with-param name="graphicoverview" select="tei:figure/tei:graphic[@n='OVERVIEW']"/>
                                <xsl:with-param name="overviewtext" select="tei:figure/tei:graphic/tei:desc/text()"/>
                            </xsl:call-template>

                        </xsl:element>

                        <xsl:apply-templates/>

                        <xsl:element name="div">
                            <xsl:attribute name="style">
                                <xsl:text>clear:both;</xsl:text>
                            </xsl:attribute>
                        </xsl:element>
                    </xsl:element>
                </xsl:when>

                <!-- content-element: only text -->
                <xsl:when test="not(@facs) and not(@corresp) and not(@xml:id) and child::node()">
                    <xsl:element name="div">
                        <xsl:attribute name="class">
                            <xsl:text>esc-1col-text esc-textblock</xsl:text>
                        </xsl:attribute>
                        <xsl:attribute name="style">
                            <xsl:text>text-align: justify</xsl:text>
                        </xsl:attribute>
                        <xsl:apply-templates/>
                    </xsl:element>
                </xsl:when>

                <!-- Text gegenüber Text -->
                <xsl:when test="not(@facs) and @corresp and not(@xml:id) and child::node()">
                    <xsl:variable name="corresp" select="@corresp"/>
                    <xsl:element name="div">
                        <xsl:attribute name="class">
                            <xsl:text>esc-2col-ltext esc-textblock</xsl:text>
                        </xsl:attribute>
                        <xsl:apply-templates/>
                    </xsl:element>
                    <xsl:apply-templates select="following-sibling::node()[@xml:id=substring-after($corresp,'#')]" mode="Text-gegenüber-Text"/>
                    <xsl:element name="div">
                        <xsl:attribute name="style">
                            <xsl:text>clear: both;</xsl:text>
                        </xsl:attribute>
                    </xsl:element>
                </xsl:when>
                <xsl:otherwise/>
            </xsl:choose>
        </div>
    </xsl:template>


    <!-- einfacher Text ohne Tags -->
    <xsl:template match="text()">
        <xsl:value-of select="."/>
    </xsl:template>


    <!--Head Inhalte der <div> werden nicht ausgegeben-->
    <xsl:template match="tei:head">
        <xsl:if test="parent::tei:figure">
            <xsl:apply-templates/>
        </xsl:if>
    </xsl:template>

    <!-- IMAGES   -->
    <xsl:template match="tei:figure">
        <xsl:call-template name="esc-create-image">
            <xsl:with-param name="url" select="id(substring-after(@facs,'#'))/parent::node()/tei:graphic[@n='PAGE']/@url"/>
            <xsl:with-param name="lrx" select="id(substring-after(@facs,'#'))/@lrx"/>
            <xsl:with-param name="lry" select="id(substring-after(@facs,'#'))/@lry"/>
            <xsl:with-param name="ulx" select="id(substring-after(@facs,'#'))/@ulx"/>
            <xsl:with-param name="uly" select="id(substring-after(@facs,'#'))/@uly"/>
            <xsl:with-param name="graphicoverview" select="id(substring-after(@facs,'#'))/parent::node()/tei:graphic[@n='OVERVIEW']"/>
            <xsl:with-param name="overviewtext" select="id(substring-after(@facs,'#'))/parent::node()/tei:desc/text()"/>
        </xsl:call-template>
    </xsl:template>

    <xsl:template match="tei:graphic">
        <xsl:element name="span">
            <xsl:attribute name="style">
                <xsl:text/>
            </xsl:attribute>
            <xsl:choose>
                <xsl:when test="$localdemo = 'true'">
                    <img src="{@url}" style="{@style}"/>
                </xsl:when>
                <xsl:otherwise>
                    <img id="id" src="{$projektpathonline}/{@url}" style="{@style}"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:element>
    </xsl:template>


    <xsl:template match="tei:person">
        <xsl:if test="tei:note/tei:figure/tei:graphic">
            <xsl:element name="figure">
                <xsl:attribute name="style">
                    <xsl:text>float:right;</xsl:text>
                </xsl:attribute>
                <xsl:attribute name="id">
                    <xsl:text>esc-list-image</xsl:text>
                </xsl:attribute>
                <xsl:choose>
                    <xsl:when test="$localdemo = 'true'">
                        <img id="esc-list-image-content" src="{tei:note/tei:figure/tei:graphic/@url}"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <img id="id" src="{$projektpathonline}/{tei:note/tei:figure/tei:graphic/@url}"/>
                    </xsl:otherwise>
                </xsl:choose>
                <xsl:if test="tei:note/tei:figure/tei:head">
                    <figcaption>
                        <i>
                            <xsl:apply-templates select="tei:note/tei:figure/tei:head"/>
                        </i>
                    </figcaption>
                </xsl:if>
            </xsl:element>
        </xsl:if>

        <!-- Personenname -->
        <h1>
            <xsl:value-of select="tei:persName"/>
        </h1>
        <xsl:element name="p">
            <xsl:choose>
                <xsl:when test="@sex='m'">
                    <span class="esc-list-spanspace">♂<xsl:text>&#160;&#160;</xsl:text></span>
                </xsl:when>
                <xsl:when test="@sex='w'">
                    <span class="esc-list-spanspace">♀<xsl:text>&#160;&#160;</xsl:text></span>
                </xsl:when>
            </xsl:choose>

            <xsl:if test="tei:birth">
                <span class="esc-list-spanspace">* <xsl:value-of select="tei:birth/@when"/><xsl:text>&#160;&#160;</xsl:text></span>
            </xsl:if>

            <xsl:if test="tei:death">
                <span class="esc-list-spanspace">✝ <xsl:value-of select="tei:death/@when"/><xsl:text>&#160;&#160;</xsl:text></span>
            </xsl:if>

            <xsl:for-each select="tei:note/tei:ref">
                <span class="esc-list-spanspace">
                    <xsl:apply-templates select="."/>
                </span>
            </xsl:for-each>
        </xsl:element>
        <xsl:apply-templates select="tei:note/tei:ab"/>
    </xsl:template>


    <xsl:template match="tei:place">
        <xsl:if test="tei:note/tei:figure/tei:graphic">
            <xsl:element name="figure">
                <xsl:attribute name="style">
                    <xsl:text>float:right;</xsl:text>
                </xsl:attribute>
                <xsl:attribute name="id">
                    <xsl:text>esc-list-image</xsl:text>
                </xsl:attribute>
                <xsl:choose>
                    <xsl:when test="$localdemo = 'true'">
                        <img id="esc-list-image-content" src="{tei:note/tei:figure/tei:graphic/@url}"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <img id="id" src="{$projektpathonline}/{tei:note/tei:figure/tei:graphic/@url}"/>
                    </xsl:otherwise>
                </xsl:choose>
                <xsl:if test="tei:note/tei:figure/tei:head">
                    <figcaption>
                        <i>
                            <xsl:apply-templates select="tei:note/tei:figure/tei:head"/>
                        </i>
                    </figcaption>
                </xsl:if>
            </xsl:element>
        </xsl:if>
        <!-- Ortsname -->
        <h1>
            <xsl:value-of select="tei:placeName"/>
        </h1>
        <p>
            <xsl:for-each select="tei:note/tei:ref">
                <span class="esc-list-spanspace">
                    <xsl:apply-templates select="."/>
                </span>
            </xsl:for-each>
        </p>
        <xsl:apply-templates select="tei:note/tei:ab"/>
    </xsl:template>


    <xsl:template match="tei:event">
        <xsl:if test="tei:note/tei:figure/tei:graphic">
            <xsl:element name="figure">
                <xsl:attribute name="style">
                    <xsl:text>float:right;</xsl:text>
                </xsl:attribute>
                <xsl:attribute name="id">
                    <xsl:text>esc-list-image</xsl:text>
                </xsl:attribute>
                <xsl:choose>
                    <xsl:when test="$localdemo = 'true'">
                        <img id="esc-list-image-content" src="{tei:note/tei:figure/tei:graphic/@url}"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <img id="id" src="{$projektpathonline}/{tei:note/tei:figure/tei:graphic/@url}"/>
                    </xsl:otherwise>
                </xsl:choose>
                <figcaption>
                    <i>
                        <xsl:apply-templates select="tei:note/tei:figure/tei:head"/>
                    </i>
                </figcaption>
            </xsl:element>
        </xsl:if>

        <!-- Ereignis -->
        <xsl:element name="h1">
            <xsl:value-of select="tei:label"/>
        </xsl:element>
        <xsl:element name="p">
            <xsl:if test="@when">
                <span class="esc-list-spanspace">
                    <xsl:text>&#128197; </xsl:text>
                    <xsl:value-of select="@when"/>
                    <xsl:text> </xsl:text>
                </span>
            </xsl:if>
        </xsl:element>
        <xsl:element name="p">
            <xsl:for-each select="tei:note/tei:ref">
                <span class="esc-list-spanspace">
                    <xsl:apply-templates select="."/>
                </span>
            </xsl:for-each>
        </xsl:element>
        <xsl:apply-templates select="tei:note[@type='addInfo']/tei:p"/>
        <xsl:apply-templates select="tei:note[@type='addInfo']/tei:ab"/>
    </xsl:template>

    <xsl:template match="tei:date">
        <xsl:element name="span">
            <xsl:attribute name="class">esc-text-date</xsl:attribute>
            <xsl:apply-templates/>
        </xsl:element>
    </xsl:template>


    <!-- Verlinkung auf Places, Persons und Events sowie DIVs -->
    <xsl:template match="tei:rs">
        <xsl:choose>
            <xsl:when test="@type='word'">
                <a onclick="javascript:ajax_load_overviewcontent('div_{substring-after(@ref,'#')}');">
                    <xsl:value-of select="."/>
                </a>
            </xsl:when>
            <xsl:otherwise>
                <a onclick="javascript:ajax_load_overviewcontent('{substring-after(@ref,'#')}');">
                    <xsl:value-of select="."/>
                </a>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <!-- Möglichkeit zur internen Menuverlinkung -->
    <xsl:template match="tei:ptr"/>

    <!-- Link auf eine externe oder interne Seite -->
    <xsl:template match="tei:ref">
        <xsl:choose>
            <xsl:when test="@type='external' or not(@type)">
                <a href="{@target}" target="_blank" class="esc-link-extern">
                    <xsl:value-of select="."/>
                </a>
                <xsl:if test="parent::note[@type='addInfo']">
                    <xsl:text>&#160;&#160;</xsl:text>
                </xsl:if>
            </xsl:when>
            <xsl:when test="@type='internal'">
                <a onclick="javascript:esc_load_divxmlid('div_{substring-after(@target,'#')}');">
                    <xsl:value-of select="."/>
                </a>
            </xsl:when>
        </xsl:choose>
    </xsl:template>

    <!-- Literaturangaben -->
    <xsl:template match="tei:bibl">
        <xsl:choose>
            <xsl:when test="@corresp">
                <xsl:element name="span">
                    <xsl:attribute name="class">esc-lit</xsl:attribute>
                    <xsl:attribute name="title">
                        <xsl:for-each select="id(translate(@corresp,'#',''))">
                            <xsl:value-of select="."/>
                        </xsl:for-each>
                    </xsl:attribute>
                    <xsl:apply-templates/>
                </xsl:element>
            </xsl:when>
        </xsl:choose>
    </xsl:template>


    <!-- subst: Klammerelement ohne Bedeutung für die Ausgabe -->
    <xsl:template match="tei:subst">
        <xsl:apply-templates/>
    </xsl:template>


    <!-- del: In der Handschrift getilgter Text -->
    <xsl:template match="tei:del">
        <xsl:element name="span">
            <xsl:attribute name="class">esc-deleted-text</xsl:attribute>
            <xsl:apply-templates/>
        </xsl:element>
    </xsl:template>


    <!-- add: Hinzugefügter Text -->
    <xsl:template match="tei:add">
        <xsl:element name="span">
            <xsl:attribute name="class">
                <xsl:text>esc-added-text</xsl:text>
                <xsl:if test="@hand='later'">
                    <xsl:text xml:space="preserve"> esc-later-added-text</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <xsl:choose>
                <xsl:when test="@place='inline'">
                    <xsl:apply-templates/>
                </xsl:when>
                <xsl:when test="@place='above'">
                    <xsl:text>&#5152;</xsl:text>
                    <xsl:apply-templates/>
                    <xsl:text>&#5151;</xsl:text>
                </xsl:when>
                <xsl:when test="@place='below'">
                    <xsl:text>&#5151;</xsl:text>
                    <xsl:apply-templates/>
                    <xsl:text>&#5152;</xsl:text>
                </xsl:when>
                <xsl:when test="@place='margin'">
                    <span style="font-size:large">
                        <xsl:text>&#0761;</xsl:text>
                    </span>
                    <xsl:apply-templates/>
                    <span style="font-size:large">
                        <xsl:text>&#0762;</xsl:text>
                    </span>
                </xsl:when>
            </xsl:choose>
        </xsl:element>
    </xsl:template>


    <!-- hi: Graphische Hervorhebungen -->
    <xsl:template match="tei:hi">
        <xsl:choose>
            <xsl:when test="@rend='italic'">
                <span style="font-style: italic">
                    <xsl:apply-templates/>
                </span>
            </xsl:when>
            <xsl:when test="@rend='bold'">
                <span style="font-weight: bold;">
                    <xsl:apply-templates/>
                </span>
            </xsl:when>
            <xsl:when test="@rend='underlined'">
                <span style="text-decoration: underline">
                    <xsl:apply-templates/>
                </span>
            </xsl:when>
            <xsl:when test="@rend='superscript'">
                <sup>
                    <xsl:apply-templates/>
                </sup>
            </xsl:when>
            <xsl:when test="@rend='small-caps'">
                <span style="font-variant: small-caps">
                    <xsl:apply-templates/>
                </span>
            </xsl:when>
        </xsl:choose>
    </xsl:template>


    <!-- choice: Mehrfache Kodierung von handschriftlichem Text -->
    <xsl:template match="tei:choice">
        <xsl:if test="tei:orig and tei:reg">
            <span class="esc-text-choice">
                <span class="esc-text-choice-orig">
                    <xsl:apply-templates select="tei:orig"/>
                </span>
                <span class="esc-text-choice-reg esc-text-choice-hidden">
                    <xsl:apply-templates select="tei:reg"/>
                </span>
            </span>
        </xsl:if>
    </xsl:template>

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

    <xsl:template match="tei:am">
        <xsl:value-of select="."/>
    </xsl:template>

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

    <!-- todo: i-tag ins CSS auslagern -->
    <xsl:template match="tei:ex">
        <i>
            <xsl:value-of select="."/>
        </i>
    </xsl:template>

    <xsl:template match="tei:supplied">
        <xsl:text>&lt;</xsl:text>
        <xsl:value-of select="."/>
        <xsl:text>&gt;</xsl:text>
    </xsl:template>

    <!-- Textlücke durch Verlust und Ähnliches -->
    <xsl:template match="tei:gap">
        <xsl:text>†††</xsl:text>
    </xsl:template>


    <xsl:template match="tei:space">
        <xsl:text>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;</xsl:text>
    </xsl:template>

    <!-- unsichere Lesart -->
    <xsl:template match="tei:unclear">
        <xsl:text>[</xsl:text>
        <xsl:value-of select="."/>
        <xsl:text>]</xsl:text>
    </xsl:template>


    <!-- Zeilenwechsel -->
    <xsl:template match="tei:lb">
        <xsl:if test="not(@break) or @break='true'">
            <xsl:element name="br"/>
        </xsl:if>
        <xsl:if test="@n">
            <span class="esc-text-line-nr">
                <xsl:value-of select="@n"/>
            </span>
        </xsl:if>
    </xsl:template>

    <!-- Andere Zählung (z. B. Satz) -->
    <xsl:template match="tei:milestone">
        <xsl:if test="@n">
            <span class="esc-text-line-nr">
                <xsl:value-of select="@n"/>
            </span>
        </xsl:if>
    </xsl:template>

    <!-- Bildunterschrift im Fenster -->
    <xsl:template name="esc-bildunterschrift"/>

    <!-- create linked image -->
    <xsl:template name="esc-create-image">
        <xsl:param name="url" required="yes"/>
        <xsl:param name="lrx" required="yes"/>
        <xsl:param name="lry" required="yes"/>
        <xsl:param name="ulx" required="yes"/>
        <xsl:param name="uly" required="yes"/>
        <xsl:param name="graphicoverview"/>
        <xsl:param name="overviewtext" select="''"/>


        <xsl:element name="div">
            <xsl:attribute name="class">
                <xsl:text>esc-image</xsl:text>
            </xsl:attribute>
            <xsl:attribute name="style">
                <xsl:text>width: </xsl:text>
                <xsl:value-of select="$lrx"/>
                <xsl:text>px; </xsl:text>

                <xsl:text>height: </xsl:text>
                <xsl:value-of select="$lry"/>
                <xsl:text>px; </xsl:text>

                <xsl:text>background-image:url(</xsl:text>
                <xsl:if test="$localdemo != 'true'">
                    <xsl:value-of select="$projektpathonline"/>
                    <xsl:text>/</xsl:text>
                </xsl:if>
                <xsl:value-of select="$url"/>
                <xsl:text>); </xsl:text>

                <xsl:text>background-position: </xsl:text>
                <xsl:value-of select="$ulx"/>
                <xsl:text>px </xsl:text>
                <xsl:value-of select="$uly"/>
                <xsl:text>px; </xsl:text>
            </xsl:attribute>

            <xsl:if test="$graphicoverview">
                <xsl:attribute name="onclick">
                    <xsl:text>javascript:$.fancybox( [</xsl:text>

                    <xsl:for-each select="$graphicoverview">
                        <xsl:text>{href : '</xsl:text>
                        <xsl:if test="$localdemo != 'true'">
                            <xsl:value-of select="$projektpathonline"/>
                            <xsl:text>/</xsl:text>
                        </xsl:if>
                        <xsl:value-of select="@url"/>
                        <xsl:text>', title : '</xsl:text>
                        <xsl:choose>
                            <xsl:when test="tei:desc/text()">
                                <xsl:value-of select="tei:desc/text()"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$overviewtext"/>
                            </xsl:otherwise>
                        </xsl:choose>

                        <xsl:text>'}, </xsl:text>
                    </xsl:for-each>

                    <xsl:text> ] );</xsl:text>
                </xsl:attribute>
            </xsl:if>
        </xsl:element>
    </xsl:template>

</xsl:stylesheet>
