Correction to handling line elements
[project-aon.git] / xml / xhtml.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 $Id$
10
11 $Log$
12 Revision 1.15  2007/02/02 20:04:28  jonathan.blake
13 Correction to handling line elements
14
15 Revision 1.14  2006/12/20 00:15:21  jonathan.blake
16 Updated to handle the new capabilities in version 0.12.1 of the Gamebook DTD.
17
18 Revision 1.13  2006/11/25 04:47:00  jonathan.blake
19 Removal of obsolete apache namespace.
20
21 Revision 1.12  2006/06/05 23:46:46  jonathan.blake
22 Fixing the handling of titles when <ch.*/> elements are used.
23
24 Revision 1.11  2006/04/04 18:48:52  angantyr
25 Fixed paragraphed list and illref template bug.
26
27 Revision 1.10  2006/04/02 19:14:37  angantyr
28 Introduced automatic footnotes list generation and changed the illustrations
29 list generation so that links to numbered sections are titled "Section ...".
30 Backwards compatible with old XML files.
31
32 Revision 1.9  2006/03/14 21:04:03  angantyr
33 Changed the illustration handling with the introduction of 'illref's.
34 Backwards compatible.
35
36 Revision 1.8  2006/03/13 18:38:49  jonathan.blake
37 Fixed minor Spanish translation issue
38
39 Revision 1.7  2006/03/09 18:56:33  jonathan.blake
40 Added a language parameter and coding to switch between languages when the output is hard-coded into the transformation.
41
42 Revision 1.5  2006/03/02 00:33:32  jonathan.blake
43 Removed the 'book-path' parameter to work with new gbtoxhtml.pl
44
45 Revision 1.4  2005/12/27 01:51:29  angantyr
46 Added templates for the "bookref" and "footref" elements.
47
48 Revision 1.3  2005/12/05 21:29:04  jonathan.blake
49 Added the facilities to properly handle character elements.
50
51 Revision 1.2  2005/04/09 19:51:50  angantyr
52 Added handling of open-ended quotes.
53
54 Revision 1.1  2005/01/30 01:32:52  jonathan.blake
55 Initial freepository revision of XML support documents.
56
57 Revision 1.12  2003/10/07 06:05:14  Jon
58 Added capability for "accent" illustrations.
59
60 Revision 1.11  2002/12/06 22:12:04  jblake
61 Added default namespace declaration to transformation element
62 and removed all the extraneous declarations in the template
63 elements.
64
65 Revision 1.10  2002/11/17 22:37:25  jblake
66 Removed the "medium" creator entry from the templates.
67 Will they be of any use?
68
69 Revision 1.9  2002/11/17 05:06:56  jblake
70 Rearranged the title page.
71
72 Revision 1.8  2002/11/15 19:35:25  jblake
73 Fixed "Content-type" of XHTML output.
74
75 Revision 1.7  2002/11/15 00:15:39  jblake
76 Fixed a problem with the client-side image map and fixed
77 the numbered section list generation so that it will work
78 for Shadow on the Sand.
79
80 Revision 1.6  2002/10/30 05:59:45  jblake
81 Added a value for the alt attribute of the ToC image on the navigation bar.
82
83 Revision 1.5  2002/10/24 15:53:41  jblake
84 Fixed a conflict with whitespace and paragraphed lists.
85
86 Revision 1.4  2002/10/24 15:06:51  jblake
87 Added xmlns attributes to all elements that are top level in
88 their templates. This was an adjustment required by Xalan-J 2.4.
89
90 Also reinstated the comment in each document since the new
91 version of Xalan redirects it properly.
92
93 Revision 1.3  2002/10/23 05:18:29  jblake
94 Added the capability to filter which illustrators' work is used.
95 This is accomplished by the "use-illustrators" parameter.
96
97 Revision 1.2  2002/10/20 06:25:35  jblake
98 Added support for CLOSE COMBAT SKILL for Freeway Warrior books.
99
100 Revision 1.1  2002/10/15 23:29:51  jblake
101 Initial revision
102
103
104 20020327 - repurposed to be used with Xalan Java 2
105
106 Todo:
107
108 * Add blank whitespace handling to the paragraphed list template
109
110 -->
111
112 <xsl:transform version="1.0"
113   xmlns="http://www.w3.org/1999/xhtml"
114   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
115   xmlns:redirect="org.apache.xalan.lib.Redirect"
116   extension-element-prefixes="redirect">
117
118 <xsl:output method="xml"
119             encoding="ISO-8859-1"
120             omit-xml-declaration="yes"
121             doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
122             doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
123
124 <xsl:strip-space elements="section data ol ul dl li dd footnotes footnote" />
125 <xsl:preserve-space elements="p choice" />
126
127 <!-- ====================== parameters ========================== -->
128
129 <xsl:param name="use-illustrators" />
130 <xsl:param name="language"><xsl:text>en</xsl:text></xsl:param>
131  
132 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~ colors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
133
134 <xsl:param name="link-color"><xsl:text>#ff0000</xsl:text></xsl:param>
135 <xsl:param name="alink-color"><xsl:value-of select="$link-color" /></xsl:param>
136 <xsl:param name="vlink-color"><xsl:value-of select="$link-color" /></xsl:param>
137
138 <xsl:param name="text-color"><xsl:text>#000000</xsl:text></xsl:param>
139 <xsl:param name="background-color"><xsl:text>#ffffe4</xsl:text></xsl:param>
140
141 <!-- ======================= variables ========================== -->
142
143 <xsl:variable name="newline">
144 <xsl:text>
145 </xsl:text>
146 </xsl:variable>
147
148 <!-- ======================== Templates ========================= -->
149
150 <!-- ================= hierarchical sections ==================== -->
151
152 <xsl:template match="meta" />
153 <xsl:template match="section" />
154
155 <!-- ::::::::::::::::::: top-level section :::::::::::::::::::::: -->
156
157 <xsl:template match="/gamebook/section[@id='title']">
158  <xsl:call-template name="xhtml-wrapper">
159   <xsl:with-param name="document-type">top-level</xsl:with-param>
160   <xsl:with-param name="filename">title</xsl:with-param>
161  </xsl:call-template>
162
163  <xsl:apply-templates />
164 </xsl:template>
165
166 <xsl:template match="/gamebook/section[@id='toc']">
167  <xsl:call-template name="xhtml-wrapper">
168   <xsl:with-param name="document-type">toc</xsl:with-param>
169   <xsl:with-param name="filename">toc</xsl:with-param>
170  </xsl:call-template>
171
172  <xsl:apply-templates />
173 </xsl:template>
174
175 <!-- ::::::::::: second-level frontmatter sections :::::::::::::: -->
176
177 <xsl:template match="/gamebook/section/data/section[@class='frontmatter']">
178  <xsl:call-template name="xhtml-wrapper">
179   <xsl:with-param name="document-type">second-level-frontmatter</xsl:with-param>
180   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
181  </xsl:call-template>
182 </xsl:template>
183
184 <!-- :::::::::::: third-level front matter sections ::::::::::::: -->
185
186 <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter']">
187  <h3><xsl:apply-templates select="meta/title[1]" /></h3>
188
189  <xsl:value-of select="$newline" />
190  <xsl:value-of select="$newline" />
191
192  <xsl:apply-templates />
193 </xsl:template>
194
195 <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter-separate']">
196  <xsl:call-template name="xhtml-wrapper">
197   <xsl:with-param name="document-type">third-level-frontmatter-separate</xsl:with-param>
198   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
199  </xsl:call-template>
200 </xsl:template>
201
202 <!-- :::::::::::: fourth-level front matter sections :::::::::::: -->
203
204 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='frontmatter']">
205  <h4><xsl:apply-templates select="meta/title[1]" /></h4>
206
207  <xsl:value-of select="$newline" />
208  <xsl:value-of select="$newline" />
209
210  <xsl:apply-templates />
211 </xsl:template>
212
213 <!-- ::::::::::::: fifth-level front matter sections :::::::::::: -->
214
215 <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='frontmatter']">
216  <h5><xsl:apply-templates select="meta/title[1]" /></h5>
217
218  <xsl:value-of select="$newline" />
219  <xsl:value-of select="$newline" />
220
221  <xsl:apply-templates />
222 </xsl:template>
223
224 <!-- ::::::::::: second-level main matter sections :::::::::::::: -->
225
226 <xsl:template match="/gamebook/section/data/section[@class='mainmatter']">
227  <xsl:call-template name="xhtml-wrapper">
228   <xsl:with-param name="document-type">second-level-mainmatter</xsl:with-param>
229   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
230  </xsl:call-template>
231 </xsl:template>
232
233 <!-- :::::::::::: third-level main matter sections ::::::::::::: -->
234
235 <xsl:template match="/gamebook/section/data/section/data/section[@class='mainmatter']">
236  <h3><xsl:apply-templates select="meta/title[1]" /></h3>
237
238  <xsl:value-of select="$newline" />
239  <xsl:value-of select="$newline" />
240
241  <xsl:apply-templates />
242 </xsl:template>
243
244 <xsl:template match="/gamebook/section/data/section/data/section[@class='mainmatter-separate']">
245  <xsl:call-template name="xhtml-wrapper">
246   <xsl:with-param name="document-type">third-level-mainmatter-separate</xsl:with-param>
247   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
248  </xsl:call-template>
249 </xsl:template>
250
251 <!-- :::::::::::: fourth-level main matter sections :::::::::::: -->
252
253 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='mainmatter']">
254  <h4><xsl:apply-templates select="meta/title[1]" /></h4>
255
256  <xsl:value-of select="$newline" />
257  <xsl:value-of select="$newline" />
258
259  <xsl:apply-templates />
260 </xsl:template>
261
262 <!-- ::::::::::::: fifth-level main matter sections :::::::::::: -->
263
264 <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='mainmatter']">
265  <h5><xsl:apply-templates select="meta/title[1]" /></h5>
266
267  <xsl:value-of select="$newline" />
268  <xsl:value-of select="$newline" />
269
270  <xsl:apply-templates />
271 </xsl:template>
272
273 <!-- :::::::::::: second-level glossary sections ::::::::::::: -->
274
275 <xsl:template match="/gamebook/section/data/section[@class='glossary']">
276  <xsl:call-template name="xhtml-wrapper">
277   <xsl:with-param name="document-type">second-level-glossary</xsl:with-param>
278   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
279   <xsl:with-param name="glossary-id-prefix">topics</xsl:with-param>
280  </xsl:call-template>
281 </xsl:template>
282
283 <!-- :::::::::::: third-level glossary sections ::::::::::::: -->
284 <!-- glossary sections should be enclosed in a second level glossary section -->
285
286 <xsl:template match="/gamebook/section/data/section/data/section[@class='glossary']">
287  <h3><xsl:apply-templates select="meta/title[1]" /></h3>
288
289  <xsl:value-of select="$newline" />
290  <xsl:value-of select="$newline" />
291
292  <xsl:apply-templates />
293 </xsl:template>
294
295 <xsl:template match="/gamebook/section/data/section/data/section[@class='glossary-separate']">
296  <xsl:call-template name="xhtml-wrapper">
297   <xsl:with-param name="document-type">third-level-glossary-separate</xsl:with-param>
298   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
299   <xsl:with-param name="glossary-id-prefix">topics</xsl:with-param>
300  </xsl:call-template>
301 </xsl:template>
302
303 <!-- :::::::::::::::::: numbered sections ::::::::::::::::::::::: -->
304
305 <xsl:template match="/gamebook/section/data/section[@class='numbered']">
306  <xsl:call-template name="xhtml-wrapper">
307   <xsl:with-param name="document-type">second-level-numbered</xsl:with-param>
308   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
309  </xsl:call-template>
310
311  <xsl:apply-templates />
312 </xsl:template>
313
314 <xsl:template match="/gamebook/section/data/section/data/section[@class='numbered']">
315  <xsl:call-template name="xhtml-wrapper">
316   <xsl:with-param name="document-type">third-level-numbered</xsl:with-param>
317   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
318  </xsl:call-template>
319 </xsl:template>
320
321 <!-- :::::::::::: second-level backmatter sections :::::::::::::: -->
322
323 <xsl:template match="/gamebook/section/data/section[@class='backmatter']">
324  <xsl:call-template name="xhtml-wrapper">
325   <xsl:with-param name="document-type">second-level-backmatter</xsl:with-param>
326   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
327  </xsl:call-template>
328 </xsl:template>
329
330 <!-- ::::::::::::: third-level back matter sections ::::::::::::: -->
331
332 <xsl:template match="/gamebook/section/data/section/data/section[@class='backmatter']">
333  <h3><xsl:apply-templates select="meta/title[1]" /></h3>
334
335  <xsl:value-of select="$newline" />
336  <xsl:value-of select="$newline" />
337
338  <xsl:apply-templates />
339 </xsl:template>
340
341 <!-- ::::::::::::: fourth-level back matter sections ::::::::::::: -->
342
343 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='backmatter']">
344  <h4><xsl:apply-templates select="meta/title[1]" /></h4>
345
346  <xsl:value-of select="$newline" />
347  <xsl:value-of select="$newline" />
348
349  <xsl:apply-templates />
350 </xsl:template>
351
352 <!-- ::::::::::::::::::::: map template ::::::::::::::::::::::::: -->
353
354 <xsl:template match="id( 'map' )">
355  <xsl:call-template name="xhtml-wrapper">
356   <xsl:with-param name="document-type">map-adjusted</xsl:with-param>
357   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
358  </xsl:call-template>
359
360  <xsl:call-template name="xhtml-wrapper">
361   <xsl:with-param name="document-type">map</xsl:with-param>
362   <xsl:with-param name="filename"><xsl:value-of select="@id" /><xsl:text>large</xsl:text></xsl:with-param>
363  </xsl:call-template>
364 </xsl:template>
365
366 <!-- ::::::::::::::::::::: footnotes template ::::::::::::::::::::::::: -->
367
368 <xsl:template match="id( 'footnotz' )">
369  <xsl:choose>
370   <!-- Backwards compatibility measure - if there is data content, use that, otherwise generate footnotes list -->
371   <xsl:when test="count( data/p ) = 0">
372    <xsl:call-template name="xhtml-wrapper">
373     <xsl:with-param name="document-type">footnotz</xsl:with-param>
374     <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
375    </xsl:call-template>
376   </xsl:when>
377   <xsl:otherwise>
378    <xsl:call-template name="xhtml-wrapper">
379     <xsl:with-param name="document-type">second-level-backmatter</xsl:with-param>
380     <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
381    </xsl:call-template>
382   </xsl:otherwise>
383  </xsl:choose>
384  <xsl:apply-templates />
385 </xsl:template>
386
387 <!-- ==================== block elements ======================== -->
388
389 <xsl:template match="p">
390  <p><xsl:apply-templates /></p>
391  <xsl:value-of select="$newline" />
392 </xsl:template>
393
394 <xsl:template match="p[@class='dedication']">
395  <p class="dedication"><xsl:apply-templates /></p>
396  <xsl:value-of select="$newline" />
397 </xsl:template>
398
399 <xsl:template match="dl[@class='paragraphed']/dd/node() | ol[@class='paragraphed']/li/node() | ul[@class='paragraphed']/li/node()">
400  <xsl:choose>
401   <xsl:when test="self::p">
402    <xsl:apply-templates /><br /><br /><xsl:value-of select="$newline" />
403   </xsl:when>
404   <xsl:when test="self::dl">
405    <dl><xsl:value-of select="$newline" />
406     <xsl:apply-templates />
407    </dl><br /><br /><xsl:value-of select="$newline" />
408   </xsl:when>
409   <xsl:when test="self::ol">
410    <ol><xsl:value-of select="$newline" />
411     <xsl:apply-templates />
412    </ol><br /><br /><xsl:value-of select="$newline" />
413   </xsl:when>
414   <xsl:when test="self::ul">
415    <ul>
416     <xsl:if test="self::*[@class='unbulleted']"><xsl:attribute name="class"><xsl:text>unbulleted</xsl:text></xsl:attribute></xsl:if>
417     <xsl:value-of select="$newline" />
418     <xsl:apply-templates />
419    </ul><br /><br /><xsl:value-of select="$newline" />
420   </xsl:when>
421   <xsl:when test="self::blockquote">
422    <blockquote><xsl:value-of select="$newline" />
423     <xsl:apply-templates />
424    </blockquote><xsl:value-of select="$newline" />
425   </xsl:when>
426   <xsl:when test="self::illustration">
427    <!-- Backwards compatibility code -->
428    <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
429    <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
430    <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
431
432    <xsl:if test="instance[@class='html'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
433     <div class="illustration">
434      <div align="center"><xsl:value-of select="$newline" />
435      <xsl:call-template name="illustration-framed">
436       <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width" /></xsl:with-param>
437       <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height" /></xsl:with-param>
438       <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
439      </xsl:call-template>
440      <br /><xsl:value-of select="$newline" />
441     </div></div><xsl:value-of select="$newline" />
442    </xsl:if>
443   </xsl:when>
444   <xsl:when test="self::illref">
445    <xsl:if test="@class='html'">
446     <xsl:for-each select="id( @idref )">
447      <xsl:apply-templates select="." />
448     </xsl:for-each>
449    </xsl:if>
450   </xsl:when>
451   <xsl:otherwise>
452    <xsl:text>[error: paragraphed list template]</xsl:text>
453    <xsl:message><xsl:text>error: paragraphed list template</xsl:text></xsl:message>
454   </xsl:otherwise>
455  </xsl:choose>
456 </xsl:template>
457
458 <xsl:template match="ol">
459  <ol><xsl:value-of select="$newline" />
460   <xsl:apply-templates />
461  </ol><xsl:value-of select="$newline" />
462 </xsl:template>
463
464 <xsl:template match="ul">
465  <ul>
466   <xsl:if test="self::*[@class='unbulleted']"><xsl:attribute name="class"><xsl:text>unbulleted</xsl:text></xsl:attribute></xsl:if>
467   <xsl:value-of select="$newline" />
468   <xsl:apply-templates />
469  </ul><xsl:value-of select="$newline" />
470 </xsl:template>
471
472 <xsl:template match="dl">
473  <dl><xsl:value-of select="$newline" />
474   <xsl:apply-templates />
475  </dl><xsl:value-of select="$newline" />
476 </xsl:template>
477
478 <xsl:template match="dt">
479  <dt><xsl:apply-templates /></dt>
480  <xsl:value-of select="$newline" />
481 </xsl:template>
482
483 <xsl:template match="dd">
484  <dd><xsl:apply-templates /></dd>
485  <xsl:value-of select="$newline" />
486 </xsl:template>
487
488 <xsl:template match="li">
489  <li><xsl:apply-templates /></li>
490  <xsl:value-of select="$newline" />
491 </xsl:template>
492
493 <xsl:template match="table">
494  <table border="1" cellspacing="0" cellpadding="2">
495   <xsl:if test="@summary"><xsl:attribute name="summary"><xsl:value-of select="@summary" /></xsl:attribute></xsl:if>
496   <xsl:apply-templates />
497  </table>
498  <xsl:value-of select="$newline" />
499 </xsl:template>
500
501 <xsl:template match="caption">
502  <caption>
503   <xsl:apply-templates />
504  </caption>
505 </xsl:template>
506
507 <xsl:template match="colgroup[@scope]">
508  <colgroup>
509   <xsl:attribute name="scope"><xsl:value-of select="@scope" /></xsl:attribute>
510  </colgroup>
511 </xsl:template>
512
513 <xsl:template match="thead">
514  <thead>
515   <xsl:apply-templates />
516  </thead>
517 </xsl:template>
518
519 <xsl:template match="tfoot">
520  <tfoot>
521   <xsl:apply-templates />
522  </tfoot>
523 </xsl:template>
524
525 <xsl:template match="tbody">
526  <tbody>
527   <xsl:apply-templates />
528  </tbody>
529 </xsl:template>
530
531 <xsl:template match="tr">
532  <tr>
533   <xsl:apply-templates />
534  </tr>
535 </xsl:template>
536
537 <xsl:template match="th">
538  <th>
539   <xsl:if test="@align"><xsl:attribute name="align"><xsl:value-of select="@align" /></xsl:attribute></xsl:if>
540   <xsl:if test="@valign"><xsl:attribute name="valign"><xsl:value-of select="@valign" /></xsl:attribute></xsl:if>
541   <xsl:if test="@char"><xsl:attribute name="char"><xsl:value-of select="@char" /></xsl:attribute></xsl:if>
542   <xsl:if test="@rowspan"><xsl:attribute name="rowspan"><xsl:value-of select="@rowspan" /></xsl:attribute></xsl:if>
543   <xsl:if test="@colspan"><xsl:attribute name="colspan"><xsl:value-of select="@colspan" /></xsl:attribute></xsl:if>
544   <xsl:if test="@axis"><xsl:attribute name="axis"><xsl:value-of select="@axis" /></xsl:attribute></xsl:if>
545   <xsl:if test="@scope"><xsl:attribute name="scope"><xsl:value-of select="@scope" /></xsl:attribute></xsl:if>
546   <xsl:apply-templates />
547  </th>
548 </xsl:template>
549
550 <xsl:template match="td">
551  <td>
552   <xsl:if test="@align"><xsl:attribute name="align"><xsl:value-of select="@align" /></xsl:attribute></xsl:if>
553   <xsl:if test="@valign"><xsl:attribute name="valign"><xsl:value-of select="@valign" /></xsl:attribute></xsl:if>
554   <xsl:if test="@char"><xsl:attribute name="char"><xsl:value-of select="@char" /></xsl:attribute></xsl:if>
555   <xsl:if test="@rowspan"><xsl:attribute name="rowspan"><xsl:value-of select="@rowspan" /></xsl:attribute></xsl:if>
556   <xsl:if test="@colspan"><xsl:attribute name="colspan"><xsl:value-of select="@colspan" /></xsl:attribute></xsl:if>
557   <xsl:if test="@axis"><xsl:attribute name="axis"><xsl:value-of select="@axis" /></xsl:attribute></xsl:if>
558   <xsl:if test="@scope"><xsl:attribute name="scope"><xsl:value-of select="@scope" /></xsl:attribute></xsl:if>
559   <xsl:apply-templates />
560  </td>
561 </xsl:template>
562
563 <xsl:template match="combat">
564  <p class="combat">
565   <xsl:apply-templates select="enemy" />
566   <xsl:text>: </xsl:text>
567   <xsl:choose>
568    <xsl:when test="enemy-attribute[@class='combatskill']">
569     <span class="smallcaps">
570      <xsl:choose>
571       <xsl:when test="$language='es'">
572        <xsl:text>DESTREZA&nbsp;EN&nbsp;EL&nbsp;COMBATE</xsl:text>
573       </xsl:when>
574       <xsl:otherwise>
575        <xsl:text>COMBAT&nbsp;SKILL</xsl:text>
576       </xsl:otherwise>
577      </xsl:choose>
578     </span>
579     <xsl:text>&nbsp;</xsl:text>
580     <xsl:value-of select="enemy-attribute[@class='combatskill']" />
581    </xsl:when>
582    <xsl:when test="enemy-attribute[@class='closecombatskill']">
583     <span class="smallcaps">
584      <xsl:choose>
585       <xsl:when test="$language='es'">
586        <xsl:text>CLOSE&nbsp;COMBAT&nbsp;SKILL</xsl:text>
587       </xsl:when>
588       <xsl:otherwise>
589        <xsl:text>CLOSE&nbsp;COMBAT&nbsp;SKILL</xsl:text>
590       </xsl:otherwise>
591      </xsl:choose>
592     </span>
593     <xsl:text>&nbsp;</xsl:text>
594     <xsl:value-of select="enemy-attribute[@class='closecombatskill']" />
595    </xsl:when>
596   </xsl:choose>
597   <xsl:text> &nbsp;&nbsp;</xsl:text>
598   <span class="smallcaps">
599     <xsl:choose>
600      <xsl:when test="$language='es'">
601       <xsl:text>RESISTENCIA</xsl:text>
602      </xsl:when>
603      <xsl:otherwise>
604       <xsl:text>ENDURANCE</xsl:text>
605     </xsl:otherwise>
606    </xsl:choose>
607   </span>
608   <xsl:choose>
609    <xsl:when test="enemy-attribute[@class='target']">
610     <xsl:choose>
611      <xsl:when test="$language='es'">
612       <xsl:text> (o </xsl:text><span class="smallcaps">BLANCOS</span><xsl:text>)</xsl:text>
613      </xsl:when>
614      <xsl:otherwise>
615       <xsl:text> (</xsl:text><span class="smallcaps">TARGET</span><xsl:text> points)</xsl:text>
616      </xsl:otherwise>
617     </xsl:choose>
618     <xsl:text>&nbsp;</xsl:text>
619     <xsl:value-of select="enemy-attribute[@class='target']" />
620    </xsl:when>
621    <xsl:when test="enemy-attribute[@class='resistance']">
622     <xsl:choose>
623      <xsl:when test="$language='es'"></xsl:when>
624      <xsl:otherwise>
625       <xsl:text> (</xsl:text><span class="smallcaps">RESISTANCE</span><xsl:text> points)</xsl:text>
626      </xsl:otherwise>
627     </xsl:choose>
628     <xsl:text>&nbsp;</xsl:text>
629     <xsl:value-of select="enemy-attribute[@class='resistance']" />
630    </xsl:when>
631    <xsl:otherwise>
632     <xsl:text>&nbsp;</xsl:text>
633     <xsl:value-of select="enemy-attribute[@class='endurance']" />
634    </xsl:otherwise>
635   </xsl:choose>
636  </p>
637  <xsl:value-of select="$newline" />
638 </xsl:template>
639
640 <xsl:template match="choice">
641  <xsl:variable name="link">
642   <xsl:value-of select="@idref" />
643  </xsl:variable>
644
645  <p class="choice">
646   <xsl:for-each select="* | text()">
647    <xsl:choose>
648     <xsl:when test="self::link-text">
649      <a href="{$link}.htm">
650       <xsl:apply-templates />
651      </a>
652     </xsl:when>
653     <xsl:otherwise>
654      <xsl:apply-templates select="." />
655     </xsl:otherwise>
656    </xsl:choose>
657   </xsl:for-each>
658  </p>
659  <xsl:value-of select="$newline" />
660 </xsl:template>
661
662 <xsl:template match="signpost">
663  <div class="signpost">
664   <xsl:apply-templates />
665  </div>
666  <xsl:value-of select="$newline" />
667 </xsl:template>
668
669 <xsl:template match="blockquote">
670  <blockquote><xsl:value-of select="$newline" />
671   <xsl:apply-templates /><xsl:value-of select="$newline" />
672  </blockquote><xsl:value-of select="$newline" />
673 </xsl:template>
674
675 <xsl:template match="illref">
676  <!-- 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 --> 
677  <xsl:if test="@class='html'">
678   <xsl:for-each select="id( @idref )">
679    <!-- 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... -->
680    <!-- When backwards compatibility can be dropped, most of (all?) the <illustration> processing can happen here -->
681    <xsl:apply-templates select="." />
682   </xsl:for-each>
683  </xsl:if>
684 </xsl:template>
685
686 <xsl:template match="illustrations">
687  <ul class="unbulleted">
688   <xsl:for-each select="illustration[contains( $use-illustrators, concat( ':', meta/creator, ':' ) )] | illgroup">
689    <xsl:choose>
690     <xsl:when test="self::illustration and @class='float'">
691      <!-- List item with illustration name as link -->
692      <li>
693       <a>
694        <xsl:attribute name="href"><xsl:text>ill</xsl:text><xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="1" /><xsl:text>.htm</xsl:text></xsl:attribute>
695        <xsl:choose>
696         <xsl:when test="$language='es'">
697          <xsl:text>Ilustraci&oacute;n </xsl:text>
698         </xsl:when>
699         <xsl:otherwise>
700          <xsl:text>Illustration </xsl:text>
701         </xsl:otherwise>
702        </xsl:choose>
703        <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
704       </a>
705       <!-- List the sections that the illustration appears in -->
706       <xsl:text> (</xsl:text>
707       <xsl:for-each select="//illref[@class='html' and @idref=current()/@id]">
708        <xsl:call-template name="section-title-link" />
709        <xsl:if test="position()!=last()">
710         <xsl:text>, </xsl:text>        
711        </xsl:if>
712       </xsl:for-each>
713       <xsl:text>)</xsl:text><xsl:value-of select="$newline" />
714      </li>
715      <!-- Call the backwards compatible template for generating the illustration page -->
716      <xsl:call-template name="xhtml-wrapper">
717       <xsl:with-param name="document-type">illustration</xsl:with-param>
718       <xsl:with-param name="filename"><xsl:text>ill</xsl:text><xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) ) ]" from="/" level="any" format="1" /></xsl:with-param>
719      </xsl:call-template>
720     </xsl:when>
721
722     <xsl:when test="self::illustration"> <!-- inline and map -->
723      <!-- List the sections that the illustration appears in -->     
724      <li>
725       <!-- TODO: fix this so that sections that do not represent separate XHTML files are not linked to? -->
726       <xsl:for-each select="//illref[@class='html' and @idref=current()/@id]">
727        <xsl:call-template name="section-title-link" />
728        <xsl:if test="position()!=last()">
729         <xsl:text>, </xsl:text>     
730        </xsl:if>
731       </xsl:for-each>
732      </li>
733     </xsl:when>
734
735     <xsl:when test="self::illgroup and @class!='hidden'">
736      <!-- Check if the group contains any illustrations being used, before creating the list item -->
737       <xsl:if test="count( illustration[contains( $use-illustrators, concat( ':', meta/creator, ':' ) )] ) != 0">
738        <li>
739         <a>
740          <xsl:attribute name="href"><xsl:value-of select="@idref" /><xsl:text>.htm</xsl:text></xsl:attribute>
741          <xsl:value-of select="id(@idref)/meta/title[1]" />
742         </a>
743        </li>
744       </xsl:if>
745     </xsl:when>
746    </xsl:choose>
747   </xsl:for-each>
748  </ul><xsl:value-of select="$newline" />
749 </xsl:template>
750
751 <xsl:template match="illustration">
752  <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
753  <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
754  <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
755
756  <xsl:variable name="illustration-width-adjusted"><xsl:number value="$illustration-width div 2" /></xsl:variable>
757  <xsl:variable name="illustration-height-adjusted"><xsl:number value="$illustration-height div 2" /></xsl:variable>
758
759  <xsl:if test="instance[@class='html'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
760   <xsl:choose>
761    <xsl:when test="@class='float'">
762     <div class="illustration">
763      <div align="center"><xsl:value-of select="$newline" />
764      <xsl:call-template name="illustration-framed">
765       <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width-adjusted" /></xsl:with-param>
766       <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height-adjusted" /></xsl:with-param>
767       <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
768       <xsl:with-param name="illustration-href">
769        <xsl:text>ill</xsl:text><xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="1" /><xsl:text>.htm</xsl:text>
770       </xsl:with-param>
771      </xsl:call-template>
772      <br /><xsl:value-of select="$newline" />
773     </div></div><xsl:value-of select="$newline" />
774
775     <xsl:call-template name="xhtml-wrapper">
776      <xsl:with-param name="document-type">illustration</xsl:with-param>
777      <xsl:with-param name="filename"><xsl:text>ill</xsl:text><xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) ) ]" from="/" level="any" format="1" /></xsl:with-param>
778     </xsl:call-template>
779    </xsl:when>
780
781    <xsl:when test="@class='accent'" />
782
783    <xsl:otherwise>
784     <div class="illustration">
785      <div align="center"><xsl:value-of select="$newline" />
786      <xsl:call-template name="illustration-framed">
787       <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width" /></xsl:with-param>
788       <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height" /></xsl:with-param>
789       <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
790      </xsl:call-template>
791      <br /><xsl:value-of select="$newline" />
792     </div></div><xsl:value-of select="$newline" />
793    </xsl:otherwise>
794   </xsl:choose>
795  </xsl:if>
796 </xsl:template>
797
798 <xsl:template match="instance" />
799
800 <xsl:template match="footnotes" />
801
802 <xsl:template match="footnote" />
803
804 <xsl:template match="hr">
805  <hr />
806  <xsl:value-of select="$newline" />
807 </xsl:template>
808
809 <!-- ==================== inline elements ======================= -->
810
811 <xsl:template match="a">
812  <xsl:choose>
813   <xsl:when test="@href">
814    <a>
815     <xsl:attribute name="href"><xsl:value-of select="@href" /></xsl:attribute>
816     <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
817     <xsl:apply-templates />
818    </a>
819   </xsl:when>
820   <xsl:otherwise>
821    <a>
822     <xsl:if test="@idref">
823      <xsl:variable name="my-idref" select="@idref" />
824      <xsl:attribute name="href">
825       <xsl:choose>
826        <!-- The order of these tests is deliberate. They are ordered roughly from most to least specific. -->
827        <xsl:when test="/gamebook/section[@id=$my-idref] | /gamebook/section/data/section[@id=$my-idref]">
828         <xsl:value-of select="$my-idref" /><xsl:text>.htm</xsl:text>
829        </xsl:when>
830        <xsl:when test="/gamebook/section/data/section/data/section[@class='frontmatter-separate' and @id=$my-idref]">
831         <xsl:value-of select="$my-idref" /><xsl:text>.htm</xsl:text>
832        </xsl:when>
833        <xsl:when test="/gamebook/section/data/section/data/section[@class='mainmatter-separate' and @id=$my-idref]">
834         <xsl:value-of select="$my-idref" /><xsl:text>.htm</xsl:text>
835        </xsl:when>
836        <xsl:when test="/gamebook/section/data/section/data/section[@class='numbered' and @id=$my-idref]">
837         <xsl:value-of select="$my-idref" /><xsl:text>.htm</xsl:text>
838        </xsl:when>
839        <xsl:when test="/gamebook/section/data/section/data/section[@class='glossary-separate' and @id=$my-idref]">
840         <xsl:value-of select="$my-idref" /><xsl:text>.htm</xsl:text>
841        </xsl:when>
842        <xsl:when test="/gamebook/section/data/section/data/section[@class='frontmatter-separate' and descendant::*[@id=$my-idref]]">
843         <xsl:value-of select="/gamebook/section/data/section/data/section[@class='frontmatter-separate' and descendant::*[@id=$my-idref]]/@id" /><xsl:text>.htm#</xsl:text><xsl:value-of select="$my-idref" />
844        </xsl:when>
845        <xsl:when test="/gamebook/section/data/section/data/section[@class='mainmatter-separate' and descendant::*[@id=$my-idref]]">
846         <xsl:value-of select="/gamebook/section/data/section/data/section[@class='mainmatter-separate' and descendant::*[@id=$my-idref]]/@id" /><xsl:text>.htm#</xsl:text><xsl:value-of select="$my-idref" />
847        </xsl:when>
848        <xsl:when test="/gamebook/section/data/section/data/section[@class='glossary-separate' and descendant::*[@id=$my-idref]]">
849         <xsl:value-of select="/gamebook/section/data/section/data/section[@class='glossary-separate' and descendant::*[@id=$my-idref]]/@id" /><xsl:text>.htm#</xsl:text><xsl:value-of select="$my-idref" />
850        </xsl:when>
851        <xsl:when test="/gamebook/section/data/section[descendant::*[@id=$my-idref]]">
852         <xsl:value-of select="/gamebook/section/data/section[descendant::*[@id=$my-idref]]/@id" /><xsl:text>.htm#</xsl:text><xsl:value-of select="$my-idref" />
853        </xsl:when>
854        <xsl:otherwise>
855         <xsl:text>[error: a template]</xsl:text>
856         <xsl:message><xsl:text>error: a template</xsl:text></xsl:message>
857        </xsl:otherwise>
858       </xsl:choose>
859      </xsl:attribute>
860     </xsl:if>
861     <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
862     <xsl:apply-templates />
863    </a>
864   </xsl:otherwise>
865  </xsl:choose>
866 </xsl:template>
867
868 <!-- This template is obsolete, the "footref" element should be used instead -->
869 <xsl:template match="a[@class='footnote']">
870  <!-- <xsl:message><xsl:text>WARNING: Obsolete &lt;a idref='...' class='footnote' /&gt; usage</xsl:text></xsl:message> -->
871  <xsl:apply-templates />
872  <sup>
873   <a>
874    <xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="@idref" /></xsl:attribute>
875    <xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute>
876    <xsl:number count="a[@class='footnote']" from="/" level="any" format="1" />
877   </a>
878  </sup>
879 </xsl:template>
880
881 <!-- TODO: can this be made more uniform with illrefs? -->
882 <xsl:template match="a[@class='accent-illustration']">
883  <xsl:for-each select="id( @idref )">
884   <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
885   <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
886   <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
887   <xsl:if test="instance[@class='html'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
888    <img src="{$illustration-src}" class="accent" width="{$illustration-width}" height="{$illustration-height}" alt="" border="" align="left" />
889   </xsl:if>
890  </xsl:for-each>
891 </xsl:template>
892
893 <xsl:template match="bookref">
894  <a>
895   <xsl:attribute name="href">
896    <xsl:variable name="my-section">
897     <xsl:choose>
898      <xsl:when test="@section">
899       <xsl:value-of select="@section" />
900      </xsl:when>
901      <xsl:otherwise>
902       <xsl:text>title</xsl:text>
903      </xsl:otherwise>
904     </xsl:choose>
905    </xsl:variable>
906    <xsl:variable name="my-series">
907     <!-- If series is specified, go one directory back and then to series. Otherwise, add nothing. -->
908     <xsl:choose>
909      <xsl:when test="@series">
910       <xsl:text>/../</xsl:text><xsl:value-of select="@series" />
911      </xsl:when>
912      <xsl:otherwise>
913       <xsl:text></xsl:text>
914      </xsl:otherwise>
915     </xsl:choose>
916    </xsl:variable>
917    <xsl:text>..</xsl:text><xsl:value-of select="$my-series" /><xsl:text>/</xsl:text><xsl:value-of select="@book" /><xsl:text>/</xsl:text><xsl:value-of select="$my-section" /><xsl:text>.htm</xsl:text>
918   </xsl:attribute>
919   <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
920   <xsl:apply-templates />
921  </a>
922 </xsl:template>
923
924 <xsl:template match="footref">
925  <xsl:apply-templates />
926  <sup>
927   <a>
928    <xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="@idref" /></xsl:attribute>
929    <xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute>
930    <xsl:number count="footref" from="/" level="any" format="1" />
931   </a>
932  </sup>
933 </xsl:template>
934
935 <xsl:template match="em">
936  <em><xsl:apply-templates /></em>
937 </xsl:template>
938
939 <xsl:template match="strong">
940  <strong><xsl:apply-templates /></strong>
941 </xsl:template>
942
943 <xsl:template match="thought">
944  <i><xsl:apply-templates /></i>
945 </xsl:template>
946
947 <xsl:template match="onomatopoeia">
948  <i><xsl:apply-templates /></i>
949 </xsl:template>
950
951 <xsl:template match="spell">
952  <i><xsl:apply-templates /></i>
953 </xsl:template>
954
955 <xsl:template match="item">
956  <xsl:apply-templates />
957 </xsl:template>
958
959 <xsl:template match="foreign">
960  <i><xsl:apply-templates /></i>
961 </xsl:template>
962
963 <xsl:template match="quote">
964  <xsl:text>&apos;</xsl:text>
965   <xsl:apply-templates />
966  <xsl:if test="not(self::*[@class='open-ended'])"><xsl:text>&apos;</xsl:text></xsl:if>
967 </xsl:template>
968
969 <xsl:template match="quote//quote">
970  <xsl:text>&quot;</xsl:text>
971   <xsl:apply-templates />
972  <xsl:if test="not(self::*[@class='open-ended'])"><xsl:text>&quot;</xsl:text></xsl:if>
973 </xsl:template>
974
975 <xsl:template match="cite">
976  <cite><xsl:apply-templates /></cite>
977 </xsl:template>
978
979 <xsl:template match="code">
980  <tt><xsl:apply-templates /></tt>
981 </xsl:template>
982
983 <xsl:template match="line">
984  <xsl:apply-templates />
985  <xsl:if test="position( ) != last( )"><br /></xsl:if>
986 </xsl:template>
987
988 <xsl:template match="br">
989  <br />
990 </xsl:template>
991
992 <xsl:template match="typ[@class='attribute']">
993  <span class="smallcaps"><xsl:apply-templates /></span>
994 </xsl:template>
995
996 <!-- ==================== character elements ==================== -->
997 <!--
998
999 These templates define the mapping between the character elements used in
1000 the Project Aon instances of Gamebook XML and the ISO-8859-1
1001 characters.
1002
1003 Portions Copyright International Organization for Standardization 1986 
1004 Permission to copy in any form is granted for use with conforming SGML 
1005 systems and applications as defined in ISO 8879, provided this notice 
1006 is included in all copies.
1007
1008 -->
1009
1010 <xsl:template match="ch.apos"><xsl:text>&#39;</xsl:text></xsl:template><!-- apostrophe = single quotation mark -->
1011 <xsl:template match="ch.nbsp"><xsl:text>&#160;</xsl:text></xsl:template><!-- no-break space = non-breaking space, U+00A0 ISOnum -->
1012 <xsl:template match="ch.iexcl"><xsl:text>&#161;</xsl:text></xsl:template><!-- inverted exclamation mark, U+00A1 ISOnum -->
1013 <xsl:template match="ch.cent"><xsl:text>&#162;</xsl:text></xsl:template><!-- cent sign, U+00A2 ISOnum -->
1014 <xsl:template match="ch.pound"><xsl:text>&#163;</xsl:text></xsl:template><!-- pound sign, U+00A3 ISOnum -->
1015 <xsl:template match="ch.curren"><xsl:text>&#164;</xsl:text></xsl:template><!-- currency sign, U+00A4 ISOnum -->
1016 <xsl:template match="ch.yen"><xsl:text>&#165;</xsl:text></xsl:template><!-- yen sign = yuan sign, U+00A5 ISOnum -->
1017 <xsl:template match="ch.brvbar"><xsl:text>&#166;</xsl:text></xsl:template><!-- broken bar = broken vertical bar, U+00A6 ISOnum -->
1018 <xsl:template match="ch.sect"><xsl:text>&#167;</xsl:text></xsl:template><!-- section sign, U+00A7 ISOnum -->
1019 <xsl:template match="ch.uml"><xsl:text>&#168;</xsl:text></xsl:template><!-- diaeresis = spacing diaeresis, U+00A8 ISOdia -->
1020 <xsl:template match="ch.copy"><xsl:text>&#169;</xsl:text></xsl:template><!-- copyright sign, U+00A9 ISOnum -->
1021 <xsl:template match="ch.ordf"><xsl:text>&#170;</xsl:text></xsl:template><!-- feminine ordinal indicator, U+00AA ISOnum -->
1022 <xsl:template match="ch.laquo"><xsl:text>&#171;</xsl:text></xsl:template><!-- left-pointing double angle quotation mark = left pointing guillemet, U+00AB ISOnum -->
1023 <xsl:template match="ch.not"><xsl:text>&#172;</xsl:text></xsl:template><!-- not sign, U+00AC ISOnum -->
1024 <xsl:template match="ch.shy"><xsl:text>&#173;</xsl:text></xsl:template><!-- soft hyphen = discretionary hyphen, U+00AD ISOnum -->
1025 <xsl:template match="ch.reg"><xsl:text>&#174;</xsl:text></xsl:template><!-- registered sign = registered trade mark sign, U+00AE ISOnum -->
1026 <xsl:template match="ch.macr"><xsl:text>&#175;</xsl:text></xsl:template><!-- macron = spacing macron = overline = APL overbar, U+00AF ISOdia -->
1027 <xsl:template match="ch.deg"><xsl:text>&#176;</xsl:text></xsl:template><!-- degree sign, U+00B0 ISOnum -->
1028 <xsl:template match="ch.plusmn"><xsl:text>&#177;</xsl:text></xsl:template><!-- plus-minus sign = plus-or-minus sign, U+00B1 ISOnum -->
1029 <xsl:template match="ch.sup2"><xsl:text>&#178;</xsl:text></xsl:template><!-- superscript two = superscript digit two = squared, U+00B2 ISOnum -->
1030 <xsl:template match="ch.sup3"><xsl:text>&#179;</xsl:text></xsl:template><!-- superscript three = superscript digit three = cubed, U+00B3 ISOnum -->
1031 <xsl:template match="ch.acute"><xsl:text>&#180;</xsl:text></xsl:template><!-- acute accent = spacing acute, U+00B4 ISOdia -->
1032 <xsl:template match="ch.micro"><xsl:text>&#181;</xsl:text></xsl:template><!-- micro sign, U+00B5 ISOnum -->
1033 <xsl:template match="ch.para"><xsl:text>&#182;</xsl:text></xsl:template><!-- pilcrow sign  = paragraph sign, U+00B6 ISOnum -->
1034 <xsl:template match="ch.middot"><xsl:text>&#183;</xsl:text></xsl:template><!-- middle dot = Georgian comma = Greek middle dot, U+00B7 ISOnum -->
1035 <xsl:template match="ch.cedil"><xsl:text>&#184;</xsl:text></xsl:template><!-- cedilla = spacing cedilla, U+00B8 ISOdia -->
1036 <xsl:template match="ch.sup1"><xsl:text>&#185;</xsl:text></xsl:template><!-- superscript one = superscript digit one, U+00B9 ISOnum -->
1037 <xsl:template match="ch.ordm"><xsl:text>&#186;</xsl:text></xsl:template><!-- masculine ordinal indicator, U+00BA ISOnum -->
1038 <xsl:template match="ch.raquo"><xsl:text>&#187;</xsl:text></xsl:template><!-- right-pointing double angle quotation mark = right pointing guillemet, U+00BB ISOnum -->
1039 <xsl:template match="ch.frac14"><xsl:text>&#188;</xsl:text></xsl:template><!-- vulgar fraction one quarter = fraction one quarter, U+00BC ISOnum -->
1040 <xsl:template match="ch.frac12"><xsl:text>&#189;</xsl:text></xsl:template><!-- vulgar fraction one half = fraction one half, U+00BD ISOnum -->
1041 <xsl:template match="ch.frac34"><xsl:text>&#190;</xsl:text></xsl:template><!-- vulgar fraction three quarters = fraction three quarters, U+00BE ISOnum -->
1042 <xsl:template match="ch.iquest"><xsl:text>&#191;</xsl:text></xsl:template><!-- inverted question mark = turned question mark, U+00BF ISOnum -->
1043 <xsl:template match="ch.Agrave"><xsl:text>&#192;</xsl:text></xsl:template><!-- latin capital letter A with grave = latin capital letter A grave, U+00C0 ISOlat1 -->
1044 <xsl:template match="ch.Aacute"><xsl:text>&#193;</xsl:text></xsl:template><!-- latin capital letter A with acute, U+00C1 ISOlat1 -->
1045 <xsl:template match="ch.Acirc"><xsl:text>&#194;</xsl:text></xsl:template><!-- latin capital letter A with circumflex, U+00C2 ISOlat1 -->
1046 <xsl:template match="ch.Atilde"><xsl:text>&#195;</xsl:text></xsl:template><!-- latin capital letter A with tilde, U+00C3 ISOlat1 -->
1047 <xsl:template match="ch.Auml"><xsl:text>&#196;</xsl:text></xsl:template><!-- latin capital letter A with diaeresis, U+00C4 ISOlat1 -->
1048 <xsl:template match="ch.Aring"><xsl:text>&#197;</xsl:text></xsl:template><!-- latin capital letter A with ring above = latin capital letter A ring, U+00C5 ISOlat1 -->
1049 <xsl:template match="ch.AElig"><xsl:text>&#198;</xsl:text></xsl:template><!-- latin capital letter AE = latin capital ligature AE, U+00C6 ISOlat1 -->
1050 <xsl:template match="ch.Ccedil"><xsl:text>&#199;</xsl:text></xsl:template><!-- latin capital letter C with cedilla, U+00C7 ISOlat1 -->
1051 <xsl:template match="ch.Egrave"><xsl:text>&#200;</xsl:text></xsl:template><!-- latin capital letter E with grave, U+00C8 ISOlat1 -->
1052 <xsl:template match="ch.Eacute"><xsl:text>&#201;</xsl:text></xsl:template><!-- latin capital letter E with acute, U+00C9 ISOlat1 -->
1053 <xsl:template match="ch.Ecirc"><xsl:text>&#202;</xsl:text></xsl:template><!-- latin capital letter E with circumflex, U+00CA ISOlat1 -->
1054 <xsl:template match="ch.Euml"><xsl:text>&#203;</xsl:text></xsl:template><!-- latin capital letter E with diaeresis, U+00CB ISOlat1 -->
1055 <xsl:template match="ch.Igrave"><xsl:text>&#204;</xsl:text></xsl:template><!-- latin capital letter I with grave, U+00CC ISOlat1 -->
1056 <xsl:template match="ch.Iacute"><xsl:text>&#205;</xsl:text></xsl:template><!-- latin capital letter I with acute, U+00CD ISOlat1 -->
1057 <xsl:template match="ch.Icirc"><xsl:text>&#206;</xsl:text></xsl:template><!-- latin capital letter I with circumflex, U+00CE ISOlat1 -->
1058 <xsl:template match="ch.Iuml"><xsl:text>&#207;</xsl:text></xsl:template><!-- latin capital letter I with diaeresis, U+00CF ISOlat1 -->
1059 <xsl:template match="ch.ETH"><xsl:text>&#208;</xsl:text></xsl:template><!-- latin capital letter ETH, U+00D0 ISOlat1 -->
1060 <xsl:template match="ch.Ntilde"><xsl:text>&#209;</xsl:text></xsl:template><!-- latin capital letter N with tilde, U+00D1 ISOlat1 -->
1061 <xsl:template match="ch.Ograve"><xsl:text>&#210;</xsl:text></xsl:template><!-- latin capital letter O with grave, U+00D2 ISOlat1 -->
1062 <xsl:template match="ch.Oacute"><xsl:text>&#211;</xsl:text></xsl:template><!-- latin capital letter O with acute, U+00D3 ISOlat1 -->
1063 <xsl:template match="ch.Ocirc"><xsl:text>&#212;</xsl:text></xsl:template><!-- latin capital letter O with circumflex, U+00D4 ISOlat1 -->
1064 <xsl:template match="ch.Otilde"><xsl:text>&#213;</xsl:text></xsl:template><!-- latin capital letter O with tilde, U+00D5 ISOlat1 -->
1065 <xsl:template match="ch.Ouml"><xsl:text>&#214;</xsl:text></xsl:template><!-- latin capital letter O with diaeresis, U+00D6 ISOlat1 -->
1066 <xsl:template match="ch.times"><xsl:text>&#215;</xsl:text></xsl:template><!-- multiplication sign, U+00D7 ISOnum -->
1067 <xsl:template match="ch.Oslash"><xsl:text>&#216;</xsl:text></xsl:template><!-- latin capital letter O with stroke = latin capital letter O slash, U+00D8 ISOlat1 -->
1068 <xsl:template match="ch.Ugrave"><xsl:text>&#217;</xsl:text></xsl:template><!-- latin capital letter U with grave, U+00D9 ISOlat1 -->
1069 <xsl:template match="ch.Uacute"><xsl:text>&#218;</xsl:text></xsl:template><!-- latin capital letter U with acute, U+00DA ISOlat1 -->
1070 <xsl:template match="ch.Ucirc"><xsl:text>&#219;</xsl:text></xsl:template><!-- latin capital letter U with circumflex, U+00DB ISOlat1 -->
1071 <xsl:template match="ch.Uuml"><xsl:text>&#220;</xsl:text></xsl:template><!-- latin capital letter U with diaeresis, U+00DC ISOlat1 -->
1072 <xsl:template match="ch.Yacute"><xsl:text>&#221;</xsl:text></xsl:template><!-- latin capital letter Y with acute, U+00DD ISOlat1 -->
1073 <xsl:template match="ch.THORN"><xsl:text>&#222;</xsl:text></xsl:template><!-- latin capital letter THORN, U+00DE ISOlat1 -->
1074 <xsl:template match="ch.szlig"><xsl:text>&#223;</xsl:text></xsl:template><!-- latin small letter sharp s = ess-zed, U+00DF ISOlat1 -->
1075 <xsl:template match="ch.agrave"><xsl:text>&#224;</xsl:text></xsl:template><!-- latin small letter a with grave = latin small letter a grave, U+00E0 ISOlat1 -->
1076 <xsl:template match="ch.aacute"><xsl:text>&#225;</xsl:text></xsl:template><!-- latin small letter a with acute, U+00E1 ISOlat1 -->
1077 <xsl:template match="ch.acirc"><xsl:text>&#226;</xsl:text></xsl:template><!-- latin small letter a with circumflex, U+00E2 ISOlat1 -->
1078 <xsl:template match="ch.atilde"><xsl:text>&#227;</xsl:text></xsl:template><!-- latin small letter a with tilde, U+00E3 ISOlat1 -->
1079 <xsl:template match="ch.auml"><xsl:text>&#228;</xsl:text></xsl:template><!-- latin small letter a with diaeresis, U+00E4 ISOlat1 -->
1080 <xsl:template match="ch.aring"><xsl:text>&#229;</xsl:text></xsl:template><!-- latin small letter a with ring above = latin small letter a ring, U+00E5 ISOlat1 -->
1081 <xsl:template match="ch.aelig"><xsl:text>&#230;</xsl:text></xsl:template><!-- latin small letter ae = latin small ligature ae, U+00E6 ISOlat1 -->
1082 <xsl:template match="ch.ccedil"><xsl:text>&#231;</xsl:text></xsl:template><!-- latin small letter c with cedilla, U+00E7 ISOlat1 -->
1083 <xsl:template match="ch.egrave"><xsl:text>&#232;</xsl:text></xsl:template><!-- latin small letter e with grave, U+00E8 ISOlat1 -->
1084 <xsl:template match="ch.eacute"><xsl:text>&#233;</xsl:text></xsl:template><!-- latin small letter e with acute, U+00E9 ISOlat1 -->
1085 <xsl:template match="ch.ecirc"><xsl:text>&#234;</xsl:text></xsl:template><!-- latin small letter e with circumflex, U+00EA ISOlat1 -->
1086 <xsl:template match="ch.euml"><xsl:text>&#235;</xsl:text></xsl:template><!-- latin small letter e with diaeresis, U+00EB ISOlat1 -->
1087 <xsl:template match="ch.igrave"><xsl:text>&#236;</xsl:text></xsl:template><!-- latin small letter i with grave, U+00EC ISOlat1 -->
1088 <xsl:template match="ch.iacute"><xsl:text>&#237;</xsl:text></xsl:template><!-- latin small letter i with acute, U+00ED ISOlat1 -->
1089 <xsl:template match="ch.icirc"><xsl:text>&#238;</xsl:text></xsl:template><!-- latin small letter i with circumflex, U+00EE ISOlat1 -->
1090 <xsl:template match="ch.iuml"><xsl:text>&#239;</xsl:text></xsl:template><!-- latin small letter i with diaeresis, U+00EF ISOlat1 -->
1091 <xsl:template match="ch.eth"><xsl:text>&#240;</xsl:text></xsl:template><!-- latin small letter eth, U+00F0 ISOlat1 -->
1092 <xsl:template match="ch.ntilde"><xsl:text>&#241;</xsl:text></xsl:template><!-- latin small letter n with tilde, U+00F1 ISOlat1 -->
1093 <xsl:template match="ch.ograve"><xsl:text>&#242;</xsl:text></xsl:template><!-- latin small letter o with grave, U+00F2 ISOlat1 -->
1094 <xsl:template match="ch.oacute"><xsl:text>&#243;</xsl:text></xsl:template><!-- latin small letter o with acute, U+00F3 ISOlat1 -->
1095 <xsl:template match="ch.ocirc"><xsl:text>&#244;</xsl:text></xsl:template><!-- latin small letter o with circumflex, U+00F4 ISOlat1 -->
1096 <xsl:template match="ch.otilde"><xsl:text>&#245;</xsl:text></xsl:template><!-- latin small letter o with tilde, U+00F5 ISOlat1 -->
1097 <xsl:template match="ch.ouml"><xsl:text>&#246;</xsl:text></xsl:template><!-- latin small letter o with diaeresis, U+00F6 ISOlat1 -->
1098 <xsl:template match="ch.divide"><xsl:text>&#247;</xsl:text></xsl:template><!-- division sign, U+00F7 ISOnum -->
1099 <xsl:template match="ch.oslash"><xsl:text>&#248;</xsl:text></xsl:template><!-- latin small letter o with stroke, = latin small letter o slash, U+00F8 ISOlat1 -->
1100 <xsl:template match="ch.ugrave"><xsl:text>&#249;</xsl:text></xsl:template><!-- latin small letter u with grave, U+00F9 ISOlat1 -->
1101 <xsl:template match="ch.uacute"><xsl:text>&#250;</xsl:text></xsl:template><!-- latin small letter u with acute, U+00FA ISOlat1 -->
1102 <xsl:template match="ch.ucirc"><xsl:text>&#251;</xsl:text></xsl:template><!-- latin small letter u with circumflex, U+00FB ISOlat1 -->
1103 <xsl:template match="ch.uuml"><xsl:text>&#252;</xsl:text></xsl:template><!-- latin small letter u with diaeresis, U+00FC ISOlat1 -->
1104 <xsl:template match="ch.yacute"><xsl:text>&#253;</xsl:text></xsl:template><!-- latin small letter y with acute, U+00FD ISOlat1 -->
1105 <xsl:template match="ch.thorn"><xsl:text>&#254;</xsl:text></xsl:template><!-- latin small letter thorn, U+00FE ISOlat1 -->
1106 <xsl:template match="ch.yuml"><xsl:text>&#255;</xsl:text></xsl:template><!-- latin small letter y with diaeresis, U+00FF ISOlat1 -->
1107
1108 <!-- ~~~~~~~~~~~~~~~~~~~~~ Special Characters ~~~~~~~~~~~~~~~~~~~~ -->
1109
1110 <xsl:template match="ch.ampersand">&amp;</xsl:template><!-- ampersand -->
1111 <xsl:template match="ch.lsquot">&apos;</xsl:template><!-- opening left quotation mark -->
1112 <xsl:template match="ch.rsquot">&apos;</xsl:template><!-- closing right quotation mark -->
1113 <xsl:template match="ch.ldquot">&quot;</xsl:template><!-- opening left double quotation mark -->
1114 <xsl:template match="ch.rdquot">&quot;</xsl:template><!-- closing right double quotation mark -->
1115 <xsl:template match="ch.minus">-</xsl:template><!-- mathematical minus -->
1116 <xsl:template match="ch.endash">-</xsl:template><!-- endash -->
1117 <xsl:template match="ch.emdash">--</xsl:template><!-- emdash -->
1118 <xsl:template match="ch.ellips">&nbsp;.&nbsp;.&nbsp;.</xsl:template><!-- ellipsis -->
1119 <xsl:template match="ch.lellips">.&nbsp;.&nbsp;.&nbsp;</xsl:template><!-- left ellipsis, used at the beginning of edited material -->
1120 <xsl:template match="ch.blankline">_______</xsl:template><!-- blank line to be filled in -->
1121 <xsl:template match="ch.percent"><xsl:text>&#37;</xsl:text></xsl:template><!-- percent sign -->
1122 <xsl:template match="ch.thinspace"><xsl:text></xsl:text></xsl:template><!-- small horizontal space for use between adjacent quotation marks - added mainly for LaTeX's sake -->
1123 <xsl:template match="ch.frac116"><xsl:text>1/16</xsl:text></xsl:template><!-- vulgar fraction one sixteenth = fraction on sixteenth -->
1124 <xsl:template match="ch.plus"><xsl:text>+</xsl:text></xsl:template><!-- mathematical plus -->
1125
1126 <!-- ==================== named templates ======================= -->
1127
1128 <xsl:template name="xhtml-wrapper">
1129  <xsl:param name="document-type">undefined</xsl:param>
1130  <xsl:param name="filename">undefined</xsl:param>
1131  <xsl:param name="glossary-id-prefix"></xsl:param>
1132
1133 <!-- <redirect:write file="{$filename}.htm">-->
1134  <redirect:write file="{$filename}.htm">
1135   <xsl:fallback>
1136    <xsl:text>xhtml-wrapper: Cannot write to filename: "</xsl:text>
1137    <xsl:value-of select="$filename" /><xsl:text>.htm"</xsl:text>
1138   </xsl:fallback>
1139
1140   <html xml:lang="en-UK" lang="en-UK">
1141
1142    <xsl:value-of select="$newline" />
1143    <xsl:value-of select="$newline" />
1144
1145    <head><xsl:value-of select="$newline" />
1146     <title>
1147      <xsl:apply-templates select="/gamebook/meta/title[1]" />
1148      <xsl:text>: </xsl:text>
1149      <xsl:choose>
1150       <xsl:when test="$document-type='illustration'">
1151        <xsl:choose>
1152         <xsl:when test="$language='es'">
1153          <xsl:text>Ilustraci&oacute;n </xsl:text>
1154         </xsl:when>
1155         <xsl:otherwise>
1156          <xsl:text>Illustration </xsl:text>
1157         </xsl:otherwise>
1158        </xsl:choose>
1159        <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
1160       </xsl:when>
1161       <xsl:otherwise><xsl:apply-templates select="meta/title[1]" /></xsl:otherwise>
1162      </xsl:choose>
1163     </title><xsl:value-of select="$newline" />
1164     <meta http-equiv="Content-type" content="text/html; charset=ISO-8859-1" /><xsl:value-of select="$newline" />
1165     <meta name="robots" content="noindex,nofollow" /><xsl:value-of select="$newline" />
1166     <link rel="stylesheet" href="main.css" type="text/css" /><xsl:value-of select="$newline" />
1167    </head>
1168
1169    <xsl:value-of select="$newline" />
1170    <xsl:value-of select="$newline" />
1171
1172    <xsl:comment>
1173     <xsl:text> </xsl:text>
1174     <xsl:apply-templates select="/gamebook/meta/rights[@class='copyrights']" />
1175     <xsl:choose>
1176      <xsl:when test="$language='es'">
1177       <xsl:text> Publicado por </xsl:text>
1178      </xsl:when>
1179      <xsl:otherwise>
1180       <xsl:text> Published by </xsl:text>
1181      </xsl:otherwise>
1182     </xsl:choose>
1183     <xsl:apply-templates select="/gamebook/meta/publisher[1]" />
1184     <xsl:text>. </xsl:text>
1185    </xsl:comment>
1186
1187    <xsl:value-of select="$newline" />
1188    <xsl:value-of select="$newline" />
1189
1190    <body>
1191     <xsl:attribute name="text"><xsl:value-of select="$text-color" /></xsl:attribute>
1192     <xsl:attribute name="bgcolor"><xsl:value-of select="$background-color" /></xsl:attribute>
1193     <xsl:attribute name="background"><xsl:text>bckgrnd.gif</xsl:text></xsl:attribute>
1194     <xsl:attribute name="link"><xsl:value-of select="$link-color" /></xsl:attribute>
1195     <xsl:attribute name="alink"><xsl:value-of select="$alink-color" /></xsl:attribute>
1196     <xsl:attribute name="vlink"><xsl:value-of select="$vlink-color" /></xsl:attribute>
1197
1198     <xsl:value-of select="$newline" />
1199     <div id="title"><img src="title.gif" width="550" height="100" border="0" align="middle" usemap="#imagemap"><xsl:attribute name="alt"><xsl:apply-templates select="/gamebook/meta/title[1]" /></xsl:attribute></img></div><xsl:value-of select="$newline" />
1200     <div id="body"><xsl:value-of select="$newline" />
1201
1202      <xsl:choose>
1203
1204 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~ top-level ~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
1205
1206       <xsl:when test="$document-type='top-level'">
1207        <div class="frontmatter"><xsl:value-of select="$newline" />
1208
1209         <xsl:apply-templates select="/gamebook/meta/description[@class='blurb']" />
1210         <xsl:apply-templates select="/gamebook/meta/creator[@class='long']" />
1211
1212         <hr />
1213
1214         <xsl:apply-templates select="/gamebook/meta/description[@class='publication']" />
1215
1216         <p>
1217          <xsl:choose>
1218           <xsl:when test="$language='es'">
1219            <xsl:text>Fecha de Publicaci&oacute;n: </xsl:text>
1220           </xsl:when>
1221           <xsl:otherwise>
1222            <xsl:text>Publication Date: </xsl:text>
1223           </xsl:otherwise>
1224          </xsl:choose>
1225          <xsl:value-of select="/gamebook/meta/date[@class='publication']/day" />
1226          <xsl:text> </xsl:text>
1227          <xsl:choose>
1228           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 1">
1229            <xsl:choose>
1230             <xsl:when test="$language='es'"><xsl:text>de enero de</xsl:text></xsl:when>
1231             <xsl:otherwise><xsl:text>January</xsl:text></xsl:otherwise>
1232            </xsl:choose>
1233           </xsl:when>
1234           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 2">
1235            <xsl:choose>
1236             <xsl:when test="$language='es'"><xsl:text>de febrero de</xsl:text></xsl:when>
1237             <xsl:otherwise><xsl:text>February</xsl:text></xsl:otherwise>
1238            </xsl:choose>
1239           </xsl:when>
1240           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 3">
1241            <xsl:choose>
1242             <xsl:when test="$language='es'"><xsl:text>de marzo de</xsl:text></xsl:when>
1243             <xsl:otherwise><xsl:text>March</xsl:text></xsl:otherwise>
1244            </xsl:choose>
1245           </xsl:when>
1246           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 4">
1247            <xsl:choose>
1248             <xsl:when test="$language='es'"><xsl:text>de abril de</xsl:text></xsl:when>
1249             <xsl:otherwise><xsl:text>April</xsl:text></xsl:otherwise>
1250            </xsl:choose>
1251           </xsl:when>
1252           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 5">
1253            <xsl:choose>
1254             <xsl:when test="$language='es'"><xsl:text>de mayo de</xsl:text></xsl:when>
1255             <xsl:otherwise><xsl:text>May</xsl:text></xsl:otherwise>
1256            </xsl:choose>
1257           </xsl:when>
1258           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 6">
1259            <xsl:choose>
1260             <xsl:when test="$language='es'"><xsl:text>de junio de</xsl:text></xsl:when>
1261             <xsl:otherwise><xsl:text>June</xsl:text></xsl:otherwise>
1262            </xsl:choose>
1263           </xsl:when>
1264           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 7">
1265            <xsl:choose>
1266             <xsl:when test="$language='es'"><xsl:text>de julio de</xsl:text></xsl:when>
1267             <xsl:otherwise><xsl:text>July</xsl:text></xsl:otherwise>
1268            </xsl:choose>
1269           </xsl:when>
1270           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 8">
1271            <xsl:choose>
1272             <xsl:when test="$language='es'"><xsl:text>de agosto de</xsl:text></xsl:when>
1273             <xsl:otherwise><xsl:text>August</xsl:text></xsl:otherwise>
1274            </xsl:choose>
1275           </xsl:when>
1276           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 9">
1277            <xsl:choose>
1278             <xsl:when test="$language='es'"><xsl:text>de septiembre de</xsl:text></xsl:when>
1279             <xsl:otherwise><xsl:text>September</xsl:text></xsl:otherwise>
1280            </xsl:choose>
1281           </xsl:when>
1282           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 10">
1283            <xsl:choose>
1284             <xsl:when test="$language='es'"><xsl:text>de octubre de</xsl:text></xsl:when>
1285             <xsl:otherwise><xsl:text>October</xsl:text></xsl:otherwise>
1286            </xsl:choose>
1287           </xsl:when>
1288           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 11">
1289            <xsl:choose>
1290             <xsl:when test="$language='es'"><xsl:text>de noviembre de</xsl:text></xsl:when>
1291             <xsl:otherwise><xsl:text>November</xsl:text></xsl:otherwise>
1292            </xsl:choose>
1293           </xsl:when>
1294           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 12">
1295            <xsl:choose>
1296             <xsl:when test="$language='es'"><xsl:text>de diciembre de</xsl:text></xsl:when>
1297             <xsl:otherwise><xsl:text>December</xsl:text></xsl:otherwise>
1298            </xsl:choose>
1299           </xsl:when>
1300           <xsl:otherwise>
1301            <xsl:text>Invalid Month</xsl:text>
1302           </xsl:otherwise>
1303          </xsl:choose>
1304          <xsl:text> </xsl:text>
1305          <xsl:value-of select="/gamebook/meta/date[@class='publication']/year" />
1306         </p>
1307
1308         <xsl:apply-templates select="/gamebook/meta/rights[@class='license-notification']" />
1309
1310         <xsl:value-of select="$newline" />
1311
1312         <xsl:call-template name="navigation-bar" />
1313
1314         <xsl:value-of select="$newline" />
1315        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1316
1317       </xsl:when>
1318
1319 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ toc ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
1320
1321       <xsl:when test="$document-type='toc'">
1322        <div class="frontmatter"><xsl:value-of select="$newline" />
1323         <h2>
1324          <xsl:choose>
1325           <xsl:when test="$language='es'">
1326            <xsl:text>&Iacute;ndice de Contenidos</xsl:text>
1327           </xsl:when>
1328           <xsl:otherwise>
1329            <xsl:text>Table of Contents</xsl:text>
1330           </xsl:otherwise>
1331          </xsl:choose>
1332         </h2><xsl:value-of select="$newline" />
1333
1334         <xsl:value-of select="$newline" />
1335         <xsl:value-of select="$newline" />
1336
1337         <ul><xsl:value-of select="$newline" />
1338          <xsl:variable name="title-page">
1339           <xsl:choose>
1340            <xsl:when test="$language='es'">
1341             <xsl:text>P&aacute;gina Principal</xsl:text>
1342            </xsl:when>
1343            <xsl:otherwise>
1344             <xsl:text>Title Page</xsl:text>
1345            </xsl:otherwise>
1346           </xsl:choose>
1347          </xsl:variable>
1348
1349          <li><a href="title.htm"><xsl:value-of select="$title-page"/></a></li><xsl:value-of select="$newline" />
1350          <xsl:for-each select="/gamebook/section/data/section">
1351           <li>
1352            <a><xsl:attribute name="href"><xsl:value-of select="@id" /><xsl:text>.htm</xsl:text></xsl:attribute>
1353             <xsl:apply-templates select="meta/title[1]" />
1354            </a>
1355            <xsl:if test="data/section[@class='frontmatter-separate' or @class='mainmatter-separate']">
1356             <xsl:value-of select="$newline" />
1357             <ul><xsl:value-of select="$newline" />
1358              <xsl:for-each select="data/section[@class='frontmatter-separate' or @class='mainmatter-separate']">
1359               <li>
1360                <a><xsl:attribute name="href"><xsl:value-of select="@id" /><xsl:text>.htm</xsl:text></xsl:attribute>
1361                 <xsl:value-of select ="meta/title[1]" />
1362                </a>
1363               </li><xsl:value-of select="$newline" />
1364              </xsl:for-each>
1365             </ul><xsl:value-of select="$newline" />
1366            </xsl:if>
1367           </li><xsl:value-of select="$newline" />
1368          </xsl:for-each>
1369         </ul><xsl:value-of select="$newline" />
1370
1371         <xsl:value-of select="$newline" />
1372         <xsl:value-of select="$newline" />
1373         <xsl:call-template name="navigation-bar" />
1374        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1375       </xsl:when>
1376
1377 <!-- ~~~~~~~~~~~~~~~~ second-level-frontmatter ~~~~~~~~~~~~~~~~~~~ -->
1378
1379       <xsl:when test="$document-type='second-level-frontmatter'">
1380        <div class="frontmatter"><xsl:value-of select="$newline" />
1381         <h2><xsl:apply-templates select="meta/title" /></h2><xsl:value-of select="$newline" />
1382
1383         <xsl:value-of select="$newline" />
1384
1385         <xsl:apply-templates />
1386
1387         <xsl:value-of select="$newline" />
1388
1389         <xsl:call-template name="navigation-bar" />
1390
1391        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1392       </xsl:when>
1393
1394 <!-- ~~~~~~~~~~~~~ third-level-frontmatter-separate ~~~~~~~~~~~~~~ -->
1395
1396       <xsl:when test="$document-type='third-level-frontmatter-separate'">
1397        <div class="frontmatter"><xsl:value-of select="$newline" />
1398         <h3><xsl:apply-templates select="meta/title" /></h3><xsl:value-of select="$newline" />
1399         <xsl:value-of select="$newline" />
1400
1401         <xsl:apply-templates />
1402
1403         <xsl:value-of select="$newline" />
1404
1405         <xsl:call-template name="navigation-bar" />
1406
1407        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1408       </xsl:when>
1409
1410 <!-- ~~~~~~~~~~~~~~~~ second-level-mainmatter ~~~~~~~~~~~~~~~~~~~ -->
1411
1412       <xsl:when test="$document-type='second-level-mainmatter'">
1413        <div class="mainmatter"><xsl:value-of select="$newline" />
1414         <h2><xsl:apply-templates select="meta/title" /></h2><xsl:value-of select="$newline" />
1415         <xsl:value-of select="$newline" />
1416
1417         <xsl:apply-templates />
1418
1419         <xsl:value-of select="$newline" />
1420
1421         <xsl:call-template name="navigation-bar" />
1422
1423        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1424       </xsl:when>
1425
1426 <!-- ~~~~~~~~~~~~~ third-level-mainmatter-separate ~~~~~~~~~~~~~~ -->
1427
1428       <xsl:when test="$document-type='third-level-mainmatter-separate'">
1429        <div class="mainmatter"><xsl:value-of select="$newline" />
1430         <h3><xsl:apply-templates select="meta/title" /></h3><xsl:value-of select="$newline" />
1431         <xsl:value-of select="$newline" />
1432
1433         <xsl:apply-templates />
1434
1435         <xsl:value-of select="$newline" />
1436
1437         <xsl:call-template name="navigation-bar" />
1438
1439        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1440       </xsl:when>
1441
1442 <!-- ~~~~~~~~~~~~~~~~ second-level-glossary ~~~~~~~~~~~~~~~~~~~ -->
1443
1444       <xsl:when test="$document-type='second-level-glossary'">
1445        <div class="mainmatter"><xsl:value-of select="$newline" />
1446         <h2><xsl:apply-templates select="meta/title" /></h2><xsl:value-of select="$newline" />
1447         <xsl:value-of select="$newline" />
1448
1449         <xsl:apply-templates />
1450
1451         <xsl:value-of select="$newline" />
1452
1453         <xsl:call-template name="alpha-bar">
1454          <xsl:with-param name="alpha-bar-id-prefix"><xsl:value-of select="$glossary-id-prefix" /></xsl:with-param>
1455         </xsl:call-template>
1456
1457         <xsl:call-template name="navigation-bar" />
1458
1459        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1460       </xsl:when>
1461
1462 <!-- ~~~~~~~~~~~~~ third-level-glossary-separate ~~~~~~~~~~~~~~ -->
1463
1464       <xsl:when test="$document-type='third-level-glossary-separate'">
1465        <div class="glossary"><xsl:value-of select="$newline" />
1466         <h3><xsl:apply-templates select="meta/title" /></h3><xsl:value-of select="$newline" />
1467         <xsl:call-template name="alpha-bar">
1468          <xsl:with-param name="alpha-bar-id-prefix"><xsl:value-of select="$glossary-id-prefix" /></xsl:with-param>
1469         </xsl:call-template>
1470
1471         <xsl:value-of select="$newline" />
1472
1473         <xsl:apply-templates />
1474
1475         <xsl:value-of select="$newline" />
1476
1477         <xsl:call-template name="navigation-bar" />
1478         <xsl:value-of select="$newline" />
1479        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1480       </xsl:when>
1481
1482 <!-- ~~~~~~~~~~~~~~~~~~ second-level-numbered ~~~~~~~~~~~~~~~~~~~~ -->
1483 <!--
1484
1485 The following automatically generated section list requires that the
1486 title of each section be a simple number.
1487
1488 -->
1489       <xsl:when test="$document-type='second-level-numbered'">
1490        <div class="numbered"><xsl:value-of select="$newline" />
1491         <h2><xsl:apply-templates select="meta/title" /></h2><xsl:value-of select="$newline" />
1492         <xsl:value-of select="$newline" />
1493
1494         <xsl:variable name="base-section-number" select="number( data/section[1]/meta/title ) - 1" />
1495         <p>
1496          <xsl:for-each select="data/section">
1497           <xsl:if test="position( ) mod 10 = 1">
1498            <b><a><xsl:attribute name="name"><xsl:value-of select="position( ) + $base-section-number" /></xsl:attribute>
1499             <xsl:value-of select="position( ) + $base-section-number" />
1500             <xsl:if test="not( position( ) = last( ) )">
1501              <xsl:text>-</xsl:text>
1502              <xsl:choose>
1503               <xsl:when test="position( ) + 9 &lt;= last( )">
1504                <xsl:value-of select="position( ) + 9 + $base-section-number" />
1505               </xsl:when>
1506               <xsl:otherwise>
1507                <xsl:value-of select="last( ) + $base-section-number" />
1508               </xsl:otherwise>
1509              </xsl:choose>
1510             </xsl:if>
1511            </a><xsl:text>: </xsl:text></b>
1512           </xsl:if>
1513           <a>
1514            <xsl:attribute name="href"><xsl:value-of select="@id" /><xsl:text>.htm</xsl:text></xsl:attribute>
1515            <xsl:apply-templates select="meta/title" />
1516           </a>
1517           <xsl:choose>
1518            <xsl:when test="position( ) mod 10 = 0">
1519             <br /><xsl:value-of select="$newline" />
1520            </xsl:when>
1521            <xsl:otherwise>
1522             <xsl:text> </xsl:text>
1523            </xsl:otherwise>
1524           </xsl:choose>
1525          </xsl:for-each>
1526         </p>
1527
1528         <xsl:value-of select="$newline" />
1529         <xsl:value-of select="$newline" />
1530
1531         <xsl:call-template name="navigation-bar" />
1532         <xsl:value-of select="$newline" />
1533        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1534       </xsl:when>
1535
1536 <!-- ~~~~~~~~~~~~~~~~~~ third-level-numbered ~~~~~~~~~~~~~~~~~~~~~ -->
1537
1538       <xsl:when test="$document-type='third-level-numbered'">
1539        <div class="numbered"><xsl:value-of select="$newline" />
1540         <h3><xsl:apply-templates select="meta/title" /></h3><xsl:value-of select="$newline" />
1541         <xsl:value-of select="$newline" />
1542
1543         <xsl:apply-templates />
1544
1545         <xsl:value-of select="$newline" />
1546         <xsl:call-template name="navigation-bar" />
1547         <xsl:value-of select="$newline" />
1548        </div>
1549       </xsl:when>
1550
1551 <!-- ~~~~~~~~~~~~~~~~~ footnotes ~~~~~~~~~~~~~~~~~~~ -->
1552
1553       <xsl:when test="$document-type='footnotz'">
1554        <div class="backmatter">
1555         <xsl:value-of select="$newline" />
1556         <!-- No particular reason to code title here -->
1557         <h2><xsl:apply-templates select="meta/title" /></h2><xsl:value-of select="$newline" />
1558         <xsl:value-of select="$newline" />
1559         <xsl:value-of select="$newline" />
1560         
1561         <!-- Generate list of footnotes -->
1562         <xsl:for-each select="//footnotes/footnote">
1563          <div class="footnote">
1564           <!-- will the list always contain the closest ancestor first? -->
1565           <xsl:variable name="footnote-section"><xsl:value-of select="ancestor::section[position()=1]/@id" /></xsl:variable>
1566           <xsl:variable name="footnote-marker"><xsl:number count="footnotes/footnote" from="/" level="any" format="1" /></xsl:variable>
1567           <xsl:variable name="footnote-idref"><xsl:value-of select="@idref" /></xsl:variable>
1568           
1569           <xsl:for-each select="*[1]">
1570            <p>
1571             <xsl:text>[</xsl:text>
1572             <a>
1573              <xsl:attribute name="href"><xsl:value-of select="$footnote-section" /><xsl:text>.htm#</xsl:text><xsl:value-of select="$footnote-idref" /></xsl:attribute>
1574              <xsl:value-of select="$footnote-marker" />
1575             </a>
1576             <xsl:text>] </xsl:text>
1577
1578             <xsl:text> (</xsl:text>
1579             <xsl:call-template name="section-title-link" />
1580             <xsl:text>) </xsl:text>
1581
1582             <xsl:apply-templates select="child::* | child::text()" />
1583            </p>
1584           </xsl:for-each>
1585           
1586           <xsl:for-each select="*[position() != 1]">
1587            <xsl:apply-templates select="." />
1588           </xsl:for-each>
1589           
1590          </div>
1591         </xsl:for-each>
1592         
1593         <!-- Backwards compatibility... needed? Probably not. -->
1594         <xsl:apply-templates />
1595         
1596         <xsl:value-of select="$newline" />
1597        
1598         <xsl:call-template name="navigation-bar" />
1599         <xsl:value-of select="$newline" />
1600        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1601       </xsl:when>
1602
1603 <!-- ~~~~~~~~~~~~~~~~~ second-level-backmatter ~~~~~~~~~~~~~~~~~~~ -->
1604
1605       <xsl:when test="$document-type='second-level-backmatter'">
1606        <div class="frontmatter"><xsl:value-of select="$newline" />
1607         <h2><xsl:apply-templates select="meta/title" /></h2><xsl:value-of select="$newline" />
1608
1609         <xsl:value-of select="$newline" />
1610         <xsl:value-of select="$newline" />
1611
1612         <xsl:apply-templates />
1613
1614         <xsl:value-of select="$newline" />
1615
1616         <xsl:call-template name="navigation-bar" />
1617         <xsl:value-of select="$newline" />
1618        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1619       </xsl:when>
1620
1621 <!-- ~~~~~~~~~~~~~~~~~~~~~~~ map-adjusted ~~~~~~~~~~~~~~~~~~~~~~~~ -->
1622
1623       <xsl:when test="$document-type='map-adjusted'">
1624        <div class="frontmatter"><xsl:value-of select="$newline" />
1625         <h2><xsl:apply-templates select="meta/title" /></h2><xsl:value-of select="$newline" />
1626
1627         <xsl:value-of select="$newline" />
1628         <xsl:value-of select="$newline" />
1629
1630         <xsl:for-each select="data/* | data/text()">
1631          <xsl:variable name="map-illustration-alt-text">
1632           <xsl:choose>
1633            <xsl:when test="$language='es'">
1634             <xsl:text>mapa</xsl:text>
1635            </xsl:when>
1636            <xsl:otherwise>
1637             <xsl:text>map</xsl:text>
1638            </xsl:otherwise>
1639           </xsl:choose>
1640          </xsl:variable>
1641
1642          <!-- duplicated stuff here, no good way to avoid this while retaining backwards compatibility -->         
1643          <xsl:choose>
1644           <xsl:when test="self::illustration and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
1645            <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
1646            <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
1647            <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
1648
1649            <xsl:variable name="illustration-width-adjusted"><xsl:number value="386" /></xsl:variable>
1650            <xsl:variable name="illustration-height-adjusted"><xsl:number value="$illustration-height * $illustration-width-adjusted div $illustration-width" /></xsl:variable>
1651
1652            <div class="illustration"><div align="center"><xsl:value-of select="$newline" />
1653             <xsl:call-template name="illustration-framed">
1654              <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width-adjusted" /></xsl:with-param>
1655              <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height-adjusted" /></xsl:with-param>
1656              <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
1657              <xsl:with-param name="illustration-href">maplarge.htm</xsl:with-param>
1658              <xsl:with-param name="brdrl-width">31</xsl:with-param>
1659              <xsl:with-param name="brdrr-width">33</xsl:with-param>
1660              <xsl:with-param name="illustration-alt-text">[{$map-illustration-alt-text}]</xsl:with-param>
1661             </xsl:call-template>
1662             <br /><br />
1663            </div></div><xsl:value-of select="$newline" />
1664           </xsl:when>
1665
1666           <xsl:when test="self::illref and @class='html'">
1667            <xsl:for-each select="id( @idref )">
1668             <xsl:if test="contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
1669              <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
1670              <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
1671              <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
1672
1673              <xsl:variable name="illustration-width-adjusted"><xsl:number value="386" /></xsl:variable>
1674              <xsl:variable name="illustration-height-adjusted"><xsl:number value="$illustration-height * $illustration-width-adjusted div $illustration-width" /></xsl:variable>
1675
1676              <div class="illustration">
1677               <div align="center"><xsl:value-of select="$newline" />
1678               <xsl:call-template name="illustration-framed">
1679                <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width-adjusted" /></xsl:with-param>
1680                <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height-adjusted" /></xsl:with-param>
1681                <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
1682                <xsl:with-param name="illustration-href">maplarge.htm</xsl:with-param>
1683                <xsl:with-param name="brdrl-width">31</xsl:with-param>
1684                <xsl:with-param name="brdrr-width">33</xsl:with-param>
1685                <xsl:with-param name="illustration-alt-text">[{$map-illustration-alt-text}]</xsl:with-param>
1686               </xsl:call-template>
1687               <br /><br />
1688              </div></div><xsl:value-of select="$newline" />
1689             </xsl:if>
1690            </xsl:for-each>
1691           </xsl:when>
1692           <xsl:otherwise>
1693            <xsl:apply-templates select="." />
1694           </xsl:otherwise>
1695          </xsl:choose>
1696         </xsl:for-each>
1697
1698         <xsl:value-of select="$newline" />
1699
1700         <xsl:call-template name="navigation-bar" />
1701         <xsl:value-of select="$newline" />
1702        </div>
1703       </xsl:when>
1704
1705 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ map ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
1706
1707       <xsl:when test="$document-type='map'">
1708        <div class="frontmatter"><xsl:value-of select="$newline" />
1709         <h2><xsl:apply-templates select="meta/title" /></h2><xsl:value-of select="$newline" />
1710
1711         <xsl:value-of select="$newline" />
1712         <xsl:value-of select="$newline" />
1713
1714         <xsl:for-each select="data/* | data/text()">
1715          <xsl:variable name="map-illustration-alt-text">
1716           <xsl:choose>
1717            <xsl:when test="$language='es'">
1718             <xsl:text>mapa</xsl:text>
1719            </xsl:when>
1720            <xsl:otherwise>
1721             <xsl:text>map</xsl:text>
1722            </xsl:otherwise>
1723           </xsl:choose>
1724          </xsl:variable>
1725
1726          <!-- duplicated stuff here, no good way to avoid this while retaining backwards compatibility -->
1727          <xsl:choose>
1728           <xsl:when test="self::illustration and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
1729            <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
1730            <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
1731            <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
1732
1733            <div class="illustration"><div align="center"><xsl:value-of select="$newline" />
1734             <xsl:call-template name="illustration-framed">
1735              <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width" /></xsl:with-param>
1736              <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height" /></xsl:with-param>
1737              <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
1738              <xsl:with-param name="illustration-href">map.htm</xsl:with-param>
1739              <xsl:with-param name="brdrl-width">31</xsl:with-param>
1740              <xsl:with-param name="brdrr-width">33</xsl:with-param>
1741              <xsl:with-param name="illustration-alt-text">[{$map-illustration-alt-text}]</xsl:with-param>
1742             </xsl:call-template>
1743             <br /><xsl:value-of select="$newline" />
1744            </div></div><xsl:value-of select="$newline" />
1745           </xsl:when>
1746
1747           <xsl:when test="self::illref and @class='html'">
1748            <xsl:for-each select="id( @idref )">
1749             <xsl:if test="contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
1750              <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
1751              <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
1752              <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
1753
1754              <div class="illustration">
1755               <div align="center"><xsl:value-of select="$newline" />
1756               <xsl:call-template name="illustration-framed">
1757                <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width" /></xsl:with-param>
1758                <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height" /></xsl:with-param>
1759                <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
1760                <xsl:with-param name="illustration-href">map.htm</xsl:with-param>
1761                <xsl:with-param name="brdrl-width">31</xsl:with-param>
1762                <xsl:with-param name="brdrr-width">33</xsl:with-param>
1763                <xsl:with-param name="illustration-alt-text">[{$map-illustration-alt-text}]</xsl:with-param>
1764               </xsl:call-template>
1765               <br /><xsl:value-of select="$newline" />
1766              </div></div><xsl:value-of select="$newline" />
1767             </xsl:if>
1768            </xsl:for-each>
1769           </xsl:when>
1770           <xsl:otherwise>
1771            <xsl:apply-templates select="." />
1772           </xsl:otherwise>
1773          </xsl:choose>
1774         </xsl:for-each>
1775
1776         <xsl:value-of select="$newline" />
1777
1778         <xsl:call-template name="navigation-bar" />
1779         <xsl:value-of select="$newline" />
1780        </div>
1781       </xsl:when>
1782
1783 <!-- ~~~~~~~~~~~~~~~~~~~~~~ illustration ~~~~~~~~~~~~~~~~~~~~~~~~~ -->
1784
1785       <xsl:when test="$document-type='illustration'">
1786        <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
1787        <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
1788        <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
1789
1790        <h3>
1791         <xsl:choose>
1792          <xsl:when test="$language='es'">
1793           <xsl:text>Ilustraci&oacute;n </xsl:text>
1794          </xsl:when>
1795          <xsl:otherwise>
1796           <xsl:text>Illustration </xsl:text>
1797          </xsl:otherwise>
1798         </xsl:choose>
1799         <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
1800        </h3><xsl:value-of select="$newline" />
1801
1802        <div class="illustration"><div align="center"><xsl:value-of select="$newline" />
1803         <xsl:call-template name="illustration-framed">
1804          <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width" /></xsl:with-param>
1805          <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height" /></xsl:with-param>
1806          <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
1807          <xsl:with-param name="brdrl-width">31</xsl:with-param>
1808          <xsl:with-param name="brdrr-width">33</xsl:with-param>
1809         </xsl:call-template>
1810         <br /><xsl:value-of select="$newline" />
1811        </div></div><xsl:value-of select="$newline" />
1812        <p class="caption"><strong><xsl:apply-templates select="meta/description" /></strong></p><xsl:value-of select="$newline" />
1813       </xsl:when>
1814
1815 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~ error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
1816
1817       <xsl:otherwise>
1818        <xsl:message>
1819         <xsl:text>xhtml-wrapper: Cannot process document of type "</xsl:text>
1820         <xsl:value-of select="$document-type" />
1821         <xsl:text>".</xsl:text>
1822        </xsl:message>
1823        <p>
1824         <xsl:text>xhtml-wrapper: Cannot process document of type "</xsl:text>
1825         <xsl:value-of select="$document-type" />
1826         <xsl:text>".</xsl:text>
1827        </p>
1828       </xsl:otherwise>
1829
1830      </xsl:choose>
1831
1832 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~ footer ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
1833
1834      <xsl:call-template name="process-footnotes" />
1835
1836      <p class="copyright"><xsl:apply-templates select="/gamebook/meta/rights[@class='copyrights']" /></p><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1837
1838     </div><xsl:value-of select="$newline" />
1839
1840     <map name="imagemap" id="imagemap">
1841      <area shape="rect" coords="0,0,99,99" href="http://www.projectaon.org/" alt="Project Aon" target="_top" />
1842      <area shape="default" href="title.htm">
1843       <xsl:attribute name="alt"><xsl:apply-templates select="/gamebook/meta/title[1]" /></xsl:attribute>
1844      </area>
1845     </map>
1846
1847    </body>
1848
1849    <xsl:value-of select="$newline" />
1850    <xsl:value-of select="$newline" />
1851
1852   </html>
1853  </redirect:write>
1854
1855 </xsl:template>
1856
1857 <xsl:template name="process-footnotes">
1858  <xsl:if test="footnotes/footnote">
1859   <div id="footnotes"><xsl:value-of select="$newline" />
1860    <xsl:for-each select="footnotes/footnote">
1861     <xsl:variable name="footnote-idref" select="@idref" />
1862     <xsl:variable name="footnote-id" select="@id" />
1863     <xsl:variable name="footnote-marker"><xsl:number count="footnotes/footnote" from="/" level="any" format="1" /></xsl:variable>
1864
1865     <xsl:for-each select="*[1]">
1866      <p>
1867       <xsl:text>[</xsl:text>
1868        <a href="#{$footnote-idref}" name="{$footnote-id}"><xsl:value-of select="$footnote-marker" /></a>
1869       <xsl:text>] </xsl:text>
1870       <xsl:apply-templates select="child::* | child::text()" />
1871      </p>
1872     </xsl:for-each>
1873
1874     <xsl:for-each select="*[position() != 1]">
1875       <xsl:apply-templates select="." />
1876     </xsl:for-each>
1877    </xsl:for-each>
1878   </div><xsl:value-of select="$newline" />
1879  </xsl:if>
1880 </xsl:template>
1881
1882 <xsl:template name="navigation-bar">
1883  <xsl:variable name="table-of-contents">
1884   <xsl:choose>
1885    <xsl:when test="$language='es'">
1886     <xsl:text>&Iacute;ndice de Contenidos</xsl:text>
1887    </xsl:when>
1888    <xsl:otherwise>
1889     <xsl:text>Table of Contents</xsl:text>      
1890    </xsl:otherwise>
1891   </xsl:choose>
1892  </xsl:variable>
1893  <div class="navigation">
1894   <table cellspacing="0" cellpadding="0" border="0">
1895    <tr>
1896     <td>
1897      <xsl:choose>
1898       <xsl:when test="meta/link[@class='prev']">
1899        <a>
1900         <xsl:attribute name="href">
1901          <xsl:apply-templates select="meta/link[@class='prev']/@idref" />
1902          <xsl:text>.htm</xsl:text>
1903         </xsl:attribute>
1904         <img src="back.gif" width="150" height="30" border="0">
1905          <xsl:attribute name="alt">
1906           <xsl:value-of select="id( meta/link[@class='prev']/@idref )/meta/title" />
1907          </xsl:attribute>
1908         </img>
1909        </a>
1910       </xsl:when>
1911       <xsl:otherwise>
1912        <img src="left.gif" width="150" height="30" border="0" alt="" />
1913       </xsl:otherwise>
1914      </xsl:choose>
1915     </td>
1916     <td><a href="toc.htm"><img src="toc.gif" width="150" height="30" border="0" alt="{$table-of-contents}" /></a></td>
1917     <td>
1918      <xsl:choose>
1919       <xsl:when test="meta/link[@class='next']">
1920        <a>
1921         <xsl:attribute name="href">
1922          <xsl:value-of select="meta/link[@class='next']/@idref" />
1923          <xsl:text>.htm</xsl:text>
1924         </xsl:attribute>
1925         <img src="forward.gif" width="150" height="30" border="0">
1926          <xsl:attribute name="alt">
1927           <xsl:choose>
1928            <xsl:when test="meta/link[@class='next']/@idref = 'sect1'">
1929             <xsl:choose>
1930              <xsl:when test="$language='es'">
1931               <xsl:text>Secci&oacute;n 1</xsl:text>
1932              </xsl:when>
1933              <xsl:otherwise>
1934               <xsl:text>Section 1</xsl:text>
1935              </xsl:otherwise>
1936             </xsl:choose>
1937            </xsl:when>
1938            <xsl:otherwise>
1939             <xsl:value-of select="id( meta/link[@class='next']/@idref )/meta/title" />
1940            </xsl:otherwise>
1941           </xsl:choose>
1942          </xsl:attribute>
1943         </img>
1944        </a>
1945       </xsl:when>
1946       <xsl:otherwise>
1947        <img src="right.gif" width="150" height="30" border="0" alt="" />
1948       </xsl:otherwise>
1949      </xsl:choose>
1950     </td>
1951    </tr>
1952   </table>
1953  </div>
1954 </xsl:template>
1955
1956 <xsl:template name="alpha-bar">
1957  <xsl:param name="alpha-bar-id-prefix"></xsl:param>
1958
1959   <p class="navigation">[<a href="{$alpha-bar-id-prefix}a.htm">A</a>&nbsp;<a href="{$alpha-bar-id-prefix}b.htm">B</a>&nbsp;<a href="{$alpha-bar-id-prefix}c.htm">C</a>&nbsp;<a href="{$alpha-bar-id-prefix}d.htm">D</a>&nbsp;<a href="{$alpha-bar-id-prefix}e.htm">E</a>&nbsp;<a href="{$alpha-bar-id-prefix}f.htm">F</a>&nbsp;<a href="{$alpha-bar-id-prefix}g.htm">G</a>&nbsp;<a href="{$alpha-bar-id-prefix}h.htm">H</a>&nbsp;<a href="{$alpha-bar-id-prefix}i.htm">I</a>&nbsp;<a href="{$alpha-bar-id-prefix}j.htm">J</a>&nbsp;<a href="{$alpha-bar-id-prefix}k.htm">K</a>&nbsp;<a href="{$alpha-bar-id-prefix}l.htm">L</a>&nbsp;<a href="{$alpha-bar-id-prefix}m.htm">M</a>&nbsp;<a href="{$alpha-bar-id-prefix}n.htm">N</a>&nbsp;<a href="{$alpha-bar-id-prefix}o.htm">O</a>&nbsp;<a href="{$alpha-bar-id-prefix}p.htm">P</a>&nbsp;<a href="{$alpha-bar-id-prefix}q.htm">Q</a>&nbsp;<a href="{$alpha-bar-id-prefix}r.htm">R</a>&nbsp;<a href="{$alpha-bar-id-prefix}s.htm">S</a>&nbsp;<a href="{$alpha-bar-id-prefix}t.htm">T</a>&nbsp;<a href="{$alpha-bar-id-prefix}u.htm">U</a>&nbsp;<a href="{$alpha-bar-id-prefix}v.htm">V</a>&nbsp;<a href="{$alpha-bar-id-prefix}w.htm">W</a>&nbsp;<a href="{$alpha-bar-id-prefix}x.htm">X</a>&nbsp;<a href="{$alpha-bar-id-prefix}y.htm">Y</a>&nbsp;<a href="{$alpha-bar-id-prefix}z.htm">Z</a>]</p><xsl:value-of select="$newline" />
1960
1961 </xsl:template>
1962
1963 <xsl:template name="illustration-framed">
1964  <xsl:param name="brdrl-width">32</xsl:param>
1965  <xsl:param name="brdr-height">32</xsl:param>
1966  <xsl:param name="brdrr-width">32</xsl:param>
1967  <xsl:param name="illustration-alt-text">
1968   <xsl:choose>
1969    <xsl:when test="$language='es'">
1970     <xsl:text>ilustraci&oacute;n</xsl:text>
1971    </xsl:when>
1972    <xsl:otherwise>
1973     <xsl:text>illustration</xsl:text>
1974    </xsl:otherwise>
1975   </xsl:choose>
1976  </xsl:param>
1977
1978  <xsl:param name="illustration-width"></xsl:param>
1979  <xsl:param name="illustration-height"></xsl:param>
1980  <xsl:param name="illustration-src"></xsl:param>
1981  <xsl:param name="illustration-href"></xsl:param>
1982
1983  <table border="0" cellpadding="0" cellspacing="0">
1984   <xsl:value-of select="$newline" />
1985   <tr>
1986    <xsl:value-of select="$newline" />
1987    <td><img src="brdrtpl.gif" width="{$brdrl-width}" height="{$brdr-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1988    <td><img src="brdrtp.gif" width="{$illustration-width}" height="{$brdr-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1989    <td><img src="brdrtpr.gif" width="{$brdrr-width}" height="{$brdr-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1990   </tr><xsl:value-of select="$newline" />
1991   <tr>
1992    <xsl:value-of select="$newline" />
1993    <td><img src="brdrl.gif" width="{$brdrl-width}" height="{$illustration-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1994    <td>
1995     <xsl:choose>
1996      <xsl:when test="$illustration-href">
1997       <a href="{$illustration-href}">
1998        <img src="{$illustration-src}" width="{$illustration-width}" height="{$illustration-height}" align="middle" border="0" alt="{$illustration-alt-text}" />
1999       </a>
2000      </xsl:when>
2001      <xsl:otherwise>
2002       <img src="{$illustration-src}" width="{$illustration-width}" height="{$illustration-height}" align="middle" border="0" alt="[{$illustration-alt-text}]" />
2003      </xsl:otherwise>
2004     </xsl:choose>
2005    </td><xsl:value-of select="$newline" />
2006    <td><img src="brdrr.gif" width="{$brdrr-width}" height="{$illustration-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
2007   </tr><xsl:value-of select="$newline" />
2008   <tr>
2009    <xsl:value-of select="$newline" />
2010    <td><img src="brdrbtl.gif" width="{$brdrl-width}" height="{$brdr-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
2011    <td><img src="brdrbt.gif" width="{$illustration-width}" height="{$brdr-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
2012    <td><img src="brdrbtr.gif" width="{$brdrr-width}" height="{$brdr-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
2013   </tr><xsl:value-of select="$newline" />
2014  </table><xsl:value-of select="$newline" />
2015 </xsl:template>
2016
2017 <!--
2018  A "subroutine" to generate a link to the current section, with the section title (expanded with "Section " in case of a numbered section) as link text.
2019 -->
2020 <xsl:template name="section-title-link">
2021  <!-- will the list always contain the closest ancestor first? -->
2022  <xsl:variable name="section-title">
2023   <!-- numbered or not? -->
2024   <xsl:if test="ancestor::section[position()=1]/@class='numbered'">
2025    <xsl:choose>
2026     <xsl:when test="$language='es'">
2027      <xsl:text>Secci&oacute;n </xsl:text>
2028     </xsl:when>
2029     <xsl:otherwise>
2030      <xsl:text>Section </xsl:text>
2031     </xsl:otherwise>
2032    </xsl:choose>
2033   </xsl:if>
2034   <xsl:apply-templates select="ancestor::section[position()=1]/meta/title[1]" />
2035  </xsl:variable>
2036  
2037  <a>
2038   <xsl:attribute name="href"><xsl:value-of select="ancestor::section[position()=1]/@id" /><xsl:text>.htm</xsl:text></xsl:attribute>
2039   <xsl:value-of select="$section-title" />
2040  </a>
2041 </xsl:template>
2042
2043 </xsl:transform>