-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathparlamint-parties.xsl
executable file
·88 lines (84 loc) · 3.45 KB
/
parlamint-parties.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?xml version="1.0"?>
<!-- Dump all politicalParties and parliamentaryGroups as TSV file -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns="http://www.tei-c.org/ns/1.0"
xmlns:et="http://nl.ijs.si/et"
exclude-result-prefixes="#all"
version="2.0">
<xsl:import href="parlamint-lib.xsl"/>
<xsl:output method="text"/>
<xsl:template match="text()"/>
<xsl:template match="/">
<xsl:text>Country	Role	ID	From	To	Abb	Name </xsl:text>
<xsl:for-each select="//xi:include">
<xsl:variable name="rootHeader">
<xsl:apply-templates mode="expand" select="document(@href)//tei:teiHeader"/>
</xsl:variable>
<!-- Get country of corpus from filename -->
<xsl:variable name="corpusCountry"
select="replace(@href,
'.+ParlaMint-([A-Z]{2}(-[A-Z0-9]{1,3})?).*',
'$1')"/>
<xsl:apply-templates select="$rootHeader//tei:particDesc//tei:org">
<xsl:with-param name="country" select="$corpusCountry"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:template>
<xsl:template match="tei:org">
<xsl:param name="country"/>
<xsl:if test="@role = 'politicalParty' or @role = 'parliamentaryGroup'">
<xsl:value-of select="$country"/>
<xsl:text>	</xsl:text>
<xsl:value-of select="@role"/>
<xsl:text>	</xsl:text>
<xsl:value-of select="@xml:id"/>
<xsl:text>	</xsl:text>
<xsl:choose>
<xsl:when test="tei:event[tei:label = 'existence']/@from">
<xsl:value-of select="tei:event[tei:label = 'existence']/@from"/>
</xsl:when>
<xsl:otherwise>-</xsl:otherwise>
</xsl:choose>
<xsl:text>	</xsl:text>
<xsl:choose>
<xsl:when test="tei:event[tei:label = 'existence']/@to">
<xsl:value-of select="tei:event[tei:label = 'existence']/@to"/>
</xsl:when>
<xsl:otherwise>-</xsl:otherwise>
</xsl:choose>
<xsl:text>	</xsl:text>
<xsl:choose>
<xsl:when test="tei:orgName[@full = 'abb']
[ancestor-or-self::tei:*[@xml:lang][1]/@xml:lang != 'en']">
<xsl:value-of select="tei:orgName[@full = 'abb']
[ancestor-or-self::tei:*[@xml:lang][1]/@xml:lang != 'en']"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="tei:orgName[@full = 'abb']"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>	</xsl:text>
<xsl:variable name="full-name">
<xsl:choose>
<xsl:when test="tei:orgName[@full = 'yes']
[ancestor-or-self::tei:*[@xml:lang][1]/@xml:lang != 'en']">
<xsl:value-of select="tei:orgName[@full = 'yes']
[ancestor-or-self::tei:*[@xml:lang][1]/@xml:lang != 'en']"/>
</xsl:when>
<xsl:when test="tei:orgName[@full = 'yes']">
<xsl:value-of select="tei:orgName[@full = 'yes']"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="tei:orgName[@full = 'abb'][1]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Some apps don't like quotes in TSV columns, simply delete -->
<xsl:value-of select="translate($full-name, '"', '')"/>
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>