forked from clarin-eric/ParlaMint
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparlamint-coaloppo.xsl
More file actions
executable file
·73 lines (70 loc) · 2.41 KB
/
parlamint-coaloppo.xsl
File metadata and controls
executable file
·73 lines (70 loc) · 2.41 KB
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
<?xml version="1.0"?>
<!-- Dump all coalitions/oppositions 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:output method="text"/>
<xsl:template match="text()"/>
<xsl:template match="/">
<xsl:text>Country	Role	From	To	Party IDs </xsl:text>
<xsl:for-each select="//xi:include">
<!-- We need "../" as the this XSLT is in Scripts! -->
<xsl:variable name="href" select="concat('../', @href)"/>
<xsl:variable name="country" select="replace(@href, '.+ParlaMint-([A-Z]{2}(-[A-Z0-9]{1,3})?).*', '$1')"/>
<xsl:variable name="coalition">
<xsl:apply-templates select="document($href)//tei:relation[@name = 'coalition']">
<xsl:with-param name="country" select="$country"/>
</xsl:apply-templates>
</xsl:variable>
<xsl:choose>
<xsl:when test="$coalition != ''">
<xsl:value-of select="$coalition"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($country, '	coalition	-	-	- ')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:variable name="opposition">
<xsl:apply-templates select="document($href)//tei:relation[@name = 'opposition']">
<xsl:with-param name="country" select="$country"/>
</xsl:apply-templates>
</xsl:variable>
<xsl:choose>
<xsl:when test="$opposition != ''">
<xsl:value-of select="$opposition"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($country, '	opposition	-	-	- ')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template match="tei:relation">
<xsl:param name="country"/>
<xsl:value-of select="$country"/>
<xsl:text>	</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>	</xsl:text>
<xsl:choose>
<xsl:when test="@from">
<xsl:value-of select="@from"/>
</xsl:when>
<xsl:otherwise>-</xsl:otherwise>
</xsl:choose>
<xsl:text>	</xsl:text>
<xsl:choose>
<xsl:when test="@to">
<xsl:value-of select="@to"/>
</xsl:when>
<xsl:otherwise>-</xsl:otherwise>
</xsl:choose>
<xsl:text>	</xsl:text>
<xsl:value-of select="replace(@mutual, '#', '')"/>
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>