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