Skip to content
Permalink
a1a5d41976
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
658 lines (611 sloc) 23.2 KB
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:eoa="http://www.edition-open-access.de/ns"
exclude-result-prefixes="xs tei eoa"
version="2.0"
>
<xsl:output
method="html"
encoding="UTF-8"
indent="yes"
/>
<xsl:key name="theoremdecls" match="tei:ab[@type = 'theoremdeclaration']" use="@xml:id"/>
<xsl:key name="theorems" match="tei:p[@corresp]" use="eoa:normalize_reference(@corresp)"/>
<xsl:param name="platform_uri" select="'/'"/>
<xsl:variable name="series" select="lower-case(/tei:TEI/tei:teiHeader/tei:fileDesc/tei:seriesStmt/tei:title)"/>
<xsl:variable name="publication_number" select="/tei:TEI/tei:teiHeader/tei:fileDesc/tei:seriesStmt/tei:idno[@type = 'number']"/>
<!-- if the current element is a "paragraph level element", return its id in the document. Otherwise return the empty sequence -->
<xsl:template name="container_id" as="xs:string?">
<xsl:choose>
<xsl:when test="
(
self::tei:div[@type = ('section', 'subsection', 'subsubsection')]
| self::tei:p
| self::tei:epigraph
| self::tei:ab
| self::tei:lg
| self::tei:quote
| self::tei:list
| self::tei:table
| self::tei:figure
| self::tei:div[@type = 'letter']
)[
parent::tei:div[@type = ('chapter', 'section', 'subsection', 'subsubsection')]
or parent::tei:div/parent::tei:div[@type = 'bilingual']
or parent::tei:div/parent::tei:div[@type = 'sidebyside']
]"
>
<xsl:number
count="
(
tei:div[@type = ('section', 'subsection', 'subsubsection')]
| tei:p
| tei:epigraph
| tei:ab
| tei:lg
| tei:quote
| tei:list
| tei:table
| tei:figure
| tei:div[@type = 'letter']
)[
parent::tei:div[@type = ('chapter', 'section', 'subsection', 'subsubsection')]
or parent::tei:div/parent::tei:div[@type = 'bilingual']
or parent::tei:div/parent::tei:div[@type = 'sidebyside']
]"
from="tei:div[@type = 'chapter']"
level="any"
/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- default rule: warning -->
<xsl:template mode="chapter_main" match="tei:*" priority="-100">
<xsl:sequence select="eoa:warning(concat('in mode ', $apos, 'chapter_main', $apos, ': no template for tei:', name(), '[@type=', $apos, @type, $apos, ']'))"/>
<!--
<xsl:apply-templates/>
-->
</xsl:template>
<xsl:template mode="chapter_main" match="tei:div[@type='chapter']">
<xsl:variable name="uri"><xsl:call-template name="calc_uri"/></xsl:variable>
<div class="accordion">
<div class="accordion__main">
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" as="xs:string" select="$uri/eoa:uri"/>
<xsl:with-param name="content" as="element()*">
<!-- print chapter heading -->
<h1 class="publication-detail__title">
<xsl:if test="@n != 'nonumber'">
<xsl:value-of select="@n"/>
</xsl:if>
<xsl:text> </xsl:text>
<xsl:apply-templates mode="text_structure" select="./tei:head"/>
</h1>
<!-- print chapter authors, if any -->
<xsl:if test="@resp">
<p>
<xsl:variable name="people" select="@resp"/>
<xsl:call-template name="format_string_authors">
<xsl:with-param name="authors" select="$people"/>
</xsl:call-template>
</p>
</xsl:if>
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates mode="chapter_main_paragraphs" select="(if (tei:div[@type = 'section']) then (tei:div[@type = 'section'][1]/preceding-sibling::*) else (*))[not(self::tei:head)]"/>
</div>
<a class="accordion__showall show" href="#">Close All</a>
<!-- render chapter text -->
<xsl:apply-templates mode="text_structure" select="(if (tei:div[@type = 'section']) then (tei:div[@type = 'section'][1]/(. | following-sibling::*)) else (*))[not(self::tei:head)]"/>
<xsl:call-template name="footnotes"/>
</div>
</xsl:template>
<xsl:template mode="chapter_navigation" match="tei:div[@type='chapter']">
<xsl:variable name="chapter_nr" select="count(preceding-sibling::*)"/>
<div class="navigation">
<xsl:if test="$chapter_nr > 1">
<a class="navigation__button navigation__button--prev" href="{concat('../', $chapter_nr - 1, '/index.html')}">Back</a>
</xsl:if>
<xsl:if test="following-sibling::*">
<a class="navigation__button navigation__button--next" href="{concat('../', $chapter_nr + 1, '/index.html')}">Back</a>
</xsl:if>
</div>
</xsl:template>
<!-- default rule: warning -->
<xsl:template mode="chapter_main_paragraphs" match="tei:*" priority="-100">
<xsl:sequence select="eoa:warning(concat('in mode ', $apos, 'chapter_main_paragraphs', $apos, ': no template for tei:', name(), '[@type=', $apos, @type, $apos, ']'))"/>
</xsl:template>
<xsl:template mode="chapter_main_paragraphs" match="tei:p" as="element(div)">
<xsl:call-template name="render_paragraph">
<xsl:with-param name="css_classes" select="'publication-detail__main-paragraph'"/>
</xsl:call-template>
</xsl:template>
<xsl:template mode="chapter_main_paragraphs" match="tei:epigraph">
<xsl:variable name="uri"><xsl:call-template name="calc_uri"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('epigraph', $uri/eoa:id))"/>
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" select="$uri/eoa:uri"/>
<xsl:with-param name="content" as="element()*">
<xsl:for-each select="tei:p">
<p id="{$uri/eoa:id}" class="epigraph">
<em>
<xsl:apply-templates mode="html"/>
</em>
</p>
</xsl:for-each>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="chapter_main_paragraphs" match="tei:ab[@type = 'chapterabstract']">
<xsl:variable name="uri"><xsl:call-template name="calc_uri"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('chapterabstract', $uri/eoa:id))"/>
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" select="$uri/eoa:uri"/>
<xsl:with-param name="content" as="element()*">
<p id="{$uri/eoa:id}" class="abstract">
<xsl:apply-templates mode="html"/>
</p>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<!-- section hierarchy -->
<!-- default rule: warning -->
<xsl:template mode="text_structure" match="tei:*" priority="-100">
<xsl:sequence select="eoa:warning(concat('in mode ', $apos, 'text_structure', $apos, ': no template for tei:', name(), '[@type=', $apos, @type, $apos, ']'))"/>
</xsl:template>
<xsl:template mode="text_structure" match="tei:div[@type='section']">
<xsl:variable name="uri"><xsl:call-template name="calc_uri"/></xsl:variable>
<xsl:sequence select="eoa:info('section')"/>
<div class="accordion__item active">
<a class="accordion__title" href="#">
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" as="xs:string" select="$uri/eoa:uri"/>
<xsl:with-param name="content" as="element()*">
<h2>
<xsl:if test="../@n != 'nonumber'">
<xsl:value-of select="concat(../@n, '.', @n, ' ')"/>
</xsl:if>
<xsl:apply-templates mode="text_structure" select="tei:head"/>
</h2>
</xsl:with-param>
</xsl:call-template>
</a>
<div class="accordion__content">
<xsl:apply-templates mode="text_structure" select="*[not(self::tei:head)]"/>
<a class="accordion__pageup" href="#"></a>
</div>
</div>
</xsl:template>
<xsl:template mode="text_structure" match="tei:div[@type='subsection']">
<xsl:variable name="uri"><xsl:call-template name="calc_uri"/></xsl:variable>
<xsl:sequence select="eoa:info('subsection')"/>
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" as="xs:string" select="$uri/eoa:uri"/>
<xsl:with-param name="content" as="element()*">
<h4>
<xsl:if test="../../@n != 'nonumber'">
<xsl:value-of select="concat(../../@n, '.', ../@n, '.', @n, ' ')"/>
</xsl:if>
<xsl:apply-templates mode="text_structure" select="tei:head"/>
</h4>
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates mode="text_structure" select="*[not(self::tei:head)]"/>
</xsl:template>
<xsl:template mode="text_structure" match="tei:div[@type='subsubsection']">
<xsl:variable name="uri"><xsl:call-template name="calc_uri"/></xsl:variable>
<xsl:sequence select="eoa:info('subsubsection')"/>
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" as="xs:string" select="$uri/eoa:uri"/>
<xsl:with-param name="content" as="element()*">
<h4>
<xsl:apply-templates mode="text_structure" select="./tei:head"/>
</h4>
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates mode="text_structure" select="*[not(self::tei:head)]"/>
</xsl:template>
<xsl:template mode="text_structure" match="tei:div[@type='letter']">
<xsl:sequence select="eoa:info('letter')"/>
<xsl:variable name="uri"><xsl:call-template name="calc_uri"/></xsl:variable>
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" as="xs:string" select="$uri/eoa:uri"/>
<xsl:with-param name="content" as="element()*">
<xsl:if test="tei:head">
<h4>
<xsl:apply-templates mode="text_structure" select="tei:head"/>
</h4>
</xsl:if>
<p class="verse">
<xsl:for-each select="tei:p">
<xsl:apply-templates mode="html" select="node()"/>
<xsl:if test="position() != last()">
<br/>
</xsl:if>
</xsl:for-each>
</p>
<!--
<xsl:apply-templates mode="text_structure" select="*[not(self::tei:head)]"/>
-->
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<!-- paragraph level elements: -->
<xsl:template mode="text_structure" match="tei:body//tei:head">
<xsl:choose>
<xsl:when test="tei:choice/tei:expan">
<xsl:apply-templates mode="html" select="tei:choice/tei:expan/node() | tei:choice/tei:expan/text()"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates mode="html"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template mode="text_structure" match="tei:body//tei:p">
<xsl:call-template name="render_paragraph"/>
</xsl:template>
<xsl:template mode="text_structure" match="tei:ab[@type='equation']">
<xsl:sequence select="eoa:info('block formula')"/>
<xsl:variable name="uri"><xsl:call-template name="calc_uri"/></xsl:variable>
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" as="xs:string" select="$uri/eoa:uri"/>
<xsl:with-param name="content" as="element()*">
<p>
<xsl:value-of select="concat('$', ., '$')"/>
</p>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="text_structure" match="tei:ab[@type='subequations']">
<xsl:sequence select="eoa:info('equation array')"/>
<xsl:variable name="uri"><xsl:call-template name="calc_uri"/></xsl:variable>
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" as="xs:string" select="$uri/eoa:uri"/>
<xsl:with-param name="content" as="element()*">
<table>
<xsl:for-each select="tei:formula">
<tr id="{$uri/eoa:id}">
<td>
<xsl:value-of select="concat('$', ., '$')"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="text_structure" match="tei:ab[@type='equationarray']">
<xsl:sequence select="eoa:info('equation array')"/>
<xsl:variable name="uri"><xsl:call-template name="calc_uri"/></xsl:variable>
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" as="xs:string" select="$uri/eoa:uri"/>
<xsl:with-param name="content" as="element()*">
<table>
<xsl:for-each select="tei:formula">
<tr id="{$uri/eoa:id}">
<td>
<xsl:value-of select="concat('$', ., '$')"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<!-- the theorem DECLARATION is not supposed to appear in the text: -->
<xsl:template mode="text_structure" match="tei:ab[@type='theoremdeclaration']"/>
<xsl:template mode="text_structure" match="tei:lg[@type='verse']">
<!-- TODO: find a way to indent the poem -->
<xsl:sequence select="eoa:info('verse')"/>
<xsl:variable name="uri"><xsl:call-template name="calc_uri"/></xsl:variable>
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" as="xs:string" select="$uri/eoa:uri"/>
<xsl:with-param name="content" as="element()*">
<p id="{$uri/eoa:id}">
<xsl:for-each select="tei:l">
<xsl:apply-templates mode="html"/>
<xsl:if test="position() != last()">
<br/>
</xsl:if>
</xsl:for-each>
</p>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="text_structure" match="tei:quote">
<!-- TODO: find a way to indent the quote -->
<xsl:sequence select="eoa:info('quote')"/>
<xsl:variable name="uri"><xsl:call-template name="calc_uri"/></xsl:variable>
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" as="xs:string" select="$uri/eoa:uri"/>
<xsl:with-param name="content" as="element()*">
<p id="{$uri/eoa:id}">
<xsl:apply-templates mode="html"/>
</p>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="text_structure" match="tei:list[@type='ordered' or @type='unordered' or @type='gloss']">
<xsl:sequence select="eoa:info('list')"/>
<xsl:variable name="uri"><xsl:call-template name="calc_uri"/></xsl:variable>
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" as="xs:string" select="$uri/eoa:uri"/>
<xsl:with-param name="content" as="element()*">
<xsl:variable name="element_name">
<xsl:choose>
<xsl:when test="@type = 'ordered'">ol</xsl:when>
<xsl:when test="@type = 'unordered'">ul</xsl:when>
<xsl:when test="@type = 'gloss'">ul</xsl:when>
<xsl:otherwise>
<xsl:sequence select="eoa:error('unknown list type!')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="{$element_name}">
<xsl:attribute name="id" select="$uri/eoa:id"/>
<xsl:for-each select="tei:item">
<li>
<xsl:if test="preceding-sibling::tei:label[1]">
<xsl:apply-templates select="preceding-sibling::tei:label[1]"/>
<xsl:text>: </xsl:text>
</xsl:if>
<xsl:apply-templates mode="html"/>
</li>
</xsl:for-each>
</xsl:element>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="text_structure" match="tei:table">
<xsl:sequence select="eoa:info('table')"/>
<xsl:variable name="uri"><xsl:call-template name="calc_uri"/></xsl:variable>
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" as="xs:string" select="$uri/eoa:uri"/>
<xsl:with-param name="content" as="element()*">
<figure id="{$uri/eoa:id}">
<xsl:element name="table">
<xsl:for-each select="tei:row">
<tr>
<xsl:for-each select="tei:cell">
<xsl:element name="{if( @role = 'label') then 'th' else 'td'}">
<xsl:apply-templates mode="html"/>
</xsl:element>
</xsl:for-each>
</tr>
</xsl:for-each>
</xsl:element>
<xsl:if test="tei:head">
<figcaption>
<xsl:apply-templates mode="html" select="tei:head/node() | text()"/>
</figcaption>
</xsl:if>
</figure>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="text_structure" match="tei:figure">
<!-- TODO: check/fix path -->
<xsl:sequence select="eoa:info('figure')"/>
<xsl:variable name="uri"><xsl:call-template name="calc_uri"/></xsl:variable>
<xsl:variable name="img_url" select="eoa:conc_path3('../../..', $publ_static_url,tei:graphic/@url)"/>
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" as="xs:string" select="$uri/eoa:uri"/>
<xsl:with-param name="content" as="element()*">
<xsl:variable name="caption">
<xsl:apply-templates mode="html" select="tei:head/node() | text()"/>
</xsl:variable>
<figure class="publication__image" id="{$uri/eoa:id}">
<a href="{$img_url}" data-lightbox="" title="{$caption}">
<img src="{$img_url}">image could not</img>
</a>
<xsl:if test="tei:head">
<figcaption>
<xsl:value-of select="$caption"/>
</figcaption>
</xsl:if>
</figure>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<!--
<xsl:template match="tei:formula">
<xsl:sequence select="eoa:info('formula')"/>
<xsl:choose>
<xsl:when test="@rend='inline'">
<xsl:message>inline</xsl:message>
<xsl:value-of select="concat('$', ., '$')"/>
</xsl:when>
<xsl:when test="../tei:ab[@type='equation']">
<xsl:message>
jo
<xsl:value-of select="."/>
</xsl:message>
<p>
<xsl:value-of select="."/>
</p>
</xsl:when>
<xsl:otherwise>
<xsl:message>nothing</xsl:message>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
-->
<!-- text inline elements: -->
<!-- mode="html": convert inline elements to html -->
<!-- default rule: warning -->
<xsl:template mode="html" match="tei:*" priority="-100">
<xsl:value-of select="eoa:warning(concat('in mode ', $apos, 'html', $apos, ': no template for tei:', name(), '[@type=', $apos, @type, $apos, ']'))"/>
<!--
<xsl:apply-templates/>
-->
</xsl:template>
<xsl:template mode="html" match="tei:hi">
<xsl:sequence select="eoa:info('markup')"/>
<xsl:choose>
<xsl:when test="@rend='italic'">
<em>
<xsl:apply-templates/>
</em>
</xsl:when>
<xsl:when test="@rend='bold'">
<b>
<xsl:apply-templates/>
</b>
</xsl:when>
<xsl:when test="@rend='superscript'">
<sup>
<xsl:apply-templates/>
</sup>
</xsl:when>
<xsl:when test="@rend='subscript'">
<sub>
<xsl:apply-templates/>
</sub>
</xsl:when>
<xsl:when test="@rend='smallcaps'">
<sc>
<xsl:apply-templates/>
</sc>
</xsl:when>
<xsl:when test="@rend='math'">
<i>
<xsl:apply-templates/>
</i>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template mode="html" match="tei:lb">
<br/>
</xsl:template>
<xsl:template mode="html" match="tei:body//tei:foreign">
<span lang="{@xml:lang}">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template mode="html" match="tei:formula[@rend='inline']">
<xsl:sequence select="eoa:info('inline formula')"/>
<xsl:value-of select="concat('$', ., '$')"/>
</xsl:template>
<xsl:template mode="html" match="tei:graphic">
<xsl:sequence select="eoa:info('inline graphic')"/>
<xsl:variable name="full_url" select="eoa:conc_path3('../../..', $publ_static_url, @url)"/>
<img class="eoainlineimage" src="{$full_url}" alt="(missing pic)"/>
</xsl:template>
<xsl:template mode="html" match="tei:note[@place = 'bottom']">
<xsl:variable name="footnote_id" as="xs:string?">
<xsl:call-template name="footnote_id"/>
</xsl:variable>
<a href="{concat('#', $footnote_id)}">
<sup>
<xsl:value-of select="@n"/>
</sup>
</a>
</xsl:template>
<xsl:template mode="html" match="tei:bibl">
<xsl:sequence select="eoa:warning('bibliographic reference dummy implementation')"/>
(reference to bibl.)
</xsl:template>
<xsl:template mode="html" match="tei:ref">
<xsl:sequence select="eoa:warning('internal reference dummy implementation')"/>
(internal reference)
</xsl:template>
<!-- index elements should not be printed in the text. They are invisible markers from which to generate the index-->
<xsl:template mode="html" match="tei:index"/>
<xsl:template name="accordion_row">
<xsl:param name="link" as="xs:string?"/>
<xsl:param name="content" as="element()*"/>
<div class="row">
<xsl:variable name="flags" as="element()*">
<xsl:variable name="data_content" as="xs:string"
select="concat('If you want to directly link to this paragraphin the text, you can use the following URL:&lt;br/&gt; &lt;a href=', $apos, $link, $apos, '&gt; ', $link,'&lt;/a&gt;')"
/>
<xsl:if test="$link">
<button class="icon-bookmark publications-popup" data-content="{$data_content}" title="" rel="popover" data-title="Permanent Link"></button>
</xsl:if>
<!-- TODO: eye -->
</xsl:variable>
<xsl:if test="$flags">
<div class="flags">
<xsl:copy-of select="$flags"/>
</div>
</xsl:if>
<xsl:copy-of select="$content"/>
</div>
</xsl:template>
<xsl:template name="render_paragraph" as="element(div)">
<xsl:param name="css_classes" as="xs:string" select="''"/>
<xsl:variable name="uri"><xsl:call-template name="calc_uri"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('chapter paragraph', $uri/eoa:id))"/>
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" select="$uri/eoa:uri"/>
<xsl:with-param name="content" as="element()*">
<p id="{$uri/eoa:id}" class="{$css_classes}">
<xsl:if test="@corresp">
<xsl:variable name="id" as="xs:string" select="eoa:normalize_reference(@corresp)"/>
<xsl:variable name="theorem" select="key('theoremdecls', $id)"/>
<xsl:variable name="theorem_group" select="key('theorems', $id)"/>
<xsl:variable name="theorem_nr" select="index-of($theorem_group/generate-id(), generate-id(.))"/>
<xsl:sequence select="eoa:info(concat(' (theorem nr', $theorem_nr, ')'))"/>
<b>
<xsl:value-of select="concat( $theorem/text(), ' ', $theorem_nr, ': ')"/>
</b>
</xsl:if>
<xsl:apply-templates mode="html"/>
</p>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="calc_uri" as="element()*">
<xsl:variable name="chapter" select="ancestor-or-self::tei:div[@type = 'chapter']"/>
<xsl:variable name="chapter_nr" select="count($chapter/preceding-sibling::*)"/>
<xsl:variable name="container_id" as="xs:string"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:variable name="local_uri" select="concat($series, '/', $publication_number, '/', $chapter_nr , '/index.html')"/>
<xsl:variable name="global_uri" select="eoa:conc_path($platform_uri, $local_uri)"/>
<eoa:id>
<xsl:value-of select="$container_id"/>
</eoa:id>
<eoa:uri>
<xsl:choose>
<xsl:when test="self::tei:div[@type ='chapter']">
<xsl:value-of select="$global_uri"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($global_uri, '#', $container_id)"/>
</xsl:otherwise>
</xsl:choose>
</eoa:uri>
</xsl:template>
<!-- if the current element is a "paragraph level element", return its id in the document. Otherwise return the empty sequence -->
<xsl:template name="footnote_id" as="xs:string?">
<xsl:choose>
<xsl:when test="self::tei:note">
<value-of>
<xsl:text>fn</xsl:text>
<xsl:number
count="tei:note"
from="tei:div[@type = 'chapter']"
level="any"
/>
</value-of>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:function name="eoa:normalize_reference">
<xsl:param name="reference"/>
<xsl:analyze-string select="$reference" regex="#{{0,1}}(.+)">
<xsl:matching-substring>
<xsl:value-of select="regex-group(1)"/>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:function>
</xsl:stylesheet>