Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
experimental implementation of equation related elements.
  • Loading branch information
EsGeh authored and EsGeh committed Mar 21, 2019
1 parent 672936b commit e923db6
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tei2html.xsl
Expand Up @@ -18,6 +18,9 @@
<xsl:key name="fr" match="translations/entry" use="@fr"/>
<xsl:key name="it" match="translations/entry" use="@it"/>

<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)"/>

<!-- index sorting, https://stackoverflow.com/questions/13763271 -->
<xsl:key name="kWith1stLetter" match="family" use="substring(.,1,1)"/>

Expand Down Expand Up @@ -871,8 +874,20 @@

<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)"/>

<xsl:message>paragraph <xsl:value-of select="$paragraph_nr"/></xsl:message>
<p>
<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:message>( theorem nr <xsl:value-of select="$theorem_nr"/> )</xsl:message>
<b>
<xsl:value-of select="concat( $theorem/text(), ' ', $theorem_nr, ': ')"/>
</b>
</xsl:if>
<xsl:apply-templates mode="html"/>
</p>

Expand Down Expand Up @@ -914,6 +929,35 @@
<xsl:value-of select="concat('$', ., '$')"/>
</xsl:template>

<xsl:template match="tei:ab[@type='subequations']" mode="body">
<xsl:message>equation array</xsl:message>
<xsl:element name="table">
<xsl:for-each select="tei:formula">
<tr>
<td>
<xsl:value-of select="concat('$', ., '$')"/>
</td>
</tr>
</xsl:for-each>
</xsl:element>
</xsl:template>

<xsl:template match="tei:ab[@type='equationarray']" mode="body">
<xsl:message>equation array</xsl:message>
<xsl:element name="table">
<xsl:for-each select="tei:formula">
<tr>
<td>
<xsl:value-of select="concat('$', ., '$')"/>
</td>
</tr>
</xsl:for-each>
</xsl:element>
</xsl:template>

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

<xsl:template match="tei:lg[@type='verse']" mode="body">
<!-- TODO: find a way to indent the poem -->
<xsl:message>verse</xsl:message>
Expand Down Expand Up @@ -1309,6 +1353,15 @@
</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:function name="eoa:debug">
<xsl:param name="level" as="xs:integer"/>
<xsl:param name="message" as="xs:string"/>
Expand Down

0 comments on commit e923db6

Please sign in to comment.