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