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