Use capital letters for Special Objects
[project-aon.git] / common / xsl / xhtml-less-simple.xsl
1 <?xml version="1.0"?>
2 <!DOCTYPE xsl:transform [
3  <!ENTITY % xhtml.characters SYSTEM "../../en/xml/htmlchar.mod">
4  %xhtml.characters;
5 ]>
6
7 <!--
8
9 Todo:
10
11 * Add blank whitespace handling to the paragraphed list template
12
13 -->
14
15 <xsl:transform version="1.0"
16   xmlns="http://www.w3.org/1999/xhtml"
17   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
18   xmlns:redirect="org.apache.xalan.lib.Redirect"
19   extension-element-prefixes="redirect">
20
21 <xsl:output method="xml"
22             encoding="UTF-8"
23             omit-xml-declaration="yes"
24             doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
25             doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
26
27 <xsl:strip-space elements="section data ol ul dl li dd footnotes footnote" />
28 <xsl:preserve-space elements="p choice puzzle deadend" />
29
30 <!-- ====================== parameters ========================== -->
31
32 <xsl:param name="use-illustrators" />
33 <xsl:param name="language"><xsl:text>en</xsl:text></xsl:param>
34  
35 <!-- ======================= variables ========================== -->
36
37 <xsl:variable name="newline">
38 <xsl:text>
39 </xsl:text>
40 </xsl:variable>
41
42 <!-- ======================== Templates ========================= -->
43
44 <!-- ================= hierarchical sections ==================== -->
45
46 <xsl:template match="meta" />
47 <xsl:template match="section" />
48
49 <xsl:template match="/gamebook">
50  <html xml:lang="en-UK" lang="en-UK">
51
52   <xsl:value-of select="$newline" />
53   <xsl:value-of select="$newline" />
54
55   <head><xsl:value-of select="$newline" />
56    <title>
57     <xsl:apply-templates select="/gamebook/meta/title[1]" />
58    </title><xsl:value-of select="$newline" />
59    <meta http-equiv="Content-type" content="text/html; charset=utf-8" /><xsl:value-of select="$newline" />
60    <meta name="robots" content="noindex,nofollow" /><xsl:value-of select="$newline" />
61   </head>
62
63   <xsl:value-of select="$newline" />
64   <xsl:value-of select="$newline" />
65
66   <body>
67    <xsl:comment>
68     <xsl:text> </xsl:text>
69     <xsl:apply-templates select="/gamebook/meta/rights[@class='copyrights']" />
70     <xsl:choose>
71      <xsl:when test="$language='es'">
72       <xsl:text> Publicado por </xsl:text>
73      </xsl:when>
74      <xsl:otherwise>
75       <xsl:text> Published by </xsl:text>
76      </xsl:otherwise>
77     </xsl:choose>
78     <xsl:apply-templates select="/gamebook/meta/publisher[1]" />
79     <xsl:text>. </xsl:text>
80    </xsl:comment>
81
82    <xsl:value-of select="$newline" />
83    <xsl:value-of select="$newline" />
84
85    <h1>
86     <a name="title">
87      <xsl:apply-templates select="/gamebook/meta/title[1]" />
88     </a>
89    </h1><xsl:value-of select="$newline" />
90
91    <xsl:apply-templates/>
92
93   </body>
94  </html>
95 </xsl:template>
96
97 <!-- ::::::::::::::::::: top-level section :::::::::::::::::::::: -->
98
99 <xsl:template match="/gamebook/section[@id='title']">
100  <div class="frontmatter"><xsl:value-of select="$newline" />
101
102   <xsl:apply-templates select="/gamebook/meta/description[@class='blurb']" />
103   <xsl:apply-templates select="/gamebook/meta/creator[@class='long']" />
104
105   <hr />
106
107   <xsl:apply-templates select="/gamebook/meta/description[@class='publication']" />
108
109   <p>
110    <xsl:choose>
111     <xsl:when test="$language='es'">
112      <xsl:text>Fecha de Publicaci&oacute;n: </xsl:text>
113     </xsl:when>
114     <xsl:otherwise>
115      <xsl:text>Publication Date: </xsl:text>
116     </xsl:otherwise>
117    </xsl:choose>
118    <xsl:value-of select="/gamebook/meta/date[@class='publication']/day" />
119    <xsl:text> </xsl:text>
120    <xsl:choose>
121     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 1">
122      <xsl:choose>
123       <xsl:when test="$language='es'"><xsl:text>de enero de</xsl:text></xsl:when>
124       <xsl:otherwise><xsl:text>January</xsl:text></xsl:otherwise>
125      </xsl:choose>
126     </xsl:when>
127     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 2">
128      <xsl:choose>
129       <xsl:when test="$language='es'"><xsl:text>de febrero de</xsl:text></xsl:when>
130       <xsl:otherwise><xsl:text>February</xsl:text></xsl:otherwise>
131      </xsl:choose>
132     </xsl:when>
133     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 3">
134      <xsl:choose>
135       <xsl:when test="$language='es'"><xsl:text>de marzo de</xsl:text></xsl:when>
136       <xsl:otherwise><xsl:text>March</xsl:text></xsl:otherwise>
137      </xsl:choose>
138     </xsl:when>
139     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 4">
140      <xsl:choose>
141       <xsl:when test="$language='es'"><xsl:text>de abril de</xsl:text></xsl:when>
142       <xsl:otherwise><xsl:text>April</xsl:text></xsl:otherwise>
143      </xsl:choose>
144     </xsl:when>
145     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 5">
146      <xsl:choose>
147       <xsl:when test="$language='es'"><xsl:text>de mayo de</xsl:text></xsl:when>
148       <xsl:otherwise><xsl:text>May</xsl:text></xsl:otherwise>
149      </xsl:choose>
150     </xsl:when>
151     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 6">
152      <xsl:choose>
153       <xsl:when test="$language='es'"><xsl:text>de junio de</xsl:text></xsl:when>
154       <xsl:otherwise><xsl:text>June</xsl:text></xsl:otherwise>
155      </xsl:choose>
156     </xsl:when>
157     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 7">
158      <xsl:choose>
159       <xsl:when test="$language='es'"><xsl:text>de julio de</xsl:text></xsl:when>
160       <xsl:otherwise><xsl:text>July</xsl:text></xsl:otherwise>
161      </xsl:choose>
162     </xsl:when>
163     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 8">
164      <xsl:choose>
165       <xsl:when test="$language='es'"><xsl:text>de agosto de</xsl:text></xsl:when>
166       <xsl:otherwise><xsl:text>August</xsl:text></xsl:otherwise>
167      </xsl:choose>
168     </xsl:when>
169     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 9">
170      <xsl:choose>
171       <xsl:when test="$language='es'"><xsl:text>de septiembre de</xsl:text></xsl:when>
172       <xsl:otherwise><xsl:text>September</xsl:text></xsl:otherwise>
173      </xsl:choose>
174     </xsl:when>
175     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 10">
176      <xsl:choose>
177       <xsl:when test="$language='es'"><xsl:text>de octubre de</xsl:text></xsl:when>
178       <xsl:otherwise><xsl:text>October</xsl:text></xsl:otherwise>
179      </xsl:choose>
180     </xsl:when>
181     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 11">
182      <xsl:choose>
183       <xsl:when test="$language='es'"><xsl:text>de noviembre de</xsl:text></xsl:when>
184       <xsl:otherwise><xsl:text>November</xsl:text></xsl:otherwise>
185      </xsl:choose>
186     </xsl:when>
187     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 12">
188      <xsl:choose>
189       <xsl:when test="$language='es'"><xsl:text>de diciembre de</xsl:text></xsl:when>
190       <xsl:otherwise><xsl:text>December</xsl:text></xsl:otherwise>
191      </xsl:choose>
192     </xsl:when>
193     <xsl:otherwise>
194      <xsl:text>Invalid Month</xsl:text>
195     </xsl:otherwise>
196    </xsl:choose>
197    <xsl:text> </xsl:text>
198    <xsl:value-of select="/gamebook/meta/date[@class='publication']/year" />
199   </p>
200
201   <xsl:apply-templates select="/gamebook/meta/rights[@class='license-notification']" />
202
203   <xsl:value-of select="$newline" />
204
205   <xsl:value-of select="$newline" />
206  </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
207
208  <xsl:apply-templates />
209 </xsl:template>
210
211 <xsl:template match="/gamebook/section[@id='toc']">
212  <div class="frontmatter"><xsl:value-of select="$newline" />
213   <h2>
214    <xsl:choose>
215     <xsl:when test="$language='es'">
216      <xsl:text>&Iacute;ndice de Contenidos</xsl:text>
217     </xsl:when>
218     <xsl:otherwise>
219      <xsl:text>Table of Contents</xsl:text>
220     </xsl:otherwise>
221    </xsl:choose>
222   </h2><xsl:value-of select="$newline" />
223
224   <xsl:value-of select="$newline" />
225   <xsl:value-of select="$newline" />
226
227   <ul><xsl:value-of select="$newline" />
228    <xsl:variable name="title-page">
229     <xsl:choose>
230      <xsl:when test="$language='es'">
231       <xsl:text>P&aacute;gina Principal</xsl:text>
232      </xsl:when>
233      <xsl:otherwise>
234       <xsl:text>Title Page</xsl:text>
235      </xsl:otherwise>
236     </xsl:choose>
237    </xsl:variable>
238
239    <xsl:for-each select="/gamebook/section/data/section">
240     <li>
241      <a><xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="@id" /></xsl:attribute>
242       <xsl:apply-templates select="meta/title[1]" />
243      </a>
244      <xsl:if test="data/section[@class='frontmatter-separate' or @class='mainmatter-separate']">
245       <xsl:value-of select="$newline" />
246       <ul><xsl:value-of select="$newline" />
247        <xsl:for-each select="data/section[@class='frontmatter-separate' or @class='mainmatter-separate']">
248         <li>
249          <a><xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="@id" /></xsl:attribute>
250           <xsl:value-of select ="meta/title[1]" />
251          </a>
252         </li><xsl:value-of select="$newline" />
253        </xsl:for-each>
254       </ul><xsl:value-of select="$newline" />
255      </xsl:if>
256     </li><xsl:value-of select="$newline" />
257    </xsl:for-each>
258   </ul><xsl:value-of select="$newline" />
259
260  </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
261 </xsl:template>
262
263 <!-- ::::::::::: second-level frontmatter sections :::::::::::::: -->
264
265 <xsl:template match="/gamebook/section/data/section[@class='frontmatter']">
266  <div class="frontmatter"><xsl:value-of select="$newline" />
267   <h2><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h2>
268
269   <xsl:value-of select="$newline" />
270   <xsl:value-of select="$newline" />
271
272   <xsl:apply-templates />
273  </div>
274 </xsl:template>
275
276 <!-- :::::::::::: third-level front matter sections ::::::::::::: -->
277
278 <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter']">
279  <h3><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h3>
280
281  <xsl:value-of select="$newline" />
282  <xsl:value-of select="$newline" />
283
284  <xsl:apply-templates />
285 </xsl:template>
286
287 <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter-separate']">
288  <h3><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h3>
289
290  <xsl:value-of select="$newline" />
291  <xsl:value-of select="$newline" />
292
293  <xsl:apply-templates />
294 </xsl:template>
295
296 <!-- :::::::::::: fourth-level front matter sections :::::::::::: -->
297
298 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='frontmatter']">
299  <h4><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h4>
300
301  <xsl:value-of select="$newline" />
302  <xsl:value-of select="$newline" />
303
304  <xsl:apply-templates />
305 </xsl:template>
306
307 <!-- ::::::::::::: fifth-level front matter sections :::::::::::: -->
308
309 <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='frontmatter']">
310  <h5><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h5>
311
312  <xsl:value-of select="$newline" />
313  <xsl:value-of select="$newline" />
314
315  <xsl:apply-templates />
316 </xsl:template>
317
318 <!-- ::::::::::: second-level main matter sections :::::::::::::: -->
319
320 <xsl:template match="/gamebook/section/data/section[@class='mainmatter']">
321  <div class="mainmatter"><xsl:value-of select="$newline" />
322   <h2><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h2>
323
324   <xsl:value-of select="$newline" />
325   <xsl:value-of select="$newline" />
326
327   <xsl:apply-templates />
328  </div>
329 </xsl:template>
330
331 <!-- :::::::::::: third-level main matter sections ::::::::::::: -->
332
333 <xsl:template match="/gamebook/section/data/section/data/section[@class='mainmatter']">
334  <h3><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h3>
335
336  <xsl:value-of select="$newline" />
337  <xsl:value-of select="$newline" />
338
339  <xsl:apply-templates />
340 </xsl:template>
341
342 <xsl:template match="/gamebook/section/data/section/data/section[@class='mainmatter-separate']">
343  <h3><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h3>
344
345  <xsl:value-of select="$newline" />
346  <xsl:value-of select="$newline" />
347
348  <xsl:apply-templates />
349 </xsl:template>
350
351 <!-- :::::::::::: fourth-level main matter sections :::::::::::: -->
352
353 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='mainmatter']">
354  <h4><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h4>
355
356  <xsl:value-of select="$newline" />
357  <xsl:value-of select="$newline" />
358
359  <xsl:apply-templates />
360 </xsl:template>
361
362 <!-- ::::::::::::: fifth-level main matter sections :::::::::::: -->
363
364 <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='mainmatter']">
365  <h5><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h5>
366
367  <xsl:value-of select="$newline" />
368  <xsl:value-of select="$newline" />
369
370  <xsl:apply-templates />
371 </xsl:template>
372
373 <!-- :::::::::::::::::: numbered sections ::::::::::::::::::::::: -->
374
375 <xsl:template match="/gamebook/section/data/section[@class='numbered']">
376  <div class="numbered"><xsl:value-of select="$newline" />
377   <h2><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h2><xsl:value-of select="$newline" />
378   <xsl:value-of select="$newline" />
379
380   <xsl:apply-templates/>
381
382  </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
383 </xsl:template>
384
385 <xsl:template match="/gamebook/section/data/section/data/section[@class='numbered']">
386  <h3 align="center"><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h3><xsl:value-of select="$newline" />
387  <xsl:value-of select="$newline" />
388
389  <xsl:apply-templates />
390
391  <xsl:value-of select="$newline" />
392 </xsl:template>
393
394 <!-- :::::::::::: second-level backmatter sections :::::::::::::: -->
395
396 <xsl:template match="/gamebook/section/data/section[@class='backmatter']">
397  <div class="frontmatter"><xsl:value-of select="$newline" />
398   <h2><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h2><xsl:value-of select="$newline" />
399
400   <xsl:value-of select="$newline" />
401   <xsl:value-of select="$newline" />
402
403   <xsl:apply-templates />
404
405   <xsl:value-of select="$newline" />
406
407  </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
408 </xsl:template>
409
410 <!-- ::::::::::::: third-level back matter sections ::::::::::::: -->
411
412 <xsl:template match="/gamebook/section/data/section/data/section[@class='backmatter']">
413  <h3><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h3>
414
415  <xsl:value-of select="$newline" />
416  <xsl:value-of select="$newline" />
417
418  <xsl:apply-templates />
419 </xsl:template>
420
421 <!-- ::::::::::::: fourth-level back matter sections ::::::::::::: -->
422
423 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='backmatter']">
424  <h4><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h4>
425
426  <xsl:value-of select="$newline" />
427  <xsl:value-of select="$newline" />
428
429  <xsl:apply-templates />
430 </xsl:template>
431
432 <!-- ::::::::::::::::::::: footnotes template ::::::::::::::::::::::::: -->
433
434 <xsl:template match="id( 'footnotz' )">
435  <div class="backmatter">
436   <xsl:value-of select="$newline" />
437   <!-- No particular reason to code title here -->
438   <h2><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h2><xsl:value-of select="$newline" />
439   <xsl:value-of select="$newline" />
440   <xsl:value-of select="$newline" />
441    
442   <!-- Generate list of footnotes -->
443   <div class="footnote">
444    <xsl:for-each select="//footnotes/footnote">
445     <!-- will the list always contain the closest ancestor first? -->
446     <xsl:variable name="footnote-section"><xsl:value-of select="ancestor::section[position()=1]/@id" /></xsl:variable>
447     <xsl:variable name="footnote-marker"><xsl:number count="footnotes/footnote" from="/" level="any" format="1" /></xsl:variable>
448     <xsl:variable name="footnote-id"><xsl:value-of select="@id" /></xsl:variable>
449     <xsl:variable name="footnote-idref"><xsl:text>#</xsl:text><xsl:value-of select="@idref" /></xsl:variable>
450      
451     <xsl:for-each select="*[1]">
452      <p>
453       <xsl:text>[</xsl:text>
454       <a>
455        <xsl:attribute name="name"><xsl:value-of select="$footnote-id" /></xsl:attribute>
456        <xsl:attribute name="href"><xsl:value-of select="$footnote-idref" /></xsl:attribute>
457        <xsl:value-of select="$footnote-marker" />
458       </a>
459       <xsl:text>] </xsl:text>
460
461       <xsl:text> (</xsl:text>
462       <xsl:call-template name="section-title-link" />
463       <xsl:text>) </xsl:text>
464
465       <xsl:apply-templates select="child::* | child::text()" />
466      </p>
467     </xsl:for-each>
468      
469     <xsl:for-each select="*[position() != 1]">
470      <xsl:apply-templates select="." />
471     </xsl:for-each>
472      
473    </xsl:for-each>
474   </div>
475    
476   <!-- Backwards compatibility... needed? Probably not. -->
477   <xsl:apply-templates />
478    
479   <xsl:value-of select="$newline" />
480   
481  </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
482 </xsl:template>
483
484 <!-- ==================== block elements ======================== -->
485
486 <xsl:template match="p">
487  <p><xsl:apply-templates /></p>
488  <xsl:value-of select="$newline" />
489 </xsl:template>
490
491 <xsl:template match="p[@class='dedication']">
492  <p class="dedication"><xsl:apply-templates /></p>
493  <xsl:value-of select="$newline" />
494 </xsl:template>
495
496 <xsl:template match="dl[@class='paragraphed']/dd/node() | ol[@class='paragraphed']/li/node() | ul[@class='paragraphed']/li/node()">
497  <xsl:choose>
498   <xsl:when test="self::p">
499    <xsl:apply-templates /><br /><br /><xsl:value-of select="$newline" />
500   </xsl:when>
501   <xsl:when test="self::dl">
502    <dl><xsl:value-of select="$newline" />
503     <xsl:apply-templates />
504    </dl><br /><br /><xsl:value-of select="$newline" />
505   </xsl:when>
506   <xsl:when test="self::ol">
507    <ol><xsl:value-of select="$newline" />
508     <xsl:apply-templates />
509    </ol><br /><br /><xsl:value-of select="$newline" />
510   </xsl:when>
511   <xsl:when test="self::ul">
512    <ul>
513     <xsl:if test="self::*[@class='unbulleted']"><xsl:attribute name="class"><xsl:text>unbulleted</xsl:text></xsl:attribute></xsl:if>
514     <xsl:value-of select="$newline" />
515     <xsl:apply-templates />
516    </ul><br /><br /><xsl:value-of select="$newline" />
517   </xsl:when>
518   <xsl:when test="self::blockquote">
519    <blockquote><xsl:value-of select="$newline" />
520     <xsl:apply-templates />
521    </blockquote><xsl:value-of select="$newline" />
522   </xsl:when>
523   <xsl:when test="self::poetry">
524    <blockquote class="poetry"><xsl:value-of select="$newline" />
525     <xsl:apply-templates />
526    </blockquote><xsl:value-of select="$newline" />
527   </xsl:when>
528   <xsl:when test="self::illustration">
529    <!-- Backwards compatibility code -->
530    <xsl:if test="instance[@class='html'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
531     <xsl:call-template name="illustration-no-frame" />
532    </xsl:if>
533   </xsl:when>
534   <xsl:when test="self::illref">
535    <xsl:if test="@class='html'">
536     <xsl:for-each select="id( @idref )">
537      <xsl:apply-templates select="." />
538     </xsl:for-each>
539    </xsl:if>
540   </xsl:when>
541   <xsl:otherwise>
542    <xsl:text>[error: paragraphed list template]</xsl:text>
543    <xsl:message><xsl:text>error: paragraphed list template</xsl:text></xsl:message>
544   </xsl:otherwise>
545  </xsl:choose>
546 </xsl:template>
547
548 <xsl:template match="ol">
549  <ol><xsl:value-of select="$newline" />
550   <xsl:apply-templates />
551  </ol><xsl:value-of select="$newline" />
552 </xsl:template>
553
554 <xsl:template match="ul">
555  <ul>
556   <xsl:if test="self::*[@class='unbulleted']"><xsl:attribute name="class"><xsl:text>unbulleted</xsl:text></xsl:attribute></xsl:if>
557   <xsl:value-of select="$newline" />
558   <xsl:apply-templates />
559  </ul><xsl:value-of select="$newline" />
560 </xsl:template>
561
562 <xsl:template match="dl">
563  <dl><xsl:value-of select="$newline" />
564   <xsl:apply-templates />
565  </dl><xsl:value-of select="$newline" />
566 </xsl:template>
567
568 <xsl:template match="dt">
569  <dt><xsl:apply-templates /></dt>
570  <xsl:value-of select="$newline" />
571 </xsl:template>
572
573 <xsl:template match="dd">
574  <dd><xsl:apply-templates /></dd>
575  <xsl:value-of select="$newline" />
576 </xsl:template>
577
578 <xsl:template match="li">
579  <li><xsl:apply-templates /></li>
580  <xsl:value-of select="$newline" />
581 </xsl:template>
582
583 <xsl:template match="table">
584  <table border="1" cellspacing="0" cellpadding="2">
585   <xsl:if test="@summary"><xsl:attribute name="summary"><xsl:value-of select="@summary" /></xsl:attribute></xsl:if>
586   <xsl:apply-templates />
587  </table>
588  <xsl:value-of select="$newline" />
589 </xsl:template>
590
591 <xsl:template match="caption">
592  <caption>
593   <xsl:apply-templates />
594  </caption>
595 </xsl:template>
596
597 <xsl:template match="colgroup[@scope]">
598  <colgroup>
599   <xsl:attribute name="scope"><xsl:value-of select="@scope" /></xsl:attribute>
600  </colgroup>
601 </xsl:template>
602
603 <xsl:template match="thead">
604  <thead>
605   <xsl:apply-templates />
606  </thead>
607 </xsl:template>
608
609 <xsl:template match="tfoot">
610  <tfoot>
611   <xsl:apply-templates />
612  </tfoot>
613 </xsl:template>
614
615 <xsl:template match="tbody">
616  <tbody>
617   <xsl:apply-templates />
618  </tbody>
619 </xsl:template>
620
621 <xsl:template match="tr">
622  <tr>
623   <xsl:apply-templates />
624  </tr>
625 </xsl:template>
626
627 <xsl:template match="th">
628  <th>
629   <xsl:if test="@align"><xsl:attribute name="align"><xsl:value-of select="@align" /></xsl:attribute></xsl:if>
630   <xsl:if test="@valign"><xsl:attribute name="valign"><xsl:value-of select="@valign" /></xsl:attribute></xsl:if>
631   <xsl:if test="@char"><xsl:attribute name="char"><xsl:value-of select="@char" /></xsl:attribute></xsl:if>
632   <xsl:if test="@rowspan"><xsl:attribute name="rowspan"><xsl:value-of select="@rowspan" /></xsl:attribute></xsl:if>
633   <xsl:if test="@colspan"><xsl:attribute name="colspan"><xsl:value-of select="@colspan" /></xsl:attribute></xsl:if>
634   <xsl:if test="@axis"><xsl:attribute name="axis"><xsl:value-of select="@axis" /></xsl:attribute></xsl:if>
635   <xsl:if test="@scope"><xsl:attribute name="scope"><xsl:value-of select="@scope" /></xsl:attribute></xsl:if>
636   <xsl:apply-templates />
637  </th>
638 </xsl:template>
639
640 <xsl:template match="td">
641  <td>
642   <xsl:if test="@align"><xsl:attribute name="align"><xsl:value-of select="@align" /></xsl:attribute></xsl:if>
643   <xsl:if test="@valign"><xsl:attribute name="valign"><xsl:value-of select="@valign" /></xsl:attribute></xsl:if>
644   <xsl:if test="@char"><xsl:attribute name="char"><xsl:value-of select="@char" /></xsl:attribute></xsl:if>
645   <xsl:if test="@rowspan"><xsl:attribute name="rowspan"><xsl:value-of select="@rowspan" /></xsl:attribute></xsl:if>
646   <xsl:if test="@colspan"><xsl:attribute name="colspan"><xsl:value-of select="@colspan" /></xsl:attribute></xsl:if>
647   <xsl:if test="@axis"><xsl:attribute name="axis"><xsl:value-of select="@axis" /></xsl:attribute></xsl:if>
648   <xsl:if test="@scope"><xsl:attribute name="scope"><xsl:value-of select="@scope" /></xsl:attribute></xsl:if>
649   <xsl:apply-templates />
650  </td>
651 </xsl:template>
652
653 <xsl:template match="combat">
654  <p class="combat">
655   <xsl:apply-templates select="enemy" />
656   <xsl:text>: </xsl:text>
657   <xsl:choose>
658    <xsl:when test="enemy-attribute[@class='combatskill']">
659     <small>
660      <xsl:choose>
661       <xsl:when test="$language='es'">
662        <xsl:text>DESTREZA&nbsp;EN&nbsp;EL&nbsp;COMBATE</xsl:text>
663       </xsl:when>
664       <xsl:otherwise>
665        <xsl:text>COMBAT&nbsp;SKILL</xsl:text>
666       </xsl:otherwise>
667      </xsl:choose>
668     </small>
669     <xsl:text>&nbsp;</xsl:text>
670     <xsl:value-of select="enemy-attribute[@class='combatskill']" />
671    </xsl:when>
672    <xsl:when test="enemy-attribute[@class='closecombatskill']">
673     <small>
674      <xsl:choose>
675       <xsl:when test="$language='es'">
676        <xsl:text>CLOSE&nbsp;COMBAT&nbsp;SKILL</xsl:text>
677       </xsl:when>
678       <xsl:otherwise>
679        <xsl:text>CLOSE&nbsp;COMBAT&nbsp;SKILL</xsl:text>
680       </xsl:otherwise>
681      </xsl:choose>
682     </small>
683     <xsl:text>&nbsp;</xsl:text>
684     <xsl:value-of select="enemy-attribute[@class='closecombatskill']" />
685    </xsl:when>
686   </xsl:choose>
687   <xsl:text> &nbsp;&nbsp;</xsl:text>
688   <small>
689     <xsl:choose>
690      <xsl:when test="$language='es'">
691       <xsl:text>RESISTENCIA</xsl:text>
692      </xsl:when>
693      <xsl:otherwise>
694       <xsl:text>ENDURANCE</xsl:text>
695     </xsl:otherwise>
696    </xsl:choose>
697   </small>
698   <xsl:choose>
699    <xsl:when test="enemy-attribute[@class='target']">
700     <xsl:choose>
701      <xsl:when test="$language='es'">
702       <xsl:text> (o </xsl:text><small>BLANCOS</small><xsl:text>)</xsl:text>
703      </xsl:when>
704      <xsl:otherwise>
705       <xsl:text> (</xsl:text><small>TARGET</small><xsl:text> points)</xsl:text>
706      </xsl:otherwise>
707     </xsl:choose>
708     <xsl:text>&nbsp;</xsl:text>
709     <xsl:value-of select="enemy-attribute[@class='target']" />
710    </xsl:when>
711    <xsl:when test="enemy-attribute[@class='resistance']">
712     <xsl:choose>
713      <xsl:when test="$language='es'"></xsl:when>
714      <xsl:otherwise>
715       <xsl:text> (</xsl:text><small>RESISTANCE</small><xsl:text> points)</xsl:text>
716      </xsl:otherwise>
717     </xsl:choose>
718     <xsl:text>&nbsp;</xsl:text>
719     <xsl:value-of select="enemy-attribute[@class='resistance']" />
720    </xsl:when>
721    <xsl:otherwise>
722     <xsl:text>&nbsp;</xsl:text>
723     <xsl:value-of select="enemy-attribute[@class='endurance']" />
724    </xsl:otherwise>
725   </xsl:choose>
726  </p>
727  <xsl:value-of select="$newline" />
728 </xsl:template>
729
730 <xsl:template match="choice">
731  <xsl:variable name="link">
732   <xsl:value-of select="@idref" />
733  </xsl:variable>
734
735  <p class="choice">
736   <xsl:for-each select="* | text()">
737    <xsl:choose>
738     <xsl:when test="self::link-text">
739      <a href="#{$link}">
740       <xsl:apply-templates />
741      </a>
742     </xsl:when>
743     <xsl:otherwise>
744      <xsl:apply-templates select="." />
745     </xsl:otherwise>
746    </xsl:choose>
747   </xsl:for-each>
748  </p>
749  <xsl:value-of select="$newline" />
750 </xsl:template>
751
752 <xsl:template match="puzzle">
753  <p class="puzzle">
754   <xsl:apply-templates />
755  </p>
756  <xsl:value-of select="$newline" />
757 </xsl:template>
758
759 <xsl:template match="deadend">
760  <p class="deadend">
761   <xsl:apply-templates />
762  </p>
763  <xsl:value-of select="$newline" />
764 </xsl:template>
765
766 <xsl:template match="data/signpost">
767  <div class="signpost">
768   <xsl:apply-templates />
769  </div>
770  <xsl:value-of select="$newline" />
771 </xsl:template>
772
773 <xsl:template match="signpost">
774  <span class="signpost"><xsl:apply-templates /></span>
775 </xsl:template>
776
777 <xsl:template match="blockquote">
778  <blockquote><xsl:value-of select="$newline" />
779   <xsl:apply-templates /><xsl:value-of select="$newline" />
780  </blockquote><xsl:value-of select="$newline" />
781 </xsl:template>
782
783 <xsl:template match="poetry">
784  <blockquote class="poetry"><p><xsl:value-of select="$newline" />
785   <xsl:apply-templates /><xsl:value-of select="$newline" />
786  </p></blockquote><xsl:value-of select="$newline" />
787 </xsl:template>
788
789 <xsl:template match="illref">
790  <!-- It is important that the class is not checked right in the template - that would make this template match with higher priority, which will turn a few things upside down --> 
791  <xsl:if test="@class='html'">
792   <xsl:for-each select="id( @idref )">
793    <!-- This creates unneccessary regeneration of float illustration pages, but it is easiest to keep things this way as long as we have to be backwards compatible... -->
794    <!-- When backwards compatibility can be dropped, most of (all?) the <illustration> processing can happen here -->
795    <xsl:apply-templates select="." />
796   </xsl:for-each>
797  </xsl:if>
798 </xsl:template>
799
800 <xsl:template match="illustrations">
801  <ul class="unbulleted">
802   <xsl:for-each select="illustration[contains( $use-illustrators, concat( ':', meta/creator, ':' ) )] | illgroup">
803    <xsl:choose>
804     <xsl:when test="self::illustration and @class='float'">
805      <!-- List item with illustration name as link -->
806      <li>
807       <xsl:choose>
808        <xsl:when test="$language='es'">
809         <xsl:text>Ilustraci&oacute;n </xsl:text>
810        </xsl:when>
811        <xsl:otherwise>
812         <xsl:text>Illustration </xsl:text>
813        </xsl:otherwise>
814       </xsl:choose>
815       <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
816       <!-- List the sections that the illustration appears in -->
817       <xsl:text> (</xsl:text>
818       <xsl:for-each select="//illref[@class='html' and @idref=current()/@id]">
819        <xsl:call-template name="section-title-link" />
820        <xsl:if test="position()!=last()">
821         <xsl:text>, </xsl:text>        
822        </xsl:if>
823       </xsl:for-each>
824       <xsl:text>)</xsl:text><xsl:value-of select="$newline" />
825      </li>
826     </xsl:when>
827
828     <xsl:when test="self::illustration"> <!-- inline and map -->
829      <!-- List the sections that the illustration appears in -->     
830      <li>
831       <!-- TODO: fix this so that sections that do not represent separate XHTML files are not linked to? -->
832       <xsl:for-each select="//illref[@class='html' and @idref=current()/@id]">
833        <xsl:call-template name="section-title-link" />
834        <xsl:if test="position()!=last()">
835         <xsl:text>, </xsl:text>     
836        </xsl:if>
837       </xsl:for-each>
838      </li>
839     </xsl:when>
840
841     <xsl:when test="self::illgroup and @class!='hidden'">
842      <!-- Check if the group contains any illustrations being used, before creating the list item -->
843       <xsl:if test="count( illustration[contains( $use-illustrators, concat( ':', meta/creator, ':' ) )] ) != 0">
844        <li>
845         <a>
846          <xsl:attribute name="href"><xsl:value-of select="@idref" /><xsl:text>.htm</xsl:text></xsl:attribute>
847          <xsl:value-of select="id(@idref)/meta/title[1]" />
848         </a>
849        </li>
850       </xsl:if>
851     </xsl:when>
852    </xsl:choose>
853   </xsl:for-each>
854  </ul><xsl:value-of select="$newline" />
855 </xsl:template>
856
857 <xsl:template match="illustration">
858  <xsl:if test="instance[@class='html'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
859   <xsl:choose>
860    <xsl:when test="@class='accent'" />
861
862    <xsl:otherwise>
863     <xsl:call-template name="illustration-no-frame" />
864    </xsl:otherwise>
865   </xsl:choose>
866  </xsl:if>
867 </xsl:template>
868
869 <xsl:template match="instance" />
870
871 <xsl:template match="footnotes" />
872
873 <xsl:template match="footnote" />
874
875 <xsl:template match="hr">
876  <hr />
877  <xsl:value-of select="$newline" />
878 </xsl:template>
879
880 <xsl:template match="choose">
881  <xsl:choose>
882   <xsl:when test="@test='has-numbered-section-list'">
883    <xsl:choose>
884     <xsl:when test="when[@value='false']">
885      <xsl:apply-templates select="when[@value='false'][1]/node()" />
886     </xsl:when>
887     <xsl:when test="otherwise">
888      <!-- this should only be applied when there is no option for "false" -->
889      <xsl:apply-templates select="otherwise/node()" />
890     </xsl:when>
891    </xsl:choose>
892   </xsl:when>
893   <xsl:otherwise>
894    <xsl:message>
895     <xsl:text>choose: unrecognized test "</xsl:text>
896     <xsl:value-of select="@test" />
897     <xsl:text>" - element ignored.</xsl:text>
898    </xsl:message>
899   </xsl:otherwise>
900  </xsl:choose>
901 </xsl:template>
902
903 <!-- ==================== inline elements ======================= -->
904
905 <xsl:template match="a">
906  <xsl:choose>
907   <xsl:when test="@href">
908    <a>
909     <xsl:attribute name="href"><xsl:value-of select="@href" /></xsl:attribute>
910     <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
911     <xsl:apply-templates />
912    </a>
913   </xsl:when>
914   <xsl:otherwise>
915    <a>
916     <xsl:if test="@idref">
917      <xsl:attribute name="href">
918       <xsl:text>#</xsl:text><xsl:value-of select="@idref" />
919      </xsl:attribute>
920     </xsl:if>
921     <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
922     <xsl:apply-templates />
923    </a>
924   </xsl:otherwise>
925  </xsl:choose>
926 </xsl:template>
927
928 <!-- This template is obsolete, the "footref" element should be used instead -->
929 <xsl:template match="a[@class='footnote']">
930  <!-- <xsl:message><xsl:text>WARNING: Obsolete &lt;a idref='...' class='footnote' /&gt; usage</xsl:text></xsl:message> -->
931  <xsl:apply-templates />
932  <sup>
933   <a>
934    <xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="@idref" /></xsl:attribute>
935    <xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute>
936    <xsl:number count="a[@class='footnote']" from="/" level="any" format="1" />
937   </a>
938  </sup>
939 </xsl:template>
940
941 <!-- TODO: can this be made more uniform with illrefs? -->
942 <xsl:template match="a[@class='accent-illustration']">
943  <xsl:for-each select="id( @idref )">
944   <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
945   <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
946   <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
947   <xsl:if test="instance[@class='html'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
948    <img src="{$illustration-src}" class="accent" width="{$illustration-width}" height="{$illustration-height}" alt="" border="" align="left" />
949   </xsl:if>
950  </xsl:for-each>
951 </xsl:template>
952
953 <xsl:template match="bookref">
954  <a>
955   <xsl:attribute name="href">
956    <xsl:variable name="my-section">
957     <xsl:choose>
958      <xsl:when test="@section">
959       <xsl:value-of select="@section" />