initial commit

This commit is contained in:
Oleg Belyaev 2025-03-21 14:14:03 +03:00
parent cee3efab31
commit 71219733bd
31 changed files with 9242 additions and 0 deletions

322
xsl/abaev2html.xsl Normal file
View file

@ -0,0 +1,322 @@
<?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(., '&#xA;', ''), ' +', ' ')"/>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,44 @@
<?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:param name="default-lang"/>
<!-- XSLT Template to copy anything -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="tei:gloss | tei:note">
<xsl:copy>
<xsl:if test="not(@xml:lang)">
<xsl:attribute name="xml:lang">
<xsl:value-of select="$default-lang"/>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="tei:lang[@xml:lang]">
<xsl:element name="tei:rs">
<xsl:attribute name="xml:lang"><xsl:value-of select="@xml:lang"/></xsl:attribute>
<xsl:element name="tei:lang">
<xsl:attribute name="xml:lang">
<xsl:value-of select="$default-lang"/>
</xsl:attribute>
<xsl:value-of select="node() | @*[not(name()='xml:lang')]"/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match=
"text()">
<xsl:value-of select="replace(translate(., '&#xA;', ''), ' +', ' ')"/>
</xsl:template>
</xsl:stylesheet>

30
xsl/delete-lang.xsl Normal file
View file

@ -0,0 +1,30 @@
<?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:param name="lang"/>
<!-- XSLT Template to copy anything -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="tei:etym|abv:tr|tei:def|tei:note|tei:bibl|tei:gram">
<xsl:choose>
<!-- <xsl:when test="lang($lang)"></xsl:when>-->
<xsl:when test="@xml:lang = $lang"></xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:biblScope[@xml:lang=$lang]"></xsl:template>
</xsl:stylesheet>

33
xsl/insert-langs.xsl Normal file
View file

@ -0,0 +1,33 @@
<?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="3.0">
<xsl:param name="name-lang"/>
<xsl:mode on-no-match="shallow-copy" />
<xsl:import href="lang-names.xsl"/>
<xsl:template match="tei:lang[not(text())]">
<xsl:variable name="lang-code" select="ancestor-or-self::*[attribute::xml:lang][1]/@xml:lang"/>
<xsl:copy>
<xsl:call-template name="lang-text">
<xsl:with-param name="lang-code" select="$lang-code"/>
<xsl:with-param name="name-lang" select="$name-lang"/>
</xsl:call-template>
<xsl:if test="parent::*/@extralang">
<xsl:for-each select="tokenize(parent::*/@extralang, ' ')">
<xsl:text>, </xsl:text>
<xsl:call-template name="lang-text">
<xsl:with-param name="lang-code" select="."/>
<xsl:with-param name="name-lang" select="$name-lang"/>
</xsl:call-template>
</xsl:for-each>
</xsl:if>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

79
xsl/insert-refs.xsl Normal file
View file

@ -0,0 +1,79 @@
<?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:param name="lookup-raw"/>
<xsl:param name="biblio-raw"/>
<xsl:param name="bib-lang"/>
<xsl:variable name="lookup" select="parse-xml($lookup-raw)"/>
<xsl:variable name="biblio" select="parse-xml($biblio-raw)"/>
<!-- <xsl:variable name="random-doc" select="document('entries/abaev_lami.xml')"/>-->
<xsl:key name="xr" match="table/entry" use="@xml:id"/>
<!-- XSLT Template to copy anything -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="tei:ref[@type = 'xr'][not(node())]">
<xsl:variable name="target" select="@target"/>
<xsl:variable name="entry" select="$lookup/tei:table/tei:entry[@xml:id = substring($target, 2)]"/>
<xsl:if test="not($entry)"><xsl:message>Cross-referenced entry <xsl:value-of select="$target"/> not found! Lemma <xsl:value-of select="ancestor::tei:entry/@xml:id"/></xsl:message></xsl:if>
<!-- <xsl:message><xsl:value-of select="$lookup"/></xsl:message>-->
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
<xsl:if test="$entry/@n"><xsl:value-of xmlns:my="http://example.com/my" select="my:getN($entry/@n)"/></xsl:if><tei:w><xsl:value-of select="$entry/text()"/></tei:w>
</xsl:copy>
<!-- <xsl:message><xsl:value-of select="$random-doc/key('xr','entry_lami')"/></xsl:message>-->
</xsl:template>
<xsl:template match="tei:ref[@type = 'bibl'][not(node())]">
<xsl:variable name="target" select="@target"/>
<xsl:variable name="bibl" select="$biblio/tei:TEI/tei:text/tei:body/tei:div//tei:listBibl/tei:bibl[@xml:id = substring($target, 2)]"/>
<xsl:if test="not($bibl)"><xsl:message>Cross-referenced bibitem <xsl:value-of select="$target"/> not found! Lemma <xsl:value-of select="ancestor::tei:entry/@xml:id"/></xsl:message></xsl:if>
<!-- <xsl:message><xsl:value-of select="$lookup"/></xsl:message>-->
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
<xsl:choose>
<xsl:when test="$bibl/tei:abbr[not(@xml:lang)]">
<xsl:copy-of select="$bibl/tei:abbr"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$bibl/tei:abbr[@xml:lang = $bib-lang]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
<!-- <xsl:message><xsl:value-of select="$random-doc/key('xr','entry_lami')"/></xsl:message>-->
</xsl:template>
<xsl:template match="tei:oRef[not(node())]">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
<xsl:copy-of select="ancestor::*[local-name() = 'entry' or local-name() = 're'][position() = 1]/tei:form[1]/tei:orth[1]/child::node()"/>
</xsl:copy>
</xsl:template>
<xsl:function xmlns:my="http://example.com/my" name="my:getN">
<xsl:param name="n"/>
<xsl:choose>
<xsl:when test="$n = 1">¹</xsl:when>
<xsl:when test="$n = 2">²</xsl:when>
<xsl:when test="$n = 3">³</xsl:when>
<xsl:when test="$n = 4"></xsl:when>
<xsl:when test="$n = 5"></xsl:when>
<xsl:when test="$n = 6"></xsl:when>
<xsl:when test="$n = 7"></xsl:when>
<xsl:when test="$n = 8"></xsl:when>
<xsl:when test="$n = 9"></xsl:when>
</xsl:choose>
</xsl:function>
</xsl:stylesheet>

2304
xsl/lang-names.xsl Normal file

File diff suppressed because it is too large Load diff

354
xsl/standardize.xsl Normal file
View file

@ -0,0 +1,354 @@
<?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:param name="standardize-lang"/>
<!-- NAMED TEMPLATES-->
<xsl:template name="defaultlang">
<xsl:if test="not(@xml:lang)">
<xsl:variable name="entrylang" select="ancestor::tei:entry/@xml:lang"/>
<xsl:choose>
<xsl:when test="$entrylang = 'os'">
<xsl:attribute name="xml:lang">os-x-iron</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="xml:lang" select="$entrylang"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<!-- XSLT Template to copy anything -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<!-- Delete outdate elements-->
<xsl:template match="tei:encodingDesc|tei:tagsDecl">
</xsl:template>
<!-- The completeness attribute is to be used without namespace, to simplify styling.
For the purposes of conversion, delete it at present -->
<xsl:template match="@abv:completeness | @abv:status">
<!--<xsl:attribute name="completeness">
<xsl:value-of select="."/>
</xsl:attribute>-->
</xsl:template>
<!-- Replace these guys with placeholders, will fix later -->
<xsl:template match="tei:publicationStatement">
<xsl:element name="tei:publicationStatement">
<tei:p>PLACEHOLDER</tei:p>
</xsl:element>
</xsl:template>
<xsl:template match="tei:sourceDesc">
<xsl:element name="tei:sourceDesc">
<tei:p>PLACEHOLDER</tei:p>
</xsl:element>
</xsl:template>
<!-- Replace custom elements with TEI elements -->
<xsl:template match="abv:tr">
<xsl:choose>
<xsl:when test="preceding-sibling::*[1][self::tei:usg or self::tei:quote]">
<tei:pc><xsl:text> </xsl:text></tei:pc>
</xsl:when>
<xsl:when test="preceding-sibling::*[1][self::abv:tr]">
<tei:pc><xsl:text>, </xsl:text></tei:pc>
</xsl:when>
</xsl:choose>
<xsl:element name="tei:cit">
<xsl:attribute name="type">
<xsl:choose>
<xsl:when test="parent::tei:sense">translationEquivalent</xsl:when>
<xsl:when test="parent::abv:example">translation</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="abv:tr/tei:q">
<xsl:if test="preceding-sibling::*[1][self::tei:q]">
<tei:pc><xsl:text>, </xsl:text></tei:pc>
</xsl:if>
<xsl:element name="tei:quote">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="abv:example">
<xsl:choose>
<xsl:when test="parent::abv:formGrp and preceding-sibling::*[1][self::tei:form]">
<tei:pc><xsl:text>: </xsl:text></tei:pc>
</xsl:when>
<xsl:when test="parent::tei:sense">
<xsl:choose>
<xsl:when test="preceding-sibling::*[1][self::abv:tr]">
<tei:pc><xsl:text>: </xsl:text></tei:pc>
</xsl:when>
<xsl:when test="preceding-sibling::*[1][self::tei:sense]">
<tei:pc><xsl:text>; </xsl:text></tei:pc>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="(parent::tei:sense or parent::abv:exampleGrp) and preceding-sibling::*[1][self::abv:example]">
<tei:pc><xsl:text>; </xsl:text></tei:pc>
</xsl:when>
</xsl:choose>
<xsl:element name="tei:cit">
<xsl:attribute name="type">example</xsl:attribute>
<xsl:call-template name="defaultlang"/>
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="abv:exampleGrp">
<xsl:choose>
<xsl:when test="ancestor::tei:re[parent::tei:entry[child::tei:sense]]">
<tei:pc><xsl:text>: </xsl:text></tei:pc>
</xsl:when>
<xsl:otherwise><tei:pc>. — </tei:pc></xsl:otherwise>
</xsl:choose>
<xsl:element name="tei:dictScrap">
<xsl:apply-templates select="@*"/>
<xsl:if test="@n"><xsl:value-of select="@n"/><xsl:text>. </xsl:text></xsl:if>
<xsl:apply-templates select="node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="tei:re[tei:re]">
<xsl:element name="tei:dictScrap">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<!-- FORMS AND FORM GROUPS -->
<xsl:template match="abv:formGrp">
<xsl:choose>
<xsl:when test="preceding-sibling::*[1][self::tei:sense or self::tei:re]">
<tei:pc><xsl:text>; </xsl:text></tei:pc>
</xsl:when>
<xsl:when test="preceding-sibling::*[1][self::tei:form] or (parent::tei:entry and preceding-sibling::*[1][self::abv:formGrp])">
<tei:pc><xsl:text>, </xsl:text></tei:pc>
</xsl:when>
<xsl:when test="preceding-sibling::*[1][self::abv:exampleGrp]">
<tei:pc><xsl:text>. — </xsl:text></tei:pc>
</xsl:when>
</xsl:choose>
<xsl:element name="tei:cit">
<xsl:attribute name="type">formGrp</xsl:attribute>
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="tei:form">
<xsl:choose>
<xsl:when test="preceding-sibling::*[1][self::tei:usg]">
<tei:pc><xsl:text> </xsl:text></tei:pc>
</xsl:when>
<xsl:when test="preceding-sibling::*[1][self::tei:form[@xml:lang='os-x-iron']] and @xml:lang='os-x-digor'">
<tei:pc><xsl:text> | </xsl:text></tei:pc>
</xsl:when>
<xsl:when test="(preceding-sibling::*[1][self::tei:orth] and (@type='variant' or @type='synonym')) or (preceding-sibling::*[1][self::tei:form] and parent::tei:form and @type = 'variant')">
<tei:pc><xsl:text>, </xsl:text></tei:pc>
</xsl:when>
<xsl:when test="preceding-sibling::*[1][self::tei:orth or self::tei:form[@type = 'variant']] and @type='participle'">
<tei:pc><xsl:text> : </xsl:text></tei:pc>
</xsl:when>
</xsl:choose>
<xsl:if test="@subtype='parens'"><xsl:text>(</xsl:text></xsl:if>
<xsl:copy>
<xsl:if test="not(@xml:lang)">
<xsl:attribute name="xml:lang" select="ancestor::tei:entry/@xml:lang"/>
</xsl:if>
<xsl:apply-templates select="@*"/>
<xsl:if test="@type='rec'"><xsl:text>*</xsl:text></xsl:if>
<xsl:apply-templates select="node()"/>
</xsl:copy>
<xsl:if test="@subtype='parens'"><xsl:text>)</xsl:text></xsl:if>
</xsl:template>
<!-- WORDS ETC. -->
<xsl:template match="tei:w | tei:m | tei:c | tei:phr | tei:oRef">
<xsl:if test="preceding-sibling::*[1][@xml:lang='os-x-iron'] and @xml:lang='os-x-digor'"> <!-- THIS IS A HACK. MAYBE I'LL HAVE TO LIST THE TAG NAMES AFTER ALL -->
<tei:pc><xsl:text> | </xsl:text></tei:pc>
</xsl:if>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:if test="@type='rec'"><xsl:text>*</xsl:text></xsl:if>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<!-- Orth after lang or gram -->
<xsl:template match="tei:form/tei:orth[preceding-sibling::*[1][self::tei:lang or self::tei:gram]]">
<tei:pc><xsl:text> </xsl:text></tei:pc>
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<!-- USAGE NOTES -->
<xsl:template match="tei:usg">
<xsl:variable name="is_afterForm"><xsl:value-of select="boolean(preceding-sibling::*[1][self::tei:form or self::abv:formGrp])"/></xsl:variable>
<xsl:if test="$is_afterForm">
<tei:pc><xsl:text> </xsl:text></tei:pc>
</xsl:if>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:if test="$is_afterForm">
<tei:pc><xsl:text>(</xsl:text></tei:pc>
</xsl:if>
<xsl:apply-templates select="node()"/>
<xsl:if test="$is_afterForm">
<tei:pc><xsl:text>)</xsl:text></tei:pc>
</xsl:if>
</xsl:copy>
</xsl:template>
<!-- SENSES -->
<xsl:template match="tei:sense">
<xsl:choose>
<xsl:when test="preceding-sibling::*[1][self::abv:formGrp or self::tei:re or self::tei:usg or self::tei:note]">
<tei:pc><xsl:text> </xsl:text></tei:pc>
</xsl:when>
<xsl:when test="parent::tei:entry or parent::tei:re">
<xsl:choose>
<xsl:when test="preceding-sibling::*[1][self::tei:sense]">
<tei:pc><xsl:text>; </xsl:text></tei:pc>
</xsl:when>
<xsl:when test="preceding-sibling::*[1][self::tei:form]">
<tei:pc><xsl:text> </xsl:text></tei:pc>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="parent::tei:sense and preceding-sibling::*[1][self::tei:sense]">
<tei:pc><xsl:text>, </xsl:text></tei:pc>
</xsl:when>
</xsl:choose>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:if test="@n"><xsl:value-of select="@n"/>. </xsl:if>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<!-- RELATED ENTRIES -->
<xsl:template match="tei:re">
<xsl:choose>
<xsl:when test="preceding-sibling::*[1][self::abv:formGrp]">
<tei:pc><xsl:text> </xsl:text></tei:pc>
</xsl:when>
<xsl:when test="parent::tei:sense">
<xsl:choose>
<xsl:when test="preceding-sibling::*[1][self::tei:re] or preceding-sibling::*[1][self::tei:sense] or (preceding-sibling::*[1][self::abv:tr] and child::*[1][self::tei:form])">
<tei:pc><xsl:text>; </xsl:text></tei:pc>
</xsl:when>
<xsl:when test="preceding-sibling::*[1][self::abv:tr] and child::*[1][self::tei:form]">
<tei:pc><xsl:text>: </xsl:text></tei:pc>
</xsl:when>
<xsl:when test="parent::*[abv:tr] and preceding-sibling::*[1][self::tei:note]">
<tei:pc><xsl:text>; </xsl:text></tei:pc>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="parent::tei:entry">
<xsl:choose>
<xsl:when test="preceding-sibling::*[self::tei:re and child::abv:exampleGrp]"><tei:pc><xsl:text>. — </xsl:text></tei:pc></xsl:when>
<xsl:when test="(preceding-sibling::*[1][self::tei:note] and child::*[1][self::tei:form]) or preceding-sibling::*[1][self::tei:sense or self::tei:re]"><tei:pc><xsl:text>; </xsl:text></tei:pc></xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="parent::tei:re">
<xsl:choose>
<xsl:when test="preceding-sibling::*[1][self::tei:re and child::abv:exampleGrp]">
<tei:pc><xsl:text>; </xsl:text></tei:pc>
</xsl:when>
<xsl:when test="preceding-sibling::*[1][self::tei:re]">
<tei:pc><xsl:text>, </xsl:text></tei:pc>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="preceding-sibling::*[1][self::abv:exampleGrp]">
<tei:pc><xsl:text>. — </xsl:text></tei:pc>
</xsl:when>
</xsl:choose>
<xsl:copy>
<xsl:call-template name="defaultlang"/>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<!-- BIBLIO -->
<xsl:template match="abv:example/tei:bibl">
<xsl:choose>
<xsl:when test="preceding-sibling::*[self::tei:bibl]">
<tei:pc><xsl:text>; </xsl:text></tei:pc>
</xsl:when>
<xsl:otherwise>
<tei:pc><xsl:text> (</xsl:text></tei:pc>
</xsl:otherwise>
</xsl:choose>
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
<xsl:if test="last()">
<tei:pc><xsl:text>)</xsl:text></tei:pc>
</xsl:if>
</xsl:template>
<!-- ENTRY AND ETYM PUNCTUATION -->
<xsl:template match="tei:entry[not(tei:etym)]">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy><tei:pc>.</tei:pc>
</xsl:template>
<xsl:template match="tei:etym">
<tei:pc>.</tei:pc><tei:lb/><xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<!-- QUOTE -->
<xsl:template match="tei:quote[preceding-sibling::*[1][self::tei:usg]]">
<tei:pc> </tei:pc><xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<!-- CROSSREF PUNCTUATION -->
<xsl:template match="tei:entry/tei:ref[@type='xr']">
<xsl:if test="preceding-sibling::*[1][self::tei:sense]">
<tei:pc><xsl:text>; </xsl:text></tei:pc>
</xsl:if>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:choose>
<xsl:when test="$standardize-lang = 'en'">
<xsl:text>see </xsl:text>
</xsl:when>
<xsl:when test="$standardize-lang = 'ru'">
<xsl:text>см. </xsl:text>
</xsl:when>
</xsl:choose>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

17
xsl/strip-space.xsl Normal file
View file

@ -0,0 +1,17 @@
<?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:strip-space elements="tei:entry abv:exampleGrp abv:example abv:tr tei:re tei:cit tei:sense"/>
<!-- XSLT Template to copy anything -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>