File: text.xsl

package info (click to toggle)
exult 1.12.0-2
  • links: PTS, VCS
  • area: contrib
  • in suites: forky
  • size: 43,608 kB
  • sloc: cpp: 169,917; xml: 7,400; yacc: 2,850; makefile: 2,419; java: 1,901; ansic: 1,654; lex: 673; sh: 539; objc: 416
file content (344 lines) | stat: -rw-r--r-- 10,545 bytes parent folder | download | duplicates (3)
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
<?xml version="1.0"?>
<!DOCTYPE stylesheet
[
<!ENTITY space "&#x20;">
<!ENTITY cr "&#xa;">
<!ENTITY tab "&#x9;">
]>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns="http://www.w3.org/1999/xhtml">
	<!-- FIX ME - <br> is translated but then immediately filtered out again.
	|   Furthermore, indention of list entries etc. is not done at all. We should
	|   fix this somehow, but how?
	+-->
	<xsl:strip-space elements="*" />
	<xsl:output
		method="text"
		indent="no"
		encoding="UTF-8" />
	<!-- Keys -->
	<xsl:key name="sub_ref" match="sub" use="@name" />
	<xsl:key name="section_ref" match="section" use="@title" />
	<!-- br Line Break trickery Templates
	|   Because we achieve proper formatting through using normalize-space we strip all line breaks.
	|   By changing the ones we really want to Ä first, we can change them back after normalizing
	+-->
	<xsl:template match="br">
		<xsl:text>Ä</xsl:text>
	</xsl:template>
	<!-- Faq Templates -->
	<xsl:template name="TOC">
		<xsl:for-each select="section">
			<xsl:number level="multiple"
				count="section"
				format="1. " />
			<xsl:value-of select="@title" />
			<xsl:text>&#xA;</xsl:text>
			<xsl:for-each
				select="sub">
				<xsl:number level="multiple"
					count="section|sub"
					format="1."
					value="count(ancestor::section/preceding-sibling::section)+1" />
				<xsl:number
					format="1. " />
				<xsl:apply-templates select="header" />
			</xsl:for-each>
			<xsl:text>&#xA;</xsl:text>
		</xsl:for-each>
	</xsl:template>
	<xsl:template match="faqs">
		<xsl:value-of select="@title" />
		<xsl:text> F.A.Q. (frequently asked questions)&#xA;</xsl:text>
		<xsl:text>last changed: </xsl:text>
		<xsl:value-of
			select="@changed" />
		<xsl:text>&#xA;&#xA;</xsl:text>
		<xsl:text>The latest version of this document can be found at https://exult.info/faq.php&#xA;</xsl:text>
		<xsl:text>&#xA;&#xA;</xsl:text>
		<!-- BEGIN TOC -->
		<xsl:call-template
			name="TOC" />
		<!-- END TOC -->
		<!-- BEGIN CONTENT -->
		<xsl:apply-templates select="section" />
		<!-- END CONTENT -->
	</xsl:template>
	<!-- Readme Templates -->
	<xsl:template match="readme">
		<xsl:value-of select="@title" />
		<xsl:text> Documentation&#xA;</xsl:text>
		<xsl:text>last changed: </xsl:text>
		<xsl:value-of
			select="@changed" />
		<xsl:text>&#xA;&#xA;</xsl:text>
		<xsl:text>The latest version of this document can be found at https://exult.info/docs.php&#xA;</xsl:text>
		<xsl:text>&#xA;&#xA;</xsl:text>
		<!-- BEGIN TOC -->
		<xsl:call-template
			name="TOC" />
		<!-- END TOC -->
		<!-- BEGIN CONTENT -->
		<xsl:apply-templates select="section" />
		<!-- END CONTENT -->
	</xsl:template>
	<!-- Studio Docs Templates -->
	<xsl:template match="studiodoc">
		<xsl:value-of select="@title" />
		<xsl:text> Studio Documentation&#xA;</xsl:text>
		<xsl:text>last changed: </xsl:text>
		<xsl:value-of
			select="@changed" />
		<xsl:text>&#xA;&#xA;</xsl:text>
		<xsl:text>The latest version of this document can be found at https://exult.info/studio.php&#xA;</xsl:text>
		<xsl:text>&#xA;&#xA;</xsl:text>
		<!-- BEGIN TOC -->
		<xsl:call-template
			name="TOC" />
		<!-- END TOC -->
		<!-- BEGIN CONTENT -->
		<xsl:apply-templates select="section" />
		<!-- END CONTENT -->
	</xsl:template>
	<!-- section Template -->
	<xsl:template match="section">
		<xsl:text>&#xA;</xsl:text>
		<xsl:text>--------------------------------------------------------------------------------&#xA;</xsl:text>
		<xsl:text>&#xA;</xsl:text>
		<xsl:number format="1. " />
		<xsl:value-of
			select="@title" />
		<xsl:text>&#xA;</xsl:text>
		<xsl:apply-templates select="sub" />
	</xsl:template>
	<!-- Entry Template -->
	<xsl:template match="sub">
		<xsl:variable name="num_idx">
			<xsl:number level="multiple"
				count="section|sub"
				format="1."
				value="count(ancestor::section/preceding-sibling::section)+1" />
			<xsl:number
				format="1. " />
		</xsl:variable>
		<xsl:value-of select="$num_idx" />
		<xsl:apply-templates
			select="header" />
		<xsl:text>&#xA;</xsl:text>
		<xsl:apply-templates select="body" />
		<xsl:text>&#xA;&#xA;</xsl:text>
	</xsl:template>
	<xsl:template match="header">
		<!-- In order to do proper formatting, we have to apply a little trick -
		|   we first store the result tree fragment (RTF) in a variable, then
		|   we can apply normalize-space to this variable. Nifty, hu? ;)
		|   In order to get our wanted line breaks back we translate
		|   Ä to line breaks *after* the normalization. see "br" template on top
		+-->
		<xsl:variable name="data">
			<xsl:apply-templates />
		</xsl:variable>
		<xsl:value-of
			select="translate(normalize-space($data), 'Ä', '&#xA;')" />
		<xsl:text>&#xA;</xsl:text>
	</xsl:template>
	<xsl:template match="body">
		<xsl:apply-templates />
	</xsl:template>
	<!--=========================-->
	<!-- Internal Link Templates -->
	<!--=========================-->
	<xsl:template match="ref">
		<xsl:value-of
			select="count(key('sub_ref',@target)/parent::section/preceding-sibling::section)+1" />
		<xsl:text>.</xsl:text>
		<xsl:value-of
			select="count(key('sub_ref',@target)/preceding-sibling::sub)+1" />
		<xsl:text>.</xsl:text>
	</xsl:template>
	<xsl:template match="ref1">
		<xsl:text>&#xA;</xsl:text>
		<xsl:value-of
			select="count(key('sub_ref',@target)/parent::section/preceding-sibling::section)+1" />
		<xsl:text>.</xsl:text>
		<xsl:value-of
			select="count(key('sub_ref',@target)/preceding-sibling::sub)+1" />
		<xsl:text>. </xsl:text>
		<xsl:apply-templates
			select="key('sub_ref',@target)/child::header" />
	</xsl:template>
	<xsl:template match="section_ref">
		<xsl:text>&#xA;</xsl:text>
		<xsl:value-of
			select="count(key('section_ref',@target)/preceding-sibling::section)+1" />
		<xsl:text>. </xsl:text>
		<xsl:apply-templates
			select="key('section_ref',@target)/@title" />
	</xsl:template>
	<!-- External Link Template -->
	<xsl:template match="extref">
		<xsl:choose>
			<xsl:when test="count(child::node())>0">
				<xsl:value-of select="." />
			</xsl:when>
			<xsl:when test="@doc='faq'">
				<xsl:text>FAQ.txt</xsl:text>
			</xsl:when>
			<xsl:when test="@doc='docs'">
				<xsl:text>ReadMe.txt</xsl:text>
			</xsl:when>
			<xsl:when test="@doc='studio'">
				<xsl:text>exult_studio.txt</xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="@target" />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<!--================-->
	<!-- Misc Templates -->
	<!--================-->
	<xsl:template match="para">
		<!-- Same trick as in the header template -->
		<xsl:variable name="data">
			<xsl:apply-templates />
		</xsl:variable>
		<xsl:value-of
			select="translate(normalize-space($data), 'Ä', '&#xA;')" />
		<xsl:text>&#xA;</xsl:text>
	</xsl:template>
	<xsl:template match="cite">
		<xsl:if test="position()!=1">
			<xsl:text>&#xA;</xsl:text>
		</xsl:if>
		<xsl:value-of select="@name" />
		<xsl:text>:&#xA;</xsl:text>
		<!-- Same trick as in the header template -->
		<xsl:variable
			name="data">
			<xsl:apply-templates />
		</xsl:variable>
		<xsl:value-of
			select="translate(normalize-space($data), 'Ä', '&#xA;')" />
		<xsl:text>&#xA;</xsl:text>
	</xsl:template>
	<xsl:template match="ol">
		<xsl:for-each select="li">
			<xsl:text></xsl:text>
			<xsl:number format="1. " />
			<xsl:variable name="data">
				<xsl:apply-templates />
			</xsl:variable>
			<xsl:value-of
				select="translate(normalize-space($data), 'Ä', '&#xA;')" />
			<xsl:text>&#xA;</xsl:text>
		</xsl:for-each>
		<xsl:text>&#xA;</xsl:text>
	</xsl:template>
	<xsl:template match="ul">
		<xsl:for-each select="li">
			<xsl:text>* </xsl:text>
			<xsl:variable name="data">
				<xsl:apply-templates />
			</xsl:variable>
			<xsl:value-of
				select="translate(normalize-space($data), 'Ä', '&#xA;')" />
			<xsl:text>&#xA;</xsl:text>
		</xsl:for-each>
		<xsl:text>&#xA;</xsl:text>
	</xsl:template>
	<xsl:template match="key">'<xsl:value-of select="." />'</xsl:template>
	<xsl:template match="Exult">
		<xsl:text>Exult</xsl:text>
	</xsl:template>
	<xsl:template match="Studio">
		<xsl:text>Exult Studio</xsl:text>
	</xsl:template>
	<xsl:template match="Pentagram">
		<xsl:text>Pentagram</xsl:text>
	</xsl:template>
	<xsl:template match="TM">
		<xsl:text>™&#160;</xsl:text>
	</xsl:template>
	<!--=======================-->
	<!-- Key Command Templates -->
	<!--=======================-->
	<xsl:template match="keytable">
		<table border="0" cellpadding="0" cellspacing="0" width="0">
			<tr>
				<th colspan="3" class="left-aligned">
					<xsl:text>&#xA;</xsl:text>
					<xsl:value-of select="@title" />
					<xsl:text>&#xA;</xsl:text>
				</th>
			</tr>
			<xsl:apply-templates select="keydesc" />
		</table>
	</xsl:template>
	<xsl:template match="keydesc">
		<tr>
			<td>
				<span class="highlight">
					<xsl:value-of select="@name" />
				</span>
			</td>
			<td>
				<xsl:text> : </xsl:text>
			</td>
			<td>
				<xsl:value-of select="." />
			</td>
			<xsl:text>&#xA;</xsl:text>
		</tr>
	</xsl:template>
	<!--========================-->
	<!-- Config Table Templates -->
	<!--========================-->
	<xsl:template match="configdesc">
		<table border="0" cellpadding="0" cellspacing="0">
			<xsl:apply-templates select="configtag" />
		</table>
	</xsl:template>
	<xsl:strip-space elements="configtag" />
	<xsl:template match="configtag">
		<xsl:param name="indent"></xsl:param>
		<xsl:value-of select="$indent" />
		<xsl:text>&lt;</xsl:text>
		<xsl:value-of
			select="@name" />
		<xsl:text>&gt;&cr;</xsl:text>
		<xsl:choose>
			<xsl:when test="count(child::configtag)>0">
				<xsl:apply-templates select="configtag">
					<xsl:with-param name="indent">
						<xsl:value-of select="$indent" /><xsl:text>&space;&space;</xsl:text>
					</xsl:with-param>
				</xsl:apply-templates>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$indent" />
				<xsl:value-of select="normalize-space(text())" /><xsl:text>&cr;</xsl:text>
				<xsl:apply-templates select="comment" />
			</xsl:otherwise>
		</xsl:choose>
		<xsl:if
			test="@closing-tag='yes'">
			<xsl:value-of select="$indent" />
			<xsl:text>&lt;/</xsl:text>
			<xsl:value-of select="@name" />
			<xsl:text>&gt;&cr;</xsl:text>
		</xsl:if>
	</xsl:template>
	<xsl:template match="comment"><xsl:text>&tab;&tab;&tab;&tab;</xsl:text>
		<xsl:apply-templates /><xsl:text>&cr;</xsl:text>
	</xsl:template>
	<!-- Clone template. Allows one to use any XHTML in the source file -->
	<!--
	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>
	-->
</xsl:stylesheet>