Skip to content

Commit

Permalink
better name for template mode
Browse files Browse the repository at this point in the history
  • Loading branch information
EsGeh authored and EsGeh committed Nov 5, 2019
1 parent d495f71 commit 143187d
Showing 1 changed file with 27 additions and 42 deletions.
69 changes: 27 additions & 42 deletions tei2html/utils/html_rules.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<xsl:variable name="local_uri" select="concat($series, '/', $publication_number, '/', $chapter_nr , '/index.html')"/>
<xsl:variable name="global_uri" select="concat($domain, '/', $local_uri)"/>
<div class="accordion">
<xsl:message>rendering chapter!</xsl:message>
<div class="accordion__main">
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" as="xs:string" select="$global_uri"/>
Expand All @@ -50,7 +49,7 @@
<xsl:value-of select="@n"/>
</xsl:if>
<xsl:text> </xsl:text>
<xsl:apply-templates mode="body" select="./tei:head"/>
<xsl:apply-templates mode="text_structure" select="./tei:head"/>
</h1>
<!-- print chapter authors, if any -->
<xsl:if test="@resp">
Expand All @@ -65,12 +64,12 @@
</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)]"/>
<!--
<xsl:apply-templates mode="body" select="tei:*[not(self::tei:head) and not(self::tei:div[@type = 'section']) and not(self::tei:div[@type = 'subsection']) and not(self::tei:div[@type = 'subsubsection'])]"/>
<xsl:apply-templates mode="text_structure" select="tei:*[not(self::tei:head) and not(self::tei:div[@type = 'section']) and not(self::tei:div[@type = 'subsection']) and not(self::tei:div[@type = 'subsubsection'])]"/>
-->
</div>
<a class="accordion__showall show" href="#">Close All</a>
<!-- render chapter text -->
<xsl:apply-templates mode="body" select="(if (tei:div[@type = 'section']) then (tei:div[@type = 'section'][1]/(. | following-sibling::*)) else (*))[not(self::tei:head)]"/>
<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>
Expand Down Expand Up @@ -154,8 +153,8 @@
<!-- section hierarchy -->

<!-- default rule: warning -->
<xsl:template mode="body" match="tei:*" priority="-100">
<xsl:message>WARNING: in mode 'body': no template for
<xsl:template mode="text_structure" match="tei:*" priority="-100">
<xsl:message>WARNING: in mode 'text_structure': no template for
<xsl:value-of select="concat('', name(), ': ') "/>
<xsl:value-of select="./text()"/>
</xsl:message>
Expand All @@ -164,7 +163,7 @@
-->
</xsl:template>

<xsl:template mode="body" match="tei:div[@type='section']">
<xsl:template mode="text_structure" match="tei:div[@type='section']">
<xsl:message>section</xsl:message>
<div class="accordion__item active">
<a class="accordion__title" href="#">
Expand All @@ -175,13 +174,13 @@
<xsl:if test="../@n != 'nonumber'">
<xsl:value-of select="concat(../@n, '.', @n, ' ')"/>
</xsl:if>
<xsl:apply-templates mode="body" select="tei:head"/>
<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="body" select="*[not(self::tei:head)]"/>
<xsl:apply-templates mode="text_structure" select="*[not(self::tei:head)]"/>
<a class="accordion__pageup" href="#"></a>
</div>
</div>
Expand All @@ -192,19 +191,19 @@
<xsl:if test="../@n != 'nonumber'">
<xsl:value-of select="concat(../@n, '.', @n, ' ')"/>
</xsl:if>
<xsl:apply-templates select="tei:head" mode="body"/>
<xsl:apply-templates select="tei:head" mode="text_structure"/>
</h2>
</a>
<div class="accordion__content">
<xsl:apply-templates select="*[not(self::tei:head)]" mode="body"/>
<xsl:apply-templates select="*[not(self::tei:head)]" mode="text_structure"/>
- the link to close the accordion: -
<a class="accordion__pageup" href="#"/>
</div>
</div>
-->
</xsl:template>

<xsl:template mode="body" match="tei:div[@type='subsection']">
<xsl:template mode="text_structure" match="tei:div[@type='subsection']">
<xsl:message>subsection</xsl:message>
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" as="xs:string" select="'subsectionlink'"/>
Expand All @@ -213,29 +212,29 @@
<xsl:if test="../../@n != 'nonumber'">
<xsl:value-of select="concat(../../@n, '.', ../@n, '.', @n, ' ')"/>
</xsl:if>
<xsl:apply-templates mode="body" select="tei:head"/>
<xsl:apply-templates mode="text_structure" select="tei:head"/>
</h4>
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates mode="body" select="*[not(self::tei:head)]"/>
<xsl:apply-templates mode="text_structure" select="*[not(self::tei:head)]"/>
</xsl:template>

<xsl:template mode="body" match="tei:div[@type='subsubsection']">
<xsl:template mode="text_structure" match="tei:div[@type='subsubsection']">
<xsl:message>subsubsection</xsl:message>
<xsl:call-template name="accordion_row">
<xsl:with-param name="link" as="xs:string" select="'subsectionlink'"/>
<xsl:with-param name="content" as="element()*">
<h4>
<xsl:apply-templates mode="body" select="./tei:head"/>
<xsl:apply-templates mode="text_structure" select="./tei:head"/>
</h4>
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates mode="body" select="*[not(self::tei:head)]"/>
<xsl:apply-templates mode="text_structure" select="*[not(self::tei:head)]"/>
</xsl:template>

<!-- paragraph level elements: -->

<xsl:template mode="body" match="tei:body//tei:head">
<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()"/>
Expand All @@ -246,11 +245,10 @@
</xsl:choose>
</xsl:template>

<xsl:template mode="body" match="tei:body//tei:p" as="element(div)">
<xsl:template mode="text_structure" match="tei:body//tei:p" as="element(div)">
<xsl:variable name="chapter" select="ancestor::tei:div[@type = 'chapter']"/>
<xsl:variable name="chapter_nr" select="count($chapter/preceding-sibling::*)"/>
<xsl:variable name="paragraph_id"><xsl:call-template name="paragraph_id"/></xsl:variable>

<xsl:variable name="local_uri" select="concat($series, '/', $publication_number, '/', $chapter_nr , '/index.html#', $paragraph_id)"/>
<xsl:variable name="global_uri" select="concat($domain, '/', $local_uri)"/>
<xsl:message>paragraph <xsl:value-of select="$paragraph_id"/></xsl:message>
Expand All @@ -273,27 +271,14 @@
</p>
</xsl:with-param>
</xsl:call-template>

<!-- the infobox link: -->
<!--
<a class="accordion__popap" href="#"></a>
<div class="infobox infobox- -arrow-left">
<h4 class="infobox__title">Permanent Link</h4>
<p class="infobox__description">If you want to directly link to this paragraph in the text, you can use the following URL:</p>
<a title="Permanent Link" href="{$global_uri}">
<xsl:value-of select="$global_uri"/>
</a>
</div>
-->
</xsl:template>

<xsl:template mode="body" match="tei:ab[@type='equation']">
<xsl:template mode="text_structure" match="tei:ab[@type='equation']">
<xsl:message>block formula</xsl:message>
<xsl:value-of select="concat('$', ., '$')"/>
</xsl:template>

<xsl:template mode="body" match="tei:ab[@type='subequations']">
<xsl:template mode="text_structure" match="tei:ab[@type='subequations']">
<xsl:message>equation array</xsl:message>
<xsl:variable name="paragraph_id"><xsl:call-template name="paragraph_id"/></xsl:variable>
<xsl:element name="table">
Expand All @@ -307,7 +292,7 @@
</xsl:element>
</xsl:template>

<xsl:template mode="body" match="tei:ab[@type='equationarray']">
<xsl:template mode="text_structure" match="tei:ab[@type='equationarray']">
<xsl:message>equation array</xsl:message>
<xsl:variable name="paragraph_id"><xsl:call-template name="paragraph_id"/></xsl:variable>
<xsl:element name="table">
Expand All @@ -322,9 +307,9 @@
</xsl:template>

<!-- the theorem DECLARATION is not supposed to appear in the text: -->
<xsl:template mode="body" match="tei:ab[@type='theoremdeclaration']"/>
<xsl:template mode="text_structure" match="tei:ab[@type='theoremdeclaration']"/>

<xsl:template mode="body" match="tei:lg[@type='verse']">
<xsl:template mode="text_structure" match="tei:lg[@type='verse']">
<!-- TODO: find a way to indent the poem -->
<xsl:message>verse</xsl:message>
<xsl:variable name="paragraph_id"><xsl:call-template name="paragraph_id"/></xsl:variable>
Expand All @@ -338,7 +323,7 @@
</p>
</xsl:template>

<xsl:template mode="body" match="tei:quote">
<xsl:template mode="text_structure" match="tei:quote">
<!-- TODO: find a way to indent the quote -->
<xsl:message>quote</xsl:message>
<xsl:variable name="paragraph_id"><xsl:call-template name="paragraph_id"/></xsl:variable>
Expand All @@ -347,7 +332,7 @@
</p>
</xsl:template>

<xsl:template mode="body" match="tei:list[@type='ordered' or @type='unordered' or @type='gloss']">
<xsl:template mode="text_structure" match="tei:list[@type='ordered' or @type='unordered' or @type='gloss']">
<xsl:message>list</xsl:message>
<xsl:variable name="paragraph_id"><xsl:call-template name="paragraph_id"/></xsl:variable>
<xsl:variable name="element_name">
Expand All @@ -374,7 +359,7 @@
</xsl:element>
</xsl:template>

<xsl:template mode="body" match="tei:table">
<xsl:template mode="text_structure" match="tei:table">
<xsl:message>table</xsl:message>
<xsl:variable name="paragraph_id"><xsl:call-template name="paragraph_id"/></xsl:variable>
<figure id="{$paragraph_id}">
Expand All @@ -397,7 +382,7 @@
</figure>
</xsl:template>

<xsl:template mode="body" match="tei:figure">
<xsl:template mode="text_structure" match="tei:figure">
<!-- TODO: check/fix path -->
<xsl:message>figure</xsl:message>
<xsl:variable name="paragraph_id"><xsl:call-template name="paragraph_id"/></xsl:variable>
Expand Down

0 comments on commit 143187d

Please sign in to comment.