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