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