-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcompos.xsl
182 lines (164 loc) · 5.03 KB
/
compos.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="/">
<html>
<head>
<title>Fallen Galaxy Fleet Compositions</title>
<link rel="stylesheet" href="compos.css" />
</head>
<body>
<xsl:for-each select="fleets/category">
<xsl:sort select="name"/>
<h1><xsl:value-of select="name" /></h1>
<xsl:for-each select="compo">
<xsl:sort select="name"/>
<div>
<!--xsl:if test="@id">
<xsl:attribute name="id"><xsl:value-of select="@id" /></xsl:attribute>
</xsl:if-->
<xsl:choose>
<xsl:when test="@faction">
<xsl:attribute name="class">
<xsl:value-of select="concat('compo ', @faction)" />
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">compo allFactions</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<h2 class="compname">
<span class="factionimage"></span>
<xsl:value-of select="name" />
<xsl:if test="@type = 'aggressive' or @type = 'defensive' or @type = 'architect' or @type = 'cargo'">
<span class="{@type}"></span>
</xsl:if>
</h2>
<xsl:if test="@min-tech or @min-pow">
<p class="minPower">
<xsl:if test="@min-tech">
<xsl:value-of select="@min-tech" />
<span class="tech"></span>
</xsl:if>
<xsl:text> </xsl:text>
<xsl:if test="@min-pow">
<xsl:value-of select="@min-pow" />
<span class="power"></span>
</xsl:if>
</p>
</xsl:if>
<xsl:if test="@faction">
<p class="faction">
<xsl:choose>
<xsl:when test="@faction = 'GalacticDiplomaticOffice'">Galactic Diplomatic Office</xsl:when>
<xsl:when test="@faction = 'AutonomousNetwork'">Autonomous Network</xsl:when>
<xsl:otherwise><xsl:value-of select="@faction" /></xsl:otherwise>
</xsl:choose>
</p>
</xsl:if>
<xsl:if test="ships">
<div class="fleet">
<xsl:apply-templates select="ships[not(@type)]/*" />
</div>
<xsl:if test="ships[@type = 'variation']">
<div class="fleet variations">
<h3>Variations</h3>
<ul>
<li class="variation selected">
<p>
<xsl:choose>
<xsl:when test="ships[not(@type)]/@title"><xsl:value-of select="ships[not(@type)]/@title"/></xsl:when>
<xsl:otherwise>Default</xsl:otherwise>
</xsl:choose>
</p>
<div class="ships">
<xsl:apply-templates select="ships[not(@type)]/*" />
</div>
</li>
<xsl:for-each select="ships[@type = 'variation']">
<li class="variation">
<p>
<xsl:choose>
<xsl:when test="@title"><xsl:value-of select="@title" /></xsl:when>
<xsl:otherwise>Variation <xsl:value-of select="position()" /></xsl:otherwise>
</xsl:choose>
</p>
<div class="ships">
<xsl:apply-templates select="*" />
</div>
</li>
</xsl:for-each>
</ul>
</div>
</xsl:if>
</xsl:if>
<xsl:if test="strength or weakness">
<div class="counters">
<h3>Counters</h3>
<xsl:if test="strength">
<div class="strongCounter">
<h4>Strong against</h4>
<ul>
<xsl:apply-templates select="strength" />
</ul>
</div>
</xsl:if>
<xsl:if test="weakness">
<div class="weakCounter">
<h4>Weak against</h4>
<ul>
<xsl:apply-templates select="weakness" />
</ul>
</div>
</xsl:if>
</div>
</xsl:if>
<xsl:if test="note">
<div class="notes">
<h4>Notes</h4>
<ul>
<xsl:for-each select="note">
<li class="note"><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>
</div>
</xsl:if>
</div>
</xsl:for-each>
</xsl:for-each>
<script type="text/javascript" src="compos.js"></script>
</body>
</html>
</xsl:template>
<xsl:template match="strength | weakness">
<li>
<a class="compo-type-link"><xsl:value-of select="." /></a>
</li>
</xsl:template>
<xsl:template match="front | back">
<div class="{name(.)}Ships ships">
<xsl:for-each select="ship">
<!--xsl:sort select="@amount"/> Do not do it! The order is important. -->
<div class="ship">
<div class="shipimage {translate(.,' ','')}"></div>
<div class="amount">
<span class="amount{@amount}">
<xsl:choose>
<xsl:when test="@amount = '0'">only</xsl:when>
<xsl:when test="@amount = '1'">lots of</xsl:when>
<xsl:when test="@amount = '2'">many</xsl:when>
<xsl:when test="@amount = '3'">some</xsl:when>
<xsl:when test="@amount = '4'">few</xsl:when>
<xsl:when test="@amount = '5'">very few</xsl:when>
<xsl:when test="@amount = '6'">one</xsl:when>
<xsl:when test="@amount = '-1'">unlimited</xsl:when>
<xsl:otherwise>???</xsl:otherwise>
</xsl:choose>
</span>
</div>
<xsl:value-of select="." />
</div>
</xsl:for-each>
</div>
</xsl:template>
</xsl:stylesheet>