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