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