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