Skip to content
Permalink
e8c2f28546
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
446 lines (414 sloc) 16.6 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"
/>
<!-- container hierarchy -->
<!-- default rule: warning -->
<xsl:template mode="container" match="tei:*" priority="-100">
<xsl:sequence select="eoa:warning(concat('in mode ', $apos, 'container', $apos, ': no template for tei:', name(), '[@type=', $apos, @type, $apos, ']'))"/>
</xsl:template>
<xsl:template mode="container" match="tei:div[@type='section']">
<xsl:param name="indices" as="element(eoa:index)*" tunnel="yes"/>
<xsl:variable name="chapter_id"><xsl:call-template name="chapter_id"/></xsl:variable>
<xsl:variable name="uri"><xsl:call-template name="full_uri_from_chapter"/></xsl:variable>
<xsl:variable name="id" as="xs:string"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('section', $id))"/>
<xsl:variable name="index_elems" as="element(eoa:term)*"
select="$indices//eoa:term[eoa:entry/eoa:link[eoa:entry[3] = $chapter_id and eoa:entry[4] = $id]]"
/>
<div class="accordion__item active" id="{$id}">
<a class="accordion__title" href="#">
<xsl:call-template name="accordion_row">
<xsl:with-param name="url_icon_content" as="xs:string" select="$uri"/>
<xsl:with-param name="eye_icon_content">
<xsl:call-template name="render_eye_content">
<xsl:with-param name="current_id" as="xs:string" select="$id"/>
<xsl:with-param name="index_elems" as="element(eoa:term)*" select="$index_elems"/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="content" as="element()*">
<h2>
<xsl:call-template name="render_section_heading_numbered"/>
</h2>
</xsl:with-param>
</xsl:call-template>
</a>
<div class="accordion__content">
<xsl:apply-templates mode="container" select="*[not(self::tei:head)]"/>
<a class="accordion__pageup" href="#"></a>
</div>
</div>
</xsl:template>
<!--
<xsl:template mode="container" match="tei:milestone[@type='chapterdivider']">
<xsl:param name="indices" as="element(eoa:index)*" tunnel="yes"/>
<xsl:variable name="chapter_id"><xsl:call-template name="chapter_id"/></xsl:variable>
<xsl:variable name="uri"><xsl:call-template name="full_uri_from_chapter"/></xsl:variable>
<xsl:variable name="id" as="xs:string"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('section', $id))"/>
<xsl:variable name="index_elems" as="element(eoa:term)*"
select="$indices//eoa:term[eoa:entry/eoa:link[eoa:entry[3] = $chapter_id and eoa:entry[4] = $id]]"
/>
<div class="accordion__item active" id="{$id}">
<a class="accordion__title" href="#">
<xsl:call-template name="accordion_row">
<xsl:with-param name="url_icon_content" as="xs:string" select="$uri"/>
<xsl:with-param name="eye_icon_content">
<xsl:call-template name="render_eye_content">
<xsl:with-param name="current_id" as="xs:string" select="$id"/>
<xsl:with-param name="index_elems" as="element(eoa:term)*" select="$index_elems"/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="content" as="element()*">
<h2 style="text-align: center;">* * *</h2>
</xsl:with-param>
</xsl:call-template>
</a>
<div class="accordion__content">
<xsl:apply-templates mode="container" select="*[not(self::tei:head)]"/>
<a class="accordion__pageup" href="#"></a>
</div>
</div>
</xsl:template>
-->
<xsl:template mode="container" match="tei:div[@type='subsection']">
<xsl:variable name="id"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('subsection', $id))"/>
<xsl:call-template name="render_paragraph_container">
<xsl:with-param name="content" as="element()*">
<h4>
<xsl:call-template name="render_section_heading_numbered"/>
</h4>
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates mode="container" select="*[not(self::tei:head)]"/>
</xsl:template>
<xsl:template mode="container" match="tei:div[@type='subsubsection']">
<xsl:variable name="id"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('subsubsection', $id))"/>
<xsl:call-template name="render_paragraph_container">
<xsl:with-param name="content" as="element()*">
<h4>
<xsl:for-each select="tei:head">
<xsl:call-template name="render_heading"/>
</xsl:for-each>
</h4>
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates mode="container" select="*[not(self::tei:head)]"/>
</xsl:template>
<xsl:template mode="container" match="tei:div[@type='letter']">
<xsl:variable name="id"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('letter', $id))"/>
<xsl:call-template name="render_paragraph_container">
<xsl:with-param name="content" as="element()*">
<xsl:if test="tei:head">
<h4>
<xsl:for-each select="tei:head">
<xsl:call-template name="render_heading"/>
</xsl:for-each>
</h4>
</xsl:if>
<p class="verse">
<xsl:for-each select="tei:p">
<xsl:apply-templates mode="inline" select="node()"/>
<xsl:if test="position() != last()">
<br/>
</xsl:if>
</xsl:for-each>
</p>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="container" match="tei:div[@type='bilingual']">
<xsl:variable name="id"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('bilingual', $id))"/>
<xsl:call-template name="render_paragraph_container">
<xsl:with-param name="content" as="element()*">
<table width="100%">
<xsl:if test="tei:div[@type = ('original', 'translation')]/tei:head">
<tr>
<th width="50%">
<xsl:apply-templates mode="inline" select="tei:div[@type = 'original']/tei:head/node()"></xsl:apply-templates>
</th>
<th width="50%">
<xsl:apply-templates mode="inline" select="tei:div[@type = 'translation']/tei:head/node()"></xsl:apply-templates>
</th>
</tr>
</xsl:if>
<tr>
<td width="50%"><xsl:apply-templates mode="container" select="tei:div[@type = 'original']/*[not(self::tei:head)]">
<xsl:with-param name="url_icon" as="xs:boolean" select="false()" tunnel="yes"/>
</xsl:apply-templates></td>
<td><xsl:apply-templates mode="container" select="tei:div[@type = 'translation']/*[not(self::tei:head)]">
<xsl:with-param name="url_icon" as="xs:boolean" select="false()" tunnel="yes"/>
</xsl:apply-templates></td>
</tr>
</table>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="container" match="tei:div[@type='sidebyside']">
<xsl:variable name="id"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('sidebyside', $id))"/>
<xsl:call-template name="render_paragraph_container">
<xsl:with-param name="content" as="element()*">
<table width="100%">
<tr>
<xsl:apply-templates mode="sidebyside_headings" select="*"/>
</tr>
<tr>
<xsl:apply-templates mode="sidebyside" select="*"/>
</tr>
</table>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<!-- default rule: warning -->
<xsl:template mode="sidebyside_headings" match="tei:*" priority="-100">
<xsl:sequence select="eoa:warning(concat('in mode ', $apos, 'sidebyside_headings', $apos, ': no template for tei:', name(), '[@type=', $apos, @type, $apos, ']'))"/>
</xsl:template>
<xsl:template mode="sidebyside_headings" match="tei:pb[@facs]">
<xsl:variable name="img_ref" as="xs:string" select="substring-after(@facs, '#')"/>
<td width="50%">
<xsl:apply-templates mode="inline" select="//tei:facsimile/tei:surface[@xml:id = $img_ref]/tei:label/node()"/>
</td>
</xsl:template>
<xsl:template mode="sidebyside_headings" match="tei:div">
<td width="50%">
<xsl:apply-templates mode="inline" select="tei:label/node()"/>
</td>
</xsl:template>
<!-- default rule: warning -->
<xsl:template mode="sidebyside" match="tei:*" priority="-100">
<xsl:sequence select="eoa:warning(concat('in mode ', $apos, 'sidebyside', $apos, ': no template for tei:', name(), '[@type=', $apos, @type, $apos, ']'))"/>
</xsl:template>
<xsl:template mode="sidebyside" match="tei:pb[@facs]">
<xsl:variable name="img_ref" as="xs:string" select="substring-after(@facs, '#')"/>
<xsl:variable name="img_url" as="xs:string" select="
eoa:conc_path3(
'../../..',
$publ_static_url,
//tei:facsimile/tei:surface[@xml:id = $img_ref]/tei:graphic/@url
)
"/>
<xsl:variable name="img_label" select="//tei:facsimile/tei:surface[@corresp = $img_ref]/tei:label"/>
<xsl:sequence select="eoa:debug(concat('tei:pb: ', $img_url))"/>
<td width="50%">
<a href="{$img_url}" title="{$img_label}" width="100%">
<img src="{$img_url}" width="100%"></img>
</a>
</td>
</xsl:template>
<xsl:template mode="sidebyside" match="tei:div">
<td>
<xsl:apply-templates mode="container" select="*[not(self::tei:label)]">
<xsl:with-param name="url_icon" as="xs:boolean" select="false()" tunnel="yes"/>
</xsl:apply-templates>
</td>
</xsl:template>
<!-- paragraph level elements: -->
<xsl:template mode="container" match="tei:p">
<xsl:variable name="id"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('paragraph', $id))"/>
<xsl:call-template name="render_paragraph_container">
<xsl:with-param name="content">
<p>
<xsl:apply-templates mode="inline"/>
</p>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="container" match="tei:milestone[@type='chapterdivider']">
<xsl:variable name="id"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('chapterdivider', $id))"/>
<xsl:call-template name="render_paragraph_container">
<xsl:with-param name="content">
<h2 style="text-align: center;">*</h2>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="container" match="tei:ab[@type=('equation', 'subequations', 'equationarray')]">
<xsl:variable name="id"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:choose>
<xsl:when test="@type = 'equation'">
<xsl:sequence select="eoa:info(concat('equation', $id))"/>
</xsl:when>
<xsl:when test="@type = 'subequations'">
<xsl:sequence select="eoa:info(concat('subequation', $id))"/>
</xsl:when>
</xsl:choose>
<xsl:call-template name="render_paragraph_container">
<xsl:with-param name="content" as="element()*">
<table class="publication__equation__table">
<tbody>
<xsl:choose>
<xsl:when test="@type = ('equation', 'subequations', 'equationarray')">
<xsl:for-each select="tei:formula">
<xsl:call-template name="render_equation_row"/>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</tbody>
</table>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="render_equation_row">
<tr class="publication__equation__row">
<td class="publication__equation__cell">
<xsl:value-of select="concat('$', ., '$')"/>
</td>
<xsl:variable name="equation_nr" as="xs:string">
<xsl:apply-templates mode="equation_nr_str" select="."/>
</xsl:variable>
<xsl:if test="$equation_nr != ''">
<td class="publication__equation__number">
<p>
<xsl:sequence select="$equation_nr"/>
</p>
</td>
</xsl:if>
</tr>
</xsl:template>
<!-- the theorem DECLARATION is not supposed to appear in the text: -->
<xsl:template mode="container" match="tei:ab[@type='theoremdeclaration']"/>
<xsl:template mode="container" match="tei:ab[@type='theoreminstance' and (@corresp != '')]">
<xsl:variable name="id"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('theorem' , $id))"/>
<xsl:variable name="theorem_id" select="eoa:normalize_reference(@corresp)"/>
<xsl:variable name="theorem_name" select="
//tei:ab[@type = 'theoremdeclaration'][@xml:id = $theorem_id]
"/>
<xsl:variable name="theorem_number">
<xsl:number
count="tei:ab[@type = 'theoreminstance']"
from="tei:div[@type = 'chapter']"
/>
</xsl:variable>
<xsl:call-template name="render_paragraph_container">
<xsl:with-param name="content" as="element()*">
<p>
<strong><xsl:value-of select="concat($theorem_name, ' ', $theorem_number, ': ')"/></strong>
<em><xsl:value-of select="."/></em>
</p>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="container" match="tei:lg[@type='verse']">
<xsl:variable name="id"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('verse', $id))"/>
<xsl:call-template name="render_paragraph_container">
<xsl:with-param name="content" as="element()*">
<p>
<xsl:for-each select="tei:l">
<xsl:apply-templates mode="inline"/>
<xsl:if test="position() != last()">
<br/>
</xsl:if>
</xsl:for-each>
</p>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="container" match="tei:quote">
<xsl:variable name="id"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('quote', $id))"/>
<xsl:call-template name="render_paragraph_container">
<xsl:with-param name="content" as="element()*">
<p>
<xsl:apply-templates mode="inline"/>
</p>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="container" match="tei:list[@type='ordered' or @type='unordered' or @type='gloss']">
<xsl:variable name="id"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('list', $id))"/>
<xsl:call-template name="render_paragraph_container">
<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="$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="inline"/>
</li>
</xsl:for-each>
</xsl:element>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="container" match="tei:table">
<xsl:variable name="id"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('table', $id))"/>
<xsl:call-template name="render_paragraph_container">
<xsl:with-param name="content" as="element()*">
<figure>
<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="inline"/>
</xsl:element>
</xsl:for-each>
</tr>
</xsl:for-each>
</xsl:element>
<xsl:if test="tei:head">
<figcaption>
<xsl:call-template name="render_table_heading_numbered"/>
</figcaption>
</xsl:if>
</figure>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="container" match="tei:figure">
<!-- TODO: check/fix path -->
<xsl:variable name="id"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:sequence select="eoa:info(concat('paragraph', $id))"/>
<xsl:variable name="img_url" select="eoa:conc_path3('../../..', $publ_static_url,tei:graphic/@url)"/>
<xsl:call-template name="render_paragraph_container">
<xsl:with-param name="content" as="element()*">
<xsl:variable name="caption">
<xsl:call-template name="render_figure_heading_numbered"/>
</xsl:variable>
<figure class="publication__image">
<a href="{$img_url}" data-lightbox="" title="{$caption}">
<img src="{$img_url}" data-object-fit="cover"></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:stylesheet>