2025-03-21 14:14:03 +03:00
|
|
|
<?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>
|
|
|
|
|
2025-03-22 18:32:34 +03:00
|
|
|
<xsl:template match="abv:mark">
|
|
|
|
<mark>
|
2025-03-22 23:43:48 +03:00
|
|
|
<xsl:apply-templates/>
|
2025-03-22 18:32:34 +03:00
|
|
|
</mark>
|
|
|
|
</xsl:template>
|
|
|
|
|
2025-03-21 14:14:03 +03:00
|
|
|
<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()"/>
|
|
|
|
</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>
|
|
|
|
|
2025-03-22 23:43:48 +03:00
|
|
|
<xsl:template match="tei:cit[@type='example']/tei:quote |
|
|
|
|
tei:cit[@type='example']/abv:mark/tei:quote">
|
2025-03-21 14:14:03 +03:00
|
|
|
<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'">
|
2025-03-21 19:46:17 +03:00
|
|
|
<!-- <xsl:element name="a"> -->
|
|
|
|
<!-- <xsl:attribute name="href">#</xsl:attribute> -->
|
2025-03-21 14:14:03 +03:00
|
|
|
<xsl:call-template name="make-word"/>
|
2025-03-21 19:46:17 +03:00
|
|
|
<!-- </xsl:element> -->
|
2025-03-21 14:14:03 +03:00
|
|
|
</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>
|