Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
implemented index (TODO: subindices)
  • Loading branch information
EsGeh authored and EsGeh committed Mar 21, 2019
1 parent e923db6 commit d82464f
Showing 1 changed file with 32 additions and 36 deletions.
68 changes: 32 additions & 36 deletions tei2html.xsl
Expand Up @@ -1302,25 +1302,41 @@

<xsl:template name="create_index">
<xsl:param name="indextype"/>
<xsl:for-each select="//tei:index[@indexName=$indextype]">
<xsl:sort lang="de" select="if (exists(./tei:term/@sortKey)) then ./tei:term/@sortKey else ./tei:term/text()"/>
<xsl:variable name="sortkey" select="if (exists(./tei:term/@sortKey)) then ./tei:term/@sortKey else ./tei:term/text()"/>
<!-- next is somewhat sketchy and does not work properly -->
<!-- <xsl:apply-templates select="//tei:index[@indexName=$indextype] [generate-id() = generate-id(key('kWith1stLetter',substring(.,1,1))[1]) ]"> -->
<!--
<xsl:apply-templates select="if (exists(./tei:term/@sortKey)) then ./tei:term/@sortKey else ./tei:term/text() [generate-id() = generate-id(key('kWith1stLetter',substring(.,1,1))[1]) ]">
<xsl:sort select="substring(.,1,1)" />
</xsl:apply-templates>-->
<!-- start of index -->
<!-- per alphabet letter one item div -->

<!-- all index elements starting with the same letter: -->
<xsl:for-each-group select="//tei:index[lower-case(@indexName) = $indextype]" group-by="substring(if (exists(./tei:term/@sortKey)) then ./tei:term/@sortKey else ./tei:term/text(),1,1)">
<xsl:sort select="current-grouping-key()"/>

<xsl:variable name="chapter" select="ancestor::tei:div[@type = 'chapter']"/>
<xsl:variable name="chapter_nr" select="count($chapter/preceding-sibling::*)"/>

<div class="accordion__item">
<a class="accordion__title" href="#">
<xsl:call-template name="create_index_letter"/>
<h2 class="border">
<xsl:value-of select="current-grouping-key()"/>
</h2>
</a>
<div class="accordion__content">
<xsl:call-template name="create_index_content"/>
<!-- each item has a h4 heading -->
<!-- below that, ul/li for each jumping point -->
<!-- all index elements with the same "term": -->
<xsl:for-each-group select="current-group()" group-by="if (exists(tei:term/@sortKey)) then tei:term/@sortKey else tei:term/text()">
<xsl:sort select="current-grouping-key()"/>
<h4>
<xsl:value-of select="current-grouping-key()"/>
</h4>
<ul>
<xsl:for-each select="current-group()">

<xsl:variable name="paragraph_nr" select="index-of($chapter//tei:p/tei:index/generate-id(), generate-id(.))"/>
<xsl:variable name="local_uri" select="concat($series, '/', $publication_number, '/', $chapter_nr , '/index.html#', $paragraph_nr)"/>
<xsl:variable name="global_uri" select="concat($domain, '/', $local_uri)"/>

<li>
<a href="{$global_uri}"> <xsl:value-of select="position()"/></a>
</li>
</xsl:for-each>
</ul>
<!-- below that, ul/li for each jumping point -->
</xsl:for-each-group>
</div>
</div>
<!--
Expand All @@ -1330,29 +1346,9 @@
<xsl:value-of select="./tei:term//text()"/>
</xsl:message>
-->
</xsl:for-each>
</xsl:template>

<xsl:template name="create_index_letter">
<xsl:variable name="sortkey" select="if (exists(./tei:term/@sortKey)) then ./tei:term/@sortKey else ./tei:term/text()"/>
<h2 class="border">
<xsl:value-of select="substring($sortkey,1,1)"/>
</h2>
<!-- <xsl:apply-templates mode="inGroup" select="key('kWith1stLetter',substring(.,1,1))"/>-->
</xsl:for-each-group>
</xsl:template>

<xsl:template name="create_index_content">
<h4>
<xsl:value-of select="."/>
</h4>
</xsl:template>

<!--
<xsl:template match="//tei:index[@indexName='keyword']" mode="inGroup">
<p><xsl:value-of select="."/>,satan <xsl:value-of select="../given"/></p>
</xsl:template>
-->

<xsl:function name="eoa:normalize_reference">
<xsl:param name="reference"/>
<xsl:analyze-string select="$reference" regex="#{{0,1}}(.+)">
Expand Down

0 comments on commit d82464f

Please sign in to comment.