-
Notifications
You must be signed in to change notification settings - Fork 52
/
parlamint-tei2text.xsl
executable file
·44 lines (36 loc) · 1.35 KB
/
parlamint-tei2text.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
<?xml version="1.0"?>
<!-- Transform one ParlaMint file to plain text -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns="http://www.tei-c.org/ns/1.0"
exclude-result-prefixes="xsl tei"
version="2.0">
<xsl:output method="text"/>
<!-- element correspond to one line -->
<xsl:param name="element">u</xsl:param>
<xsl:template match="/">
<xsl:message select="concat('INFO: converting ', tei:TEI/@xml:id, ' to text file')"/>
<xsl:apply-templates select="//tei:*[local-name() = $element]"/>
</xsl:template>
<xsl:template match="tei:*[local-name() = $element]">
<xsl:variable name="text">
<xsl:apply-templates/>
</xsl:variable>
<xsl:value-of select="concat(@xml:id, '	',
normalize-space($text), ' ')"/>
</xsl:template>
<xsl:template match="tei:note | tei:gap | tei:vocal | tei:kinesic | tei:incident">
<xsl:variable name="text">
<xsl:value-of select="normalize-space(.)"/>
</xsl:variable>
<xsl:value-of select="concat('[[', normalize-space($text), ']]')"/>
</xsl:template>
<xsl:template match="tei:s//text()"/>
<xsl:template match="tei:w | tei:pc">
<xsl:value-of select="."/>
<xsl:if test="not(@join = 'right')">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>