Initial freepository revision of XML support documents.
[project-aon.git] / xml / xhtml-single.xsl
1 <?xml version="1.0"?>
2 <!DOCTYPE xsl:transform [
3  <!ENTITY % xhtml.characters SYSTEM "htmlchar.mod">
4  %xhtml.characters;
5 ]>
6
7 <!--
8
9 $Id$
10
11 $Log$
12 Revision 1.1  2005/01/30 01:32:52  jonathan.blake
13 Initial freepository revision of XML support documents.
14
15 Revision 1.1  2003/01/15 17:24:02  jblake
16 Initial revision - originally xhtml.xsl:
17
18 Revision 1.11  2002/12/06 22:12:04  jblake
19 Added default namespace declaration to transformation element
20 and removed all the extraneous declarations in the template
21 elements.
22
23 Revision 1.10  2002/11/17 22:37:25  jblake
24 Removed the "medium" creator entry from the templates.
25 Will they be of any use?
26
27 Revision 1.9  2002/11/17 05:06:56  jblake
28 Rearranged the title page.
29
30 Revision 1.8  2002/11/15 19:35:25  jblake
31 Fixed "Content-type" of XHTML output.
32
33 Revision 1.7  2002/11/15 00:15:39  jblake
34 Fixed a problem with the client-side image map and fixed
35 the numbered section list generation so that it will work
36 for Shadow on the Sand.
37
38 Revision 1.6  2002/10/30 05:59:45  jblake
39 Added a value for the alt attribute of the ToC image on the navigation bar.
40
41 Revision 1.5  2002/10/24 15:53:41  jblake
42 Fixed a conflict with whitespace and paragraphed lists.
43
44 Revision 1.4  2002/10/24 15:06:51  jblake
45 Added xmlns attributes to all elements that are top level in
46 their templates. This was an adjustment required by Xalan-J 2.4.
47
48 Also reinstated the comment in each document since the new
49 version of Xalan redirects it properly.
50
51 Revision 1.3  2002/10/23 05:18:29  jblake
52 Added the capability to filter which illustrators' work is used.
53 This is accomplished by the "use-illustrators" parameter.
54
55 Revision 1.2  2002/10/20 06:25:35  jblake
56 Added support for CLOSE COMBAT SKILL for Freeway Warrior books.
57
58 Revision 1.1  2002/10/15 23:29:51  jblake
59 Initial revision
60
61
62 20020327 - repurposed to be used with Xalan Java 2
63
64 Todo:
65
66 * Add blank whitespace handling to the paragraphed list template
67
68 -->
69
70 <xsl:transform version="1.0"
71   xmlns="http://www.w3.org/1999/xhtml"
72   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
73   xmlns:lxslt="http://xml.apache.org/xslt">
74
75 <xsl:output method="html"
76             encoding="ISO-8859-1"
77             omit-xml-declaration="yes"
78             doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
79             doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
80
81 <xsl:strip-space elements="gamebook section meta data ol ul dl li dd footnotes footnote illustration instance" />
82 <xsl:preserve-space elements="p choice" />
83
84 <!-- ====================== parameters ========================== -->
85
86 <xsl:param name="book-path"><xsl:text>undefined-book</xsl:text></xsl:param>
87 <xsl:param name="use-illustrators" />
88
89 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~ colors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
90
91 <xsl:param name="link-color"><xsl:text>#ff0000</xsl:text></xsl:param>
92 <xsl:param name="alink-color"><xsl:value-of select="$link-color" /></xsl:param>
93 <xsl:param name="vlink-color"><xsl:value-of select="$link-color" /></xsl:param>
94
95 <xsl:param name="text-color"><xsl:text>#000000</xsl:text></xsl:param>
96 <xsl:param name="background-color"><xsl:text>#ffffe4</xsl:text></xsl:param>
97
98 <!-- ======================= variables ========================== -->
99
100 <xsl:variable name="newline">
101 <xsl:text>
102 </xsl:text>
103 </xsl:variable>
104
105 <!-- ======================== Templates ========================= -->
106
107 <!-- ================= hierarchical sections ==================== -->
108
109 <xsl:template match="meta" />
110 <xsl:template match="section" />
111
112 <!-- ::::::::::::::::::: top-level section :::::::::::::::::::::: -->
113
114 <xsl:template match="/gamebook/section[@id='title']">
115  <html xml:lang="en-UK" lang="en-UK">
116
117   <xsl:value-of select="$newline" />
118   <xsl:value-of select="$newline" />
119
120   <head><xsl:value-of select="$newline" />
121    <title>
122     <xsl:value-of select="/gamebook/meta/title[1]" />
123    </title><xsl:value-of select="$newline" />
124    <meta http-equiv="Content-type" content="text/html; charset=ISO-8859-1" /><xsl:value-of select="$newline" />
125    <meta name="robots" content="noindex,nofollow" /><xsl:value-of select="$newline" />
126    <link rel="stylesheet" href="main.css" type="text/css" /><xsl:value-of select="$newline" />
127   </head>
128
129   <xsl:value-of select="$newline" />
130   <xsl:value-of select="$newline" />
131
132   <xsl:comment>
133    <xsl:text> </xsl:text>
134    <xsl:apply-templates select="/gamebook/meta/rights[@class='copyrights']" />
135    <xsl:text> Published by </xsl:text>
136    <xsl:value-of select="/gamebook/meta/publisher[1]" />
137    <xsl:text>. </xsl:text>
138   </xsl:comment>
139
140   <xsl:value-of select="$newline" />
141   <xsl:value-of select="$newline" />
142
143   <body>
144    <xsl:attribute name="text"><xsl:value-of select="$text-color" /></xsl:attribute>
145    <xsl:attribute name="bgcolor"><xsl:value-of select="$background-color" /></xsl:attribute>
146    <xsl:attribute name="background"><xsl:text>bckgrnd.gif</xsl:text></xsl:attribute>
147    <xsl:attribute name="link"><xsl:value-of select="$link-color" /></xsl:attribute>
148    <xsl:attribute name="alink"><xsl:value-of select="$alink-color" /></xsl:attribute>
149    <xsl:attribute name="vlink"><xsl:value-of select="$vlink-color" /></xsl:attribute>
150
151    <xsl:value-of select="$newline" />
152    <h1 id="title"><xsl:value-of select="/gamebook/meta/title[1]" /></h1><xsl:value-of select="$newline" />
153    <div id="body"><xsl:value-of select="$newline" />
154
155     <div class="frontmatter"><xsl:value-of select="$newline" />
156
157      <xsl:apply-templates select="/gamebook/meta/description[@class='blurb']" />
158      <xsl:apply-templates select="/gamebook/meta/creator[@class='long']" />
159
160      <hr />
161
162      <xsl:apply-templates select="/gamebook/meta/description[@class='publication']" />
163
164      <p>
165       <xsl:text>Publication Date: </xsl:text>
166       <xsl:value-of select="/gamebook/meta/date[@class='publication']/day" />
167       <xsl:text> </xsl:text>
168       <xsl:choose>
169        <xsl:when test="/gamebook/meta/date[@class='publication']/month = 1">
170         <xsl:text>January</xsl:text>
171        </xsl:when>
172        <xsl:when test="/gamebook/meta/date[@class='publication']/month = 2">
173         <xsl:text>February</xsl:text>
174        </xsl:when>
175        <xsl:when test="/gamebook/meta/date[@class='publication']/month = 3">
176         <xsl:text>March</xsl:text>
177        </xsl:when>
178        <xsl:when test="/gamebook/meta/date[@class='publication']/month = 4">
179         <xsl:text>April</xsl:text>
180        </xsl:when>
181        <xsl:when test="/gamebook/meta/date[@class='publication']/month = 5">
182         <xsl:text>May</xsl:text>
183        </xsl:when>
184        <xsl:when test="/gamebook/meta/date[@class='publication']/month = 6">
185         <xsl:text>June</xsl:text>
186        </xsl:when>
187        <xsl:when test="/gamebook/meta/date[@class='publication']/month = 7">
188         <xsl:text>July</xsl:text>
189        </xsl:when>
190        <xsl:when test="/gamebook/meta/date[@class='publication']/month = 8">
191         <xsl:text>August</xsl:text>
192        </xsl:when>
193        <xsl:when test="/gamebook/meta/date[@class='publication']/month = 9">
194         <xsl:text>September</xsl:text>
195        </xsl:when>
196        <xsl:when test="/gamebook/meta/date[@class='publication']/month = 10">
197         <xsl:text>October</xsl:text>
198        </xsl:when>
199        <xsl:when test="/gamebook/meta/date[@class='publication']/month = 11">
200         <xsl:text>November</xsl:text>
201        </xsl:when>
202        <xsl:when test="/gamebook/meta/date[@class='publication']/month = 12">
203         <xsl:text>December</xsl:text>
204        </xsl:when>
205        <xsl:otherwise>
206         <xsl:text>Invalid Month</xsl:text>
207        </xsl:otherwise>
208       </xsl:choose>
209       <xsl:text> </xsl:text>
210       <xsl:value-of select="/gamebook/meta/date[@class='publication']/year" />
211      </p>
212
213      <xsl:apply-templates select="/gamebook/meta/rights[@class='license-notification']" />
214      <xsl:value-of select="$newline" />
215
216      <xsl:apply-templates select="data/section[@class='frontmatter']" />
217
218     </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
219
220     <div class="mainmatter"><xsl:value-of select="$newline" />
221      <xsl:apply-templates select="/gamebook/section/data/section[@class='mainmatter']" />
222      <xsl:apply-templates select="/gamebook/section/data/section[@class='glossary']" />
223     </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
224
225     <div class="numbered"><xsl:value-of select="$newline" />
226      <xsl:apply-templates select="/gamebook/section/data/section[@class='numbered']" />
227     </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
228
229     <div class="backmatter"><xsl:value-of select="$newline" />
230      <xsl:apply-templates select="/gamebook/section/data/section[@class='backmatter']" />
231     </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
232
233     <div id="footnotes">
234      <h2>Footnotes</h2><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
235      <xsl:for-each select="//footnote">
236       <xsl:variable name="footnote-idref" select="@idref" />
237       <xsl:variable name="footnote-id" select="@id" />
238       <xsl:variable name="footnote-marker"><xsl:number count="footnotes/footnote" from="/" level="any" format="1" /></xsl:variable>
239       <xsl:for-each select="*">
240        <xsl:choose>
241         <xsl:when test="preceding-sibling::node( )">
242          <xsl:apply-templates select="." />
243         </xsl:when>
244         <xsl:otherwise>
245          <p>
246           <xsl:text>[</xsl:text>
247            <a href="#{$footnote-idref}" name="{$footnote-id}"><xsl:value-of select="$footnote-marker" /></a>
248           <xsl:text>] </xsl:text>
249           <xsl:apply-templates select="child::node()" />
250          </p>
251         </xsl:otherwise>
252        </xsl:choose>
253       </xsl:for-each>
254      </xsl:for-each>
255     </div><xsl:value-of select="$newline" />
256
257    </div><xsl:value-of select="$newline" />
258   </body>
259
260   <xsl:value-of select="$newline" />
261   <xsl:value-of select="$newline" />
262
263  </html>
264 </xsl:template>
265
266 <xsl:template match="/gamebook/section[@id='toc']" />
267
268 <!-- ::::::::::: second-level frontmatter sections :::::::::::::: -->
269
270 <xsl:template match="/gamebook/section/data/section[@class='frontmatter']">
271  <h2><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="meta/title" /></a></h2><xsl:value-of select="$newline" />
272  <xsl:value-of select="$newline" />
273  <xsl:apply-templates />
274  <xsl:value-of select="$newline" />
275 </xsl:template>
276
277 <!-- :::::::::::: third-level frontmatter sections ::::::::::::: -->
278
279 <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter' or @class='frontmatter-separate']">
280  <h3><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="meta/title" /></a></h3><xsl:value-of select="$newline" />
281  <xsl:value-of select="$newline" />
282  <xsl:apply-templates />
283  <xsl:value-of select="$newline" />
284 </xsl:template>
285
286 <!-- :::::::::::: fourth-level frontmatter sections :::::::::::: -->
287
288 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='frontmatter']">
289  <h4><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="meta/title" /></a></h4><xsl:value-of select="$newline" />
290  <xsl:value-of select="$newline" />
291  <xsl:apply-templates />
292  <xsl:value-of select="$newline" />
293 </xsl:template>
294
295 <!-- ::::::::::::: fifth-level frontmatter sections :::::::::::: -->
296
297 <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='frontmatter']">
298  <h5><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="meta/title" /></a></h5><xsl:value-of select="$newline" />
299  <xsl:value-of select="$newline" />
300  <xsl:apply-templates />
301  <xsl:value-of select="$newline" />
302 </xsl:template>
303
304 <!-- ::::::::::: second-level main matter sections :::::::::::::: -->
305
306 <xsl:template match="/gamebook/section/data/section[@class='mainmatter']">
307  <h2><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="meta/title" /></a></h2><xsl:value-of select="$newline" />
308  <xsl:value-of select="$newline" />
309  <xsl:apply-templates />
310  <xsl:value-of select="$newline" />
311 </xsl:template>
312
313 <!-- :::::::::::: third-level main matter sections ::::::::::::: -->
314
315 <xsl:template match="/gamebook/section/data/section/data/section[@class='mainmatter' or @class='mainmatter-separate']">
316  <h3><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="meta/title" /></a></h3><xsl:value-of select="$newline" />
317  <xsl:value-of select="$newline" />
318  <xsl:apply-templates />
319  <xsl:value-of select="$newline" />
320 </xsl:template>
321
322 <!-- :::::::::::: fourth-level main matter sections :::::::::::: -->
323
324 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='mainmatter']">
325  <h4><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="meta/title" /></a></h4><xsl:value-of select="$newline" />
326  <xsl:value-of select="$newline" />
327  <xsl:apply-templates />
328  <xsl:value-of select="$newline" />
329 </xsl:template>
330
331 <!-- ::::::::::::: fifth-level main matter sections :::::::::::: -->
332
333 <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='mainmatter']">
334  <h5><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="meta/title" /></a></h5><xsl:value-of select="$newline" />
335  <xsl:value-of select="$newline" />
336  <xsl:apply-templates />
337  <xsl:value-of select="$newline" />
338 </xsl:template>
339
340 <!-- :::::::::::: second-level glossary sections ::::::::::::: -->
341
342 <xsl:template match="/gamebook/section/data/section[@class='glossary']">
343  <xsl:variable name="glossary-id-prefix"><xsl:text>topics</xsl:text></xsl:variable>
344  <h2><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="meta/title" /></a></h2><xsl:value-of select="$newline" />
345  <xsl:value-of select="$newline" />
346  <xsl:apply-templates />
347  <xsl:value-of select="$newline" />
348 </xsl:template>
349
350 <!-- :::::::::::: third-level glossary sections ::::::::::::: -->
351 <!-- glossary sections should be enclosed in a second level glossary section -->
352
353 <xsl:template match="/gamebook/section/data/section/data/section[@class='glossary']">
354  <h3><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="meta/title" /></a></h3><xsl:value-of select="$newline" />
355  <xsl:call-template name="alpha-bar">
356   <xsl:with-param name="alpha-bar-id-prefix">topics</xsl:with-param>
357  </xsl:call-template>
358  <xsl:value-of select="$newline" />
359  <xsl:apply-templates />
360  <xsl:value-of select="$newline" />
361 </xsl:template>
362
363 <!-- :::::::::::::::::: numbered sections ::::::::::::::::::::::: -->
364
365 <xsl:template match="/gamebook/section/data/section[@class='numbered']">
366  <h2><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="meta/title" /></a></h2><xsl:value-of select="$newline" />
367  <xsl:value-of select="$newline" />
368  <xsl:apply-templates />
369  <xsl:value-of select="$newline" />
370 </xsl:template>
371
372 <xsl:template match="/gamebook/section/data/section/data/section[@class='numbered']">
373  <h3><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="meta/title" /></a></h3><xsl:value-of select="$newline" />
374  <xsl:value-of select="$newline" />
375  <xsl:apply-templates />
376  <xsl:value-of select="$newline" />
377 </xsl:template>
378
379 <!-- :::::::::::: second-level backmatter sections :::::::::::::: -->
380
381 <xsl:template match="/gamebook/section/data/section[@class='backmatter']">
382  <h2><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="meta/title" /></a></h2><xsl:value-of select="$newline" />
383  <xsl:value-of select="$newline" />
384  <xsl:apply-templates />
385  <xsl:value-of select="$newline" />
386 </xsl:template>
387
388 <!-- ::::::::::::: third-level back matter sections ::::::::::::: -->
389
390 <xsl:template match="/gamebook/section/data/section/data/section[@class='backmatter']">
391  <h3><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="meta/title" /></a></h3><xsl:value-of select="$newline" />
392  <xsl:value-of select="$newline" />
393  <xsl:apply-templates />
394  <xsl:value-of select="$newline" />
395 </xsl:template>
396
397 <!-- ::::::::::::: fourth-level back matter sections ::::::::::::: -->
398
399 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='backmatter']">
400  <h4><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="meta/title" /></a></h4><xsl:value-of select="$newline" />
401  <xsl:value-of select="$newline" />
402  <xsl:apply-templates />
403  <xsl:value-of select="$newline" />
404 </xsl:template>
405
406 <!-- ==================== block elements ======================== -->
407
408 <xsl:template match="p">
409  <p><xsl:apply-templates /></p>
410  <xsl:value-of select="$newline" />
411 </xsl:template>
412
413 <xsl:template match="p[@class='dedication']">
414  <p class="dedication"><xsl:apply-templates /></p>
415  <xsl:value-of select="$newline" />
416 </xsl:template>
417
418 <xsl:template match="dl[@class='paragraphed']/dd/node() | ol[@class='paragraphed']/li/node() | ul[@class='paragraphed']/li/node()">
419  <xsl:choose>
420   <xsl:when test="self::p">
421    <xsl:apply-templates /><br /><br /><xsl:value-of select="$newline" />
422   </xsl:when>
423   <xsl:when test="self::dl">
424    <dl><xsl:value-of select="$newline" />
425     <xsl:apply-templates />
426    </dl><br /><br /><xsl:value-of select="$newline" />
427   </xsl:when>
428   <xsl:when test="self::ol">
429    <ol><xsl:value-of select="$newline" />
430     <xsl:apply-templates />
431    </ol><br /><br /><xsl:value-of select="$newline" />
432   </xsl:when>
433   <xsl:when test="self::ul">
434    <ul>
435     <xsl:if test="self::*[@class='unbulleted']"><xsl:attribute name="class"><xsl:text>unbulleted</xsl:text></xsl:attribute></xsl:if>
436     <xsl:value-of select="$newline" />
437     <xsl:apply-templates />
438    </ul><br /><br /><xsl:value-of select="$newline" />
439   </xsl:when>
440   <xsl:when test="self::blockquote">
441    <blockquote><xsl:value-of select="$newline" />
442     <xsl:apply-templates />
443    </blockquote><xsl:value-of select="$newline" />
444   </xsl:when>
445   <xsl:when test="self::illustration" />
446   <xsl:otherwise>
447    <xsl:text>[error: paragraphed list template]</xsl:text>
448   </xsl:otherwise>
449  </xsl:choose>
450 </xsl:template>
451
452 <xsl:template match="ol">
453  <ol><xsl:value-of select="$newline" />
454   <xsl:apply-templates />
455  </ol><xsl:value-of select="$newline" />
456 </xsl:template>
457
458 <xsl:template match="ul">
459  <ul>
460   <xsl:if test="self::*[@class='unbulleted']"><xsl:attribute name="class"><xsl:text>unbulleted</xsl:text></xsl:attribute></xsl:if>
461   <xsl:value-of select="$newline" />
462   <xsl:apply-templates />
463  </ul><xsl:value-of select="$newline" />
464 </xsl:template>
465
466 <xsl:template match="dl">
467  <dl><xsl:value-of select="$newline" />
468   <xsl:apply-templates />
469  </dl><xsl:value-of select="$newline" />
470 </xsl:template>
471
472 <xsl:template match="dt">
473  <dt><xsl:apply-templates /></dt>
474  <xsl:value-of select="$newline" />
475 </xsl:template>
476
477 <xsl:template match="dd">
478  <dd><xsl:apply-templates /></dd>
479  <xsl:value-of select="$newline" />
480 </xsl:template>
481
482 <xsl:template match="li">
483  <li><xsl:apply-templates /></li>
484  <xsl:value-of select="$newline" />
485 </xsl:template>
486
487 <xsl:template match="table">
488  <table border="1" cellspacing="0" cellpadding="2">
489   <xsl:apply-templates />
490  </table>
491  <xsl:value-of select="$newline" />
492 </xsl:template>
493
494 <xsl:template match="tr">
495  <tr>
496   <xsl:apply-templates />
497  </tr>
498 </xsl:template>
499
500 <xsl:template match="th">
501  <th>
502   <xsl:if test="@align"><xsl:attribute name="align"><xsl:value-of select="@align" /></xsl:attribute></xsl:if>
503   <xsl:if test="@valign"><xsl:attribute name="valign"><xsl:value-of select="@valign" /></xsl:attribute></xsl:if>
504   <xsl:if test="@char"><xsl:attribute name="char"><xsl:value-of select="@char" /></xsl:attribute></xsl:if>
505   <xsl:apply-templates />
506  </th>
507 </xsl:template>
508
509 <xsl:template match="td">
510  <td>
511   <xsl:if test="@align"><xsl:attribute name="align"><xsl:value-of select="@align" /></xsl:attribute></xsl:if>
512   <xsl:if test="@valign"><xsl:attribute name="valign"><xsl:value-of select="@valign" /></xsl:attribute></xsl:if>
513   <xsl:if test="@char"><xsl:attribute name="char"><xsl:value-of select="@char" /></xsl:attribute></xsl:if>
514   <xsl:apply-templates />
515  </td>
516 </xsl:template>
517
518 <xsl:template match="combat">
519  <p class="combat">
520   <xsl:apply-templates select="enemy" />
521   <xsl:text>: </xsl:text>
522   <xsl:choose>
523    <xsl:when test="enemy-attribute[@class='combatskill']">
524     <span class="smallcaps">COMBAT<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>SKILL</span>
525     <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
526     <xsl:value-of select="enemy-attribute[@class='combatskill']" />
527    </xsl:when>
528    <xsl:when test="enemy-attribute[@class='closecombatskill']">
529     <span class="smallcaps">CLOSE<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>COMBAT<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>SKILL</span>
530     <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
531     <xsl:value-of select="enemy-attribute[@class='closecombatskill']" />
532    </xsl:when>
533   </xsl:choose>
534   <xsl:text disable-output-escaping="yes"> &amp;nbsp;&amp;nbsp;</xsl:text>
535   <span class="smallcaps">ENDURANCE</span>
536   <xsl:choose>
537    <xsl:when test="enemy-attribute[@class='target']">
538     <xsl:text> (</xsl:text><span class="smallcaps">TARGET</span><xsl:text> points)</xsl:text>
539     <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
540     <xsl:value-of select="enemy-attribute[@class='target']" />
541    </xsl:when>
542    <xsl:when test="enemy-attribute[@class='resistance']">
543     <xsl:text> (</xsl:text><span class="smallcaps">RESISTANCE</span><xsl:text> points)</xsl:text>
544     <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
545     <xsl:value-of select="enemy-attribute[@class='resistance']" />
546    </xsl:when>
547    <xsl:otherwise>
548     <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
549     <xsl:value-of select="enemy-attribute[@class='endurance']" />
550    </xsl:otherwise>
551   </xsl:choose>
552  </p>
553  <xsl:value-of select="$newline" />
554 </xsl:template>
555
556 <xsl:template match="choice">
557  <xsl:variable name="link">
558   <xsl:value-of select="@idref" />
559  </xsl:variable>
560
561  <p class="choice">
562   <xsl:for-each select="* | text()">
563    <xsl:choose>
564     <xsl:when test="self::link-text">
565      <a href="#{$link}">
566       <xsl:apply-templates />
567      </a>
568     </xsl:when>
569     <xsl:otherwise>
570      <xsl:apply-templates select="." />
571     </xsl:otherwise>
572    </xsl:choose>
573   </xsl:for-each>
574  </p>
575  <xsl:value-of select="$newline" />
576 </xsl:template>
577
578 <xsl:template match="signpost">
579  <div class="signpost">
580   <xsl:apply-templates />
581  </div>
582  <xsl:value-of select="$newline" />
583 </xsl:template>
584
585 <xsl:template match="blockquote">
586  <blockquote><xsl:value-of select="$newline" />
587   <xsl:apply-templates /><xsl:value-of select="$newline" />
588  </blockquote><xsl:value-of select="$newline" />
589 </xsl:template>
590
591 <xsl:template match="illustration" />
592
593 <xsl:template match="instance" />
594
595 <xsl:template match="footnotes" />
596
597 <xsl:template match="footnote" />
598
599 <xsl:template match="hr">
600  <hr />
601  <xsl:value-of select="$newline" />
602 </xsl:template>
603
604 <!-- ==================== inline elements ======================= -->
605
606 <xsl:template match="a">
607  <xsl:choose>
608   <xsl:when test="@href">
609    <a>
610     <xsl:attribute name="href"><xsl:value-of select="@href" /></xsl:attribute>
611     <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
612     <xsl:apply-templates />
613    </a>
614   </xsl:when>
615   <xsl:otherwise>
616    <a>
617     <xsl:if test="@idref">
618      <xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="@idref" /></xsl:attribute>
619     </xsl:if>
620     <xsl:if test="@id">
621      <xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute>
622     </xsl:if>
623     <xsl:apply-templates />
624    </a>
625   </xsl:otherwise>
626  </xsl:choose>
627 </xsl:template>
628
629 <xsl:template match="a[@class='footnote']">
630  <xsl:apply-templates />
631  <sup>
632   <a>
633    <xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="@idref" /></xsl:attribute>
634    <xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute>
635    <xsl:number count="a[@class='footnote']" from="/" level="any" format="1" />
636   </a>
637  </sup>
638 </xsl:template>
639
640 <xsl:template match="em">
641  <em><xsl:apply-templates /></em>
642 </xsl:template>
643
644 <xsl:template match="strong">
645  <strong><xsl:apply-templates /></strong>
646 </xsl:template>
647
648 <xsl:template match="thought">
649  <i><xsl:apply-templates /></i>
650 </xsl:template>
651
652 <xsl:template match="onomatopoeia">
653  <i><xsl:apply-templates /></i>
654 </xsl:template>
655
656 <xsl:template match="spell">
657  <i><xsl:apply-templates /></i>
658 </xsl:template>
659
660 <xsl:template match="item">
661  <xsl:apply-templates />
662 </xsl:template>
663
664 <xsl:template match="foreign">
665  <i><xsl:apply-templates /></i>
666 </xsl:template>
667
668 <xsl:template match="quote">
669  <xsl:text>&apos;</xsl:text>
670   <xsl:apply-templates />
671  <xsl:text>&apos;</xsl:text>
672 </xsl:template>
673
674 <xsl:template match="quote//quote">
675  <xsl:text>&quot;</xsl:text>
676   <xsl:apply-templates />
677  <xsl:text>&quot;</xsl:text>
678 </xsl:template>
679
680 <xsl:template match="cite">
681  <cite><xsl:apply-templates /></cite>
682 </xsl:template>
683
684 <xsl:template match="code">
685  <tt><xsl:apply-templates /></tt>
686 </xsl:template>
687
688 <xsl:template match="br">
689  <br />
690 </xsl:template>
691
692 <xsl:template match="typ[@class='attribute']">
693  <span class="smallcaps"><xsl:apply-templates /></span>
694 </xsl:template>
695
696 <!-- ==================== named templates ======================= -->
697
698 <xsl:template name="alpha-bar">
699  <xsl:param name="alpha-bar-id-prefix"></xsl:param>
700
701   <p class="navigation">[<a href="#{$alpha-bar-id-prefix}a">A</a>&nbsp;<a href="#{$alpha-bar-id-prefix}b">B</a>&nbsp;<a href="#{$alpha-bar-id-prefix}c">C</a>&nbsp;<a href="#{$alpha-bar-id-prefix}d">D</a>&nbsp;<a href="#{$alpha-bar-id-prefix}e">E</a>&nbsp;<a href="#{$alpha-bar-id-prefix}f">F</a>&nbsp;<a href="#{$alpha-bar-id-prefix}g">G</a>&nbsp;<a href="#{$alpha-bar-id-prefix}h">H</a>&nbsp;<a href="#{$alpha-bar-id-prefix}i">I</a>&nbsp;<a href="#{$alpha-bar-id-prefix}j">J</a>&nbsp;<a href="#{$alpha-bar-id-prefix}k">K</a>&nbsp;<a href="#{$alpha-bar-id-prefix}l">L</a>&nbsp;<a href="#{$alpha-bar-id-prefix}m">M</a>&nbsp;<a href="#{$alpha-bar-id-prefix}n">N</a>&nbsp;<a href="#{$alpha-bar-id-prefix}o">O</a>&nbsp;<a href="#{$alpha-bar-id-prefix}p">P</a>&nbsp;<a href="#{$alpha-bar-id-prefix}q">Q</a>&nbsp;<a href="#{$alpha-bar-id-prefix}r">R</a>&nbsp;<a href="#{$alpha-bar-id-prefix}s">S</a>&nbsp;<a href="#{$alpha-bar-id-prefix}t">T</a>&nbsp;<a href="#{$alpha-bar-id-prefix}u">U</a>&nbsp;<a href="#{$alpha-bar-id-prefix}v">V</a>&nbsp;<a href="#{$alpha-bar-id-prefix}w">W</a>&nbsp;<a href="#{$alpha-bar-id-prefix}x">X</a>&nbsp;<a href="#{$alpha-bar-id-prefix}y">Y</a>&nbsp;<a href="#{$alpha-bar-id-prefix}z">Z</a>]</p><xsl:value-of select="$newline" />
702
703 </xsl:template>
704
705 </xsl:transform>