322 lines
No EOL
15 KiB
XML
322 lines
No EOL
15 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
|
xmlns:tei="http://www.tei-c.org/ns/1.0"
|
|
xmlns:abv="http://ossetic-studies.org/ns/abaevdict"
|
|
exclude-result-prefixes="xs tei"
|
|
version="2.0">
|
|
<xsl:output method="xml"/>
|
|
|
|
<!-- Which language we are using for the final output -->
|
|
<xsl:param name="lang"/>
|
|
|
|
<!-- Function that recursively produces a sequence of languages -->
|
|
<xsl:function name="abv:getlangs" as="xs:string+">
|
|
<xsl:param name="node" as="node()"/>
|
|
<xsl:choose>
|
|
<xsl:when test="$node/@xml:lang">
|
|
<xsl:sequence select="($node/@xml:lang, tokenize($node/@extralang,','))"/>
|
|
<!-- <xsl:value-of select="($node/@xml:lang,$node/@extralang)"/> -->
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:sequence select="abv:getlangs($node/..)"/>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:function>
|
|
|
|
<xsl:template match="tei:entry">
|
|
<xsl:variable name="entry-id" select="@xml:id"/>
|
|
<xsl:element name="article">
|
|
<xsl:attribute name="id" select="$entry-id"/>
|
|
<xsl:attribute name="lang" select="$lang"/>
|
|
<xsl:attribute name="class">abv-entry</xsl:attribute>
|
|
<xsl:variable name="position">0</xsl:variable>
|
|
|
|
<!-- Split into two groups: the headword div and the rest -->
|
|
<xsl:for-each-group select="*" group-adjacent="self::tei:form or
|
|
(self::tei:pc and following-sibling::*[1][self::tei:form])">
|
|
<xsl:choose>
|
|
<xsl:when test="current-grouping-key()">
|
|
<h6 class="abv-headword">
|
|
<xsl:apply-templates select="current-group()"/>
|
|
<br/>
|
|
<a class="abv-map" href="#modal_map">
|
|
<xsl:attribute name="data-abv-entry" select="$entry-id"/>
|
|
<!-- map icon by Free Icons (https://free-icons.github.io/free-icons/) -->
|
|
<svg xmlns="http://www.w3.org/2000/svg" height="1em" fill="currentColor" viewBox="0 0 512 512">
|
|
<path
|
|
d="M 160.88888888888889 57.77777777777778 Q 163.55555555555554 56.888888888888886 165.33333333333334 56.888888888888886 L 348.44444444444446 113.77777777777777 L 348.44444444444446 113.77777777777777 L 473.77777777777777 67.55555555555556 L 473.77777777777777 67.55555555555556 Q 488 63.111111111111114 499.55555555555554 71.11111111111111 Q 511.1111111111111 79.11111111111111 512 94.22222222222223 L 512 376 L 512 376 Q 511.1111111111111 395.55555555555554 493.3333333333333 402.6666666666667 L 351.1111111111111 455.1111111111111 L 351.1111111111111 455.1111111111111 Q 348.44444444444446 455.1111111111111 346.6666666666667 455.1111111111111 L 163.55555555555554 398.22222222222223 L 163.55555555555554 398.22222222222223 L 38.22222222222222 444.44444444444446 L 38.22222222222222 444.44444444444446 Q 24 448.8888888888889 12.444444444444445 440.8888888888889 Q 0.8888888888888888 432.8888888888889 0 417.77777777777777 L 0 136 L 0 136 Q 0.8888888888888888 116.44444444444444 18.666666666666668 109.33333333333333 L 160.88888888888889 57.77777777777778 L 160.88888888888889 57.77777777777778 Z M 24 122.66666666666667 Q 15.11111111111111 126.22222222222223 14.222222222222221 136 L 14.222222222222221 417.77777777777777 L 14.222222222222221 417.77777777777777 Q 14.222222222222221 424.8888888888889 20.444444444444443 429.3333333333333 Q 25.77777777777778 432.8888888888889 33.77777777777778 431.1111111111111 L 156.44444444444446 385.77777777777777 L 156.44444444444446 385.77777777777777 L 156.44444444444446 73.77777777777777 L 156.44444444444446 73.77777777777777 L 24 122.66666666666667 L 24 122.66666666666667 Z M 341.3333333333333 438.22222222222223 L 341.3333333333333 126.22222222222223 L 341.3333333333333 438.22222222222223 L 341.3333333333333 126.22222222222223 L 170.66666666666666 73.77777777777777 L 170.66666666666666 73.77777777777777 L 170.66666666666666 385.77777777777777 L 170.66666666666666 385.77777777777777 L 341.3333333333333 438.22222222222223 L 341.3333333333333 438.22222222222223 Z M 355.55555555555554 438.22222222222223 L 488.8888888888889 389.3333333333333 L 355.55555555555554 438.22222222222223 L 488.8888888888889 389.3333333333333 Q 496.8888888888889 385.77777777777777 497.77777777777777 376 L 497.77777777777777 94.22222222222223 L 497.77777777777777 94.22222222222223 Q 497.77777777777777 87.11111111111111 491.55555555555554 82.66666666666667 Q 486.22222222222223 79.11111111111111 479.1111111111111 80.88888888888889 L 355.55555555555554 126.22222222222223 L 355.55555555555554 126.22222222222223 L 355.55555555555554 438.22222222222223 L 355.55555555555554 438.22222222222223 Z"
|
|
/>
|
|
</svg>
|
|
</a>
|
|
</h6>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<!-- Further split into usg 9i.e. dialect marking) and rest -->
|
|
<xsl:for-each-group select="current-group()"
|
|
group-adjacent="self::tei:usg or (self::tei:pc and following-sibling::*[1][self::tei:usg])" composite="yes">
|
|
<xsl:choose>
|
|
<xsl:when test="current-grouping-key()">
|
|
<div class="abv-usg">
|
|
<xsl:apply-templates select="current-group()"/>
|
|
</div>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<!-- If there is no usg, create an empty div for correct
|
|
alignment -->
|
|
<xsl:if test="not(../tei:usg)">
|
|
<div class="abv-usg"></div>
|
|
</xsl:if>
|
|
<div class="abv-entrytxt">
|
|
<!-- Split main part into two paragraphs: examples and etym -->
|
|
<xsl:for-each-group select="current-group()"
|
|
group-adjacent="not(self::tei:etym)">
|
|
<xsl:choose>
|
|
<xsl:when test="current-grouping-key()">
|
|
<p class="abv-mainpart">
|
|
<xsl:apply-templates select="current-group()"/>
|
|
</p>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:apply-templates select="current-group()"/>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:for-each-group>
|
|
</div>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:for-each-group>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:for-each-group>
|
|
<!-- <div class="abv-usg">
|
|
<xsl:for-each select="tei:usg">
|
|
<xsl:apply-templates select="."/>
|
|
</xsl:for-each>
|
|
</div>
|
|
<div class="abv-entrytxt">
|
|
<p class="abv-mainpart">
|
|
<xsl:for-each select="*[not(self::tei:etym) and not(self::tei:form or self::tei:pc[following-sibling::*[1][self::tei:form]]) and not(self::tei:usg)]">
|
|
<xsl:apply-templates select="."/>
|
|
</xsl:for-each>
|
|
</p>
|
|
<xsl:apply-templates select="tei:etym"/>
|
|
</div> -->
|
|
</xsl:element>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="tei:form/tei:orth">
|
|
<xsl:variable name="elem">
|
|
<xsl:choose>
|
|
<xsl:when test="ancestor::tei:cit[@type='formGrp']">i</xsl:when>
|
|
<xsl:otherwise>b</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:variable>
|
|
<xsl:element name="{$elem}">
|
|
<xsl:attribute name="class">abv-form</xsl:attribute>
|
|
<xsl:attribute name="lang" select="../@xml:lang"/>
|
|
<xsl:apply-templates/>
|
|
</xsl:element>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="tei:cit[@type='translationEquivalent']/tei:quote | tei:gloss/tei:q">
|
|
<xsl:element name="q">
|
|
<xsl:attribute name="class">abv-gloss</xsl:attribute>
|
|
<xsl:apply-templates/>
|
|
</xsl:element>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="tei:cit[@type='translation']/tei:quote">
|
|
<xsl:element name="q">
|
|
<xsl:attribute name="class">abv-tr</xsl:attribute>
|
|
<xsl:apply-templates/>
|
|
</xsl:element>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="tei:cit[@type='example']/tei:quote">
|
|
<xsl:element name="i">
|
|
<xsl:attribute name="class">abv-example</xsl:attribute>
|
|
<xsl:attribute name="lang" select="../@xml:lang"/>
|
|
<xsl:apply-templates/>
|
|
</xsl:element>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="tei:ref[@type='bibl']">
|
|
<xsl:element name="a">
|
|
<xsl:attribute name="class">abv-bibl</xsl:attribute>
|
|
<xsl:attribute name="href" select="@target"/>
|
|
<xsl:apply-templates/>
|
|
</xsl:element>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="tei:ref[@type='bibl']/tei:abbr">
|
|
<xsl:element name="abbr">
|
|
<xsl:attribute name="class">abv-bibl</xsl:attribute>
|
|
<xsl:apply-templates/>
|
|
</xsl:element>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="tei:ref[@type='xr' and not(tei:c | tei:m | tei:w | tei:phr | tei:s)]">
|
|
<xsl:element name="a">
|
|
<xsl:attribute name="href" select="@target"/>
|
|
<xsl:element name="i">
|
|
<xsl:choose>
|
|
<xsl:when test="../@xml:lang">
|
|
<xsl:attribute name="lang" select="../@xml:lang"/>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:attribute name="lang">os</xsl:attribute>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
<xsl:apply-templates/>
|
|
</xsl:element>
|
|
</xsl:element>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="tei:ref[@type='xr']/tei:c | tei:ref[@type='xr']/tei:m | tei:ref[@type='xr']/tei:w | tei:ref[@type='xr']/tei:phr | tei:ref[@type='xr']/tei:s">
|
|
<xsl:element name="a">
|
|
<xsl:attribute name="href" select="../@target"/>
|
|
<xsl:element name="i">
|
|
<xsl:choose>
|
|
<xsl:when test="@xml:lang">
|
|
<xsl:attribute name="lang" select="@xml:lang"/>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:attribute name="lang">os</xsl:attribute>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
<xsl:apply-templates/>
|
|
</xsl:element>
|
|
</xsl:element>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="tei:name | tei:author">
|
|
<xsl:element name="span">
|
|
<xsl:attribute name="class">abv-name</xsl:attribute>
|
|
<xsl:apply-templates/>
|
|
</xsl:element>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="tei:lang">
|
|
<xsl:element name="abbr">
|
|
<xsl:attribute name="class">abv-lang</xsl:attribute>
|
|
<xsl:attribute name="data-lang" select="string-join(abv:getlangs(.),',')"/>
|
|
<!-- <xsl:attribute name="title">#</xsl:attribute> TODO: Implement lookup table for full language names -->
|
|
<xsl:apply-templates/>
|
|
</xsl:element>
|
|
</xsl:template>
|
|
|
|
<xsl:template name="make-word">
|
|
<xsl:element name="i">
|
|
<!-- If the element has its own language, or is part of a
|
|
mentioned, assign it a language. Otherwise, assign a special tag
|
|
that says that it is not really a linguistic object (e.g. an
|
|
abstract hypothetical form, phonetic sequence, etc.)-->
|
|
<xsl:choose>
|
|
<xsl:when test="../name() = 'mentioned' or @xml:lang">
|
|
<xsl:attribute name="lang" select="abv:getlangs(.)[1]"/>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:attribute name="lang" select="'zxx'"/>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
<xsl:apply-templates/>
|
|
</xsl:element>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="tei:c | tei:m | tei:w | tei:phr | tei:s">
|
|
<xsl:choose>
|
|
<xsl:when test="../name() = 'mentioned'">
|
|
<!-- <xsl:element name="a"> -->
|
|
<!-- <xsl:attribute name="href">#</xsl:attribute> -->
|
|
<xsl:call-template name="make-word"/>
|
|
<!-- </xsl:element> -->
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:call-template name="make-word"/>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:template>
|
|
|
|
<!-- If pc is empty, add one space -->
|
|
<xsl:template match="tei:pc[not(node())]">
|
|
<xsl:text> </xsl:text>
|
|
</xsl:template>
|
|
|
|
|
|
<!-- ETYMOLOGY -->
|
|
<xsl:template match="tei:etym">
|
|
<p class="abv-etym">
|
|
<xsl:apply-templates />
|
|
</p>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="tei:oRef">
|
|
<xsl:element name="i">
|
|
<!-- If oRef has a language, select it, otherwise
|
|
use the entry language -->
|
|
<xsl:attribute name="lang">
|
|
<xsl:choose>
|
|
<xsl:when test="@xml:lang">
|
|
<xsl:value-of select="@xml:lang"/>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:value-of select="ancestor::tei:entry/@xml:lang"/>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:attribute>
|
|
<xsl:apply-templates/>
|
|
</xsl:element>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="tei:lb">
|
|
<xsl:element name="br"/>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="tei:hi">
|
|
<xsl:choose>
|
|
<xsl:when test="@rendition='#rend_italic'">
|
|
<em><xsl:apply-templates/></em>
|
|
</xsl:when>
|
|
<xsl:when test="@rendition='#rend_bold'">
|
|
<strong><xsl:apply-templates/></strong>
|
|
</xsl:when>
|
|
<xsl:when test="@rendition='#rend_underline'">
|
|
<span class="abv-text-ul"><xsl:apply-templates/></span>
|
|
</xsl:when>
|
|
<xsl:when test="@rendition='#rend_subscript'">
|
|
<sub><xsl:apply-templates/></sub>
|
|
</xsl:when>
|
|
<xsl:when test="@rendition='#rend_superscript'">
|
|
<sup><xsl:apply-templates/></sup>
|
|
</xsl:when>
|
|
<xsl:when test="@rendition='#rend_smallcaps'">
|
|
<span class="abv-text-sc"><xsl:apply-templates/></span>
|
|
</xsl:when>
|
|
</xsl:choose>
|
|
</xsl:template>
|
|
|
|
<!-- tables -->
|
|
<xsl:template match="tei:table">
|
|
<table>
|
|
<xsl:apply-templates/>
|
|
</table>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="tei:row">
|
|
<tr>
|
|
<xsl:apply-templates/>
|
|
</tr>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="tei:cell">
|
|
<td>
|
|
<xsl:apply-templates/>
|
|
</td>
|
|
</xsl:template>
|
|
|
|
<xsl:template match=
|
|
"text()">
|
|
<xsl:value-of select="replace(translate(., '
', ''), ' +', ' ')"/>
|
|
</xsl:template>
|
|
</xsl:stylesheet> |