forked from abaevdict/abaev-basex
342 lines
No EOL
14 KiB
XML
342 lines
No EOL
14 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<xsl:stylesheet xpath-default-namespace=""
|
|
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:mark">
|
|
<mark>
|
|
<xsl:apply-templates/>
|
|
</mark>
|
|
</xsl:template>
|
|
|
|
<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 href="#{$entry-id}">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-hash" viewBox="0 0 16 16">
|
|
<path d="M8.39 12.648a1 1 0 0 0-.015.18c0 .305.21.508.5.508.266 0 .492-.172.555-.477l.554-2.703h1.204c.421 0 .617-.234.617-.547 0-.312-.188-.53-.617-.53h-.985l.516-2.524h1.265c.43 0 .618-.227.618-.547 0-.313-.188-.524-.618-.524h-1.046l.476-2.304a1 1 0 0 0 .016-.164.51.51 0 0 0-.516-.516.54.54 0 0 0-.539.43l-.523 2.554H7.617l.477-2.304c.008-.04.015-.118.015-.164a.51.51 0 0 0-.523-.516.54.54 0 0 0-.531.43L6.53 5.484H5.414c-.43 0-.617.22-.617.532s.187.539.617.539h.906l-.515 2.523H4.609c-.421 0-.609.219-.609.531s.188.547.61.547h.976l-.516 2.492c-.008.04-.015.125-.015.18 0 .305.21.508.5.508.265 0 .492-.172.554-.477l.555-2.703h2.242zm-1-6.109h2.266l-.515 2.563H6.859l.532-2.563z"/>
|
|
</svg>
|
|
</a>
|
|
<xsl:if test="//tei:mentioned[@xml:lang != 'os' and not(starts-with(@xml:lang,'os-'))]">
|
|
<a class="abv-map"
|
|
hx-get="./map"
|
|
hx-target="#modal_map"
|
|
hx-swap="innerHTML"
|
|
hx-vals='{"{"}"entry": "{$entry-id}"{"}"}'
|
|
hx-on-click='document.getElementById("modal_map").showModal()'
|
|
>
|
|
<img src="/static/map.png"></img>
|
|
</a>
|
|
</xsl:if>
|
|
</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()">
|
|
<div class="abv-mainpart">
|
|
<p>
|
|
<xsl:apply-templates select="current-group()"/>
|
|
</p>
|
|
</div>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<div class="abv-etym">
|
|
<xsl:for-each-group select="node()"
|
|
group-starting-with="tei:lb">
|
|
<p>
|
|
<xsl:apply-templates select="current-group()"/>
|
|
</p>
|
|
</xsl:for-each-group>
|
|
</div>
|
|
</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">
|
|
<xsl:apply-templates />
|
|
</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: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> |