-
Notifications
You must be signed in to change notification settings - Fork 0
/
xmlLangFix.xsl
50 lines (44 loc) · 1.37 KB
/
xmlLangFix.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?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"
xpath-default-namespace="http://www.tei-c.org/ns/1.0"
xmlns:e="http://distantreading.net/eltec/ns" exclude-result-prefixes="xs e" version="2.0">
<xsl:template match="/ | @* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="foreign/@xml:lang">
<xsl:attribute name="xml:lang">
<xsl:choose>
<xsl:when test="matches(.,'([A-Z][A-Z])')">
<xsl:value-of select="lower-case(.)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose></xsl:attribute>
</xsl:template>
<xsl:template match="TEI/@xml:lang">
<xsl:attribute name="xml:lang">
<xsl:choose>
<xsl:when test="contains(.,'-C')">
<xsl:value-of select="substring-before(.,'-')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:template>
<xsl:template match="language/@ident">
<xsl:attribute name="ident">
<xsl:choose>
<xsl:when test=". = 'sr'">sr-Cyrl</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>