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