Initial freepository revision of XML support documents.
[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.1  2005/01/30 01:32:52  jonathan.blake
13 Initial freepository revision of XML support documents.
14
15 Revision 1.12  2003/10/07 06:05:14  Jon
16 Added capability for "accent" illustrations.
17
18 Revision 1.11  2002/12/06 22:12:04  jblake
19 Added default namespace declaration to transformation element
20 and removed all the extraneous declarations in the template
21 elements.
22
23 Revision 1.10  2002/11/17 22:37:25  jblake
24 Removed the "medium" creator entry from the templates.
25 Will they be of any use?
26
27 Revision 1.9  2002/11/17 05:06:56  jblake
28 Rearranged the title page.
29
30 Revision 1.8  2002/11/15 19:35:25  jblake
31 Fixed "Content-type" of XHTML output.
32
33 Revision 1.7  2002/11/15 00:15:39  jblake
34 Fixed a problem with the client-side image map and fixed
35 the numbered section list generation so that it will work
36 for Shadow on the Sand.
37
38 Revision 1.6  2002/10/30 05:59:45  jblake
39 Added a value for the alt attribute of the ToC image on the navigation bar.
40
41 Revision 1.5  2002/10/24 15:53:41  jblake
42 Fixed a conflict with whitespace and paragraphed lists.
43
44 Revision 1.4  2002/10/24 15:06:51  jblake
45 Added xmlns attributes to all elements that are top level in
46 their templates. This was an adjustment required by Xalan-J 2.4.
47
48 Also reinstated the comment in each document since the new
49 version of Xalan redirects it properly.
50
51 Revision 1.3  2002/10/23 05:18:29  jblake
52 Added the capability to filter which illustrators' work is used.
53 This is accomplished by the "use-illustrators" parameter.
54
55 Revision 1.2  2002/10/20 06:25:35  jblake
56 Added support for CLOSE COMBAT SKILL for Freeway Warrior books.
57
58 Revision 1.1  2002/10/15 23:29:51  jblake
59 Initial revision
60
61
62 20020327 - repurposed to be used with Xalan Java 2
63
64 Todo:
65
66 * Add blank whitespace handling to the paragraphed list template
67
68 -->
69
70 <xsl:transform version="1.0"
71   xmlns="http://www.w3.org/1999/xhtml"
72   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
73   xmlns:lxslt="http://xml.apache.org/xslt"
74   xmlns:redirect="org.apache.xalan.lib.Redirect"
75   extension-element-prefixes="redirect">
76
77 <xsl:output method="xml"
78             encoding="ISO-8859-1"
79             omit-xml-declaration="yes"
80             doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
81             doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
82
83 <xsl:strip-space elements="section data ol ul dl li dd footnotes footnote" />
84 <xsl:preserve-space elements="p choice" />
85
86 <!-- ====================== parameters ========================== -->
87
88 <xsl:param name="book-path"><xsl:text>undefined-book</xsl:text></xsl:param>
89 <xsl:param name="use-illustrators" />
90
91 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~ colors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
92
93 <xsl:param name="link-color"><xsl:text>#ff0000</xsl:text></xsl:param>
94 <xsl:param name="alink-color"><xsl:value-of select="$link-color" /></xsl:param>
95 <xsl:param name="vlink-color"><xsl:value-of select="$link-color" /></xsl:param>
96
97 <xsl:param name="text-color"><xsl:text>#000000</xsl:text></xsl:param>
98 <xsl:param name="background-color"><xsl:text>#ffffe4</xsl:text></xsl:param>
99
100 <!-- ======================= variables ========================== -->
101
102 <xsl:variable name="newline">
103 <xsl:text>
104 </xsl:text>
105 </xsl:variable>
106
107 <!-- ======================== Templates ========================= -->
108
109 <!-- ================= hierarchical sections ==================== -->
110
111 <xsl:template match="meta" />
112 <xsl:template match="section" />
113
114 <!-- ::::::::::::::::::: top-level section :::::::::::::::::::::: -->
115
116 <xsl:template match="/gamebook/section[@id='title']">
117  <xsl:call-template name="xhtml-wrapper">
118   <xsl:with-param name="document-type">top-level</xsl:with-param>
119   <xsl:with-param name="filename">title</xsl:with-param>
120  </xsl:call-template>
121
122  <xsl:apply-templates />
123 </xsl:template>
124
125 <xsl:template match="/gamebook/section[@id='toc']">
126  <xsl:call-template name="xhtml-wrapper">
127   <xsl:with-param name="document-type">toc</xsl:with-param>
128   <xsl:with-param name="filename">toc</xsl:with-param>
129  </xsl:call-template>
130
131  <xsl:apply-templates />
132 </xsl:template>
133
134 <!-- ::::::::::: second-level frontmatter sections :::::::::::::: -->
135
136 <xsl:template match="/gamebook/section/data/section[@class='frontmatter']">
137  <xsl:call-template name="xhtml-wrapper">
138   <xsl:with-param name="document-type">second-level-frontmatter</xsl:with-param>
139   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
140  </xsl:call-template>
141 </xsl:template>
142
143 <!-- :::::::::::: third-level front matter sections ::::::::::::: -->
144
145 <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter']">
146  <h3><xsl:value-of select="meta/title[1]" /></h3>
147
148  <xsl:value-of select="$newline" />
149  <xsl:value-of select="$newline" />
150
151  <xsl:apply-templates />
152 </xsl:template>
153
154 <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter-separate']">
155  <xsl:call-template name="xhtml-wrapper">
156   <xsl:with-param name="document-type">third-level-frontmatter-separate</xsl:with-param>
157   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
158  </xsl:call-template>
159 </xsl:template>
160
161 <!-- :::::::::::: fourth-level front matter sections :::::::::::: -->
162
163 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='frontmatter']">
164  <h4><xsl:value-of select="meta/title[1]" /></h4>
165
166  <xsl:value-of select="$newline" />
167  <xsl:value-of select="$newline" />
168
169  <xsl:apply-templates />
170 </xsl:template>
171
172 <!-- ::::::::::::: fifth-level front matter sections :::::::::::: -->
173
174 <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='frontmatter']">
175  <h5><xsl:value-of select="meta/title[1]" /></h5>
176
177  <xsl:value-of select="$newline" />
178  <xsl:value-of select="$newline" />
179
180  <xsl:apply-templates />
181 </xsl:template>
182
183 <!-- ::::::::::: second-level main matter sections :::::::::::::: -->
184
185 <xsl:template match="/gamebook/section/data/section[@class='mainmatter']">
186  <xsl:call-template name="xhtml-wrapper">
187   <xsl:with-param name="document-type">second-level-mainmatter</xsl:with-param>
188   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
189  </xsl:call-template>
190 </xsl:template>
191
192 <!-- :::::::::::: third-level main matter sections ::::::::::::: -->
193
194 <xsl:template match="/gamebook/section/data/section/data/section[@class='mainmatter']">
195  <h3><xsl:value-of select="meta/title[1]" /></h3>
196
197  <xsl:value-of select="$newline" />
198  <xsl:value-of select="$newline" />
199
200  <xsl:apply-templates />
201 </xsl:template>
202
203 <xsl:template match="/gamebook/section/data/section/data/section[@class='mainmatter-separate']">
204  <xsl:call-template name="xhtml-wrapper">
205   <xsl:with-param name="document-type">third-level-mainmatter-separate</xsl:with-param>
206   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
207  </xsl:call-template>
208 </xsl:template>
209
210 <!-- :::::::::::: fourth-level main matter sections :::::::::::: -->
211
212 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='mainmatter']">
213  <h4><xsl:value-of select="meta/title[1]" /></h4>
214
215  <xsl:value-of select="$newline" />
216  <xsl:value-of select="$newline" />
217
218  <xsl:apply-templates />
219 </xsl:template>
220
221 <!-- ::::::::::::: fifth-level main matter sections :::::::::::: -->
222
223 <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='mainmatter']">
224  <h5><xsl:value-of select="meta/title[1]" /></h5>
225
226  <xsl:value-of select="$newline" />
227  <xsl:value-of select="$newline" />
228
229  <xsl:apply-templates />
230 </xsl:template>
231
232 <!-- :::::::::::: second-level glossary sections ::::::::::::: -->
233
234 <xsl:template match="/gamebook/section/data/section[@class='glossary']">
235  <xsl:call-template name="xhtml-wrapper">
236   <xsl:with-param name="document-type">second-level-glossary</xsl:with-param>
237   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
238   <xsl:with-param name="glossary-id-prefix">topics</xsl:with-param>
239  </xsl:call-template>
240 </xsl:template>
241
242 <!-- :::::::::::: third-level glossary sections ::::::::::::: -->
243 <!-- glossary sections should be enclosed in a second level glossary section -->
244
245 <xsl:template match="/gamebook/section/data/section/data/section[@class='glossary']">
246  <h3><xsl:value-of select="meta/title[1]" /></h3>
247
248  <xsl:value-of select="$newline" />
249  <xsl:value-of select="$newline" />
250
251  <xsl:apply-templates />
252 </xsl:template>
253
254 <xsl:template match="/gamebook/section/data/section/data/section[@class='glossary-separate']">
255  <xsl:call-template name="xhtml-wrapper">
256   <xsl:with-param name="document-type">third-level-glossary-separate</xsl:with-param>
257   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
258   <xsl:with-param name="glossary-id-prefix">topics</xsl:with-param>
259  </xsl:call-template>
260 </xsl:template>
261
262 <!-- :::::::::::::::::: numbered sections ::::::::::::::::::::::: -->
263
264 <xsl:template match="/gamebook/section/data/section[@class='numbered']">
265  <xsl:call-template name="xhtml-wrapper">
266   <xsl:with-param name="document-type">second-level-numbered</xsl:with-param>
267   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
268  </xsl:call-template>
269
270  <xsl:apply-templates />
271 </xsl:template>
272
273 <xsl:template match="/gamebook/section/data/section/data/section[@class='numbered']">
274  <xsl:call-template name="xhtml-wrapper">
275   <xsl:with-param name="document-type">third-level-numbered</xsl:with-param>
276   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
277  </xsl:call-template>
278 </xsl:template>
279
280 <!-- :::::::::::: second-level backmatter sections :::::::::::::: -->
281
282 <xsl:template match="/gamebook/section/data/section[@class='backmatter']">
283  <xsl:call-template name="xhtml-wrapper">
284   <xsl:with-param name="document-type">second-level-backmatter</xsl:with-param>
285   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
286  </xsl:call-template>
287 </xsl:template>
288
289 <!-- ::::::::::::: third-level back matter sections ::::::::::::: -->
290
291 <xsl:template match="/gamebook/section/data/section/data/section[@class='backmatter']">
292  <h3><xsl:value-of select="meta/title[1]" /></h3>
293
294  <xsl:value-of select="$newline" />
295  <xsl:value-of select="$newline" />
296
297  <xsl:apply-templates />
298 </xsl:template>
299
300 <!-- ::::::::::::: fourth-level back matter sections ::::::::::::: -->
301
302 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='backmatter']">
303  <h4><xsl:value-of select="meta/title[1]" /></h4>
304
305  <xsl:value-of select="$newline" />
306  <xsl:value-of select="$newline" />
307
308  <xsl:apply-templates />
309 </xsl:template>
310
311 <!-- ::::::::::::::::::::: map template ::::::::::::::::::::::::: -->
312
313 <xsl:template match="id( 'map' )">
314  <xsl:call-template name="xhtml-wrapper">
315   <xsl:with-param name="document-type">map-adjusted</xsl:with-param>
316   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
317  </xsl:call-template>
318
319  <xsl:call-template name="xhtml-wrapper">
320   <xsl:with-param name="document-type">map</xsl:with-param>
321   <xsl:with-param name="filename"><xsl:value-of select="@id" /><xsl:text>large</xsl:text></xsl:with-param>
322  </xsl:call-template>
323 </xsl:template>
324
325 <!-- ==================== block elements ======================== -->
326
327 <xsl:template match="p">
328  <p><xsl:apply-templates /></p>
329  <xsl:value-of select="$newline" />
330 </xsl:template>
331
332 <xsl:template match="p[@class='dedication']">
333  <p class="dedication"><xsl:apply-templates /></p>
334  <xsl:value-of select="$newline" />
335 </xsl:template>
336
337 <xsl:template match="dl[@class='paragraphed']/dd/node() | ol[@class='paragraphed']/li/node() | ul[@class='paragraphed']/li/node()">
338  <xsl:choose>
339   <xsl:when test="self::p">
340    <xsl:apply-templates /><br /><br /><xsl:value-of select="$newline" />
341   </xsl:when>
342   <xsl:when test="self::dl">
343    <dl><xsl:value-of select="$newline" />
344     <xsl:apply-templates />
345    </dl><br /><br /><xsl:value-of select="$newline" />
346   </xsl:when>
347   <xsl:when test="self::ol">
348    <ol><xsl:value-of select="$newline" />
349     <xsl:apply-templates />
350    </ol><br /><br /><xsl:value-of select="$newline" />
351   </xsl:when>
352   <xsl:when test="self::ul">
353    <ul>
354     <xsl:if test="self::*[@class='unbulleted']"><xsl:attribute name="class"><xsl:text>unbulleted</xsl:text></xsl:attribute></xsl:if>
355     <xsl:value-of select="$newline" />
356     <xsl:apply-templates />
357    </ul><br /><br /><xsl:value-of select="$newline" />
358   </xsl:when>
359   <xsl:when test="self::blockquote">
360    <blockquote><xsl:value-of select="$newline" />
361     <xsl:apply-templates />
362    </blockquote><xsl:value-of select="$newline" />
363   </xsl:when>
364   <xsl:when test="self::illustration">
365    <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
366    <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
367    <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
368
369    <xsl:if test="instance[@class='html'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
370     <div class="illustration"><div align="center"><xsl:value-of select="$newline" />
371      <table border="0" cellpadding="0" cellspacing="0"><xsl:value-of select="$newline" />
372       <tr><xsl:value-of select="$newline" />
373        <td><img src="brdrtpl.gif" width="32" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
374        <td><img src="brdrtp.gif" width="{$illustration-width}" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
375        <td><img src="brdrtpr.gif" width="32" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
376       </tr><xsl:value-of select="$newline" />
377       <tr><xsl:value-of select="$newline" />
378        <td><img src="brdrl.gif" width="32" height="{$illustration-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
379        <td><img src="{$illustration-src}" width="{$illustration-width}" height="{$illustration-height}" border="0" align="middle" alt="[illustration]" /></td><xsl:value-of select="$newline" />
380        <td><img src="brdrr.gif" width="32" height="{$illustration-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
381       </tr><xsl:value-of select="$newline" />
382       <tr><xsl:value-of select="$newline" />
383        <td><img src="brdrbtl.gif" width="32" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
384        <td><img src="brdrbt.gif" width="{$illustration-width}" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
385        <td><img src="brdrbtr.gif" width="32" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
386       </tr><xsl:value-of select="$newline" />
387      </table><br /><xsl:value-of select="$newline" />
388     </div></div><xsl:value-of select="$newline" />
389    </xsl:if>
390   </xsl:when>
391   <xsl:otherwise>
392    <xsl:text>[error: paragraphed list template]</xsl:text>
393   </xsl:otherwise>
394  </xsl:choose>
395 </xsl:template>
396
397 <xsl:template match="ol">
398  <ol><xsl:value-of select="$newline" />
399   <xsl:apply-templates />
400  </ol><xsl:value-of select="$newline" />
401 </xsl:template>
402
403 <xsl:template match="ul">
404  <ul>
405   <xsl:if test="self::*[@class='unbulleted']"><xsl:attribute name="class"><xsl:text>unbulleted</xsl:text></xsl:attribute></xsl:if>
406   <xsl:value-of select="$newline" />
407   <xsl:apply-templates />
408  </ul><xsl:value-of select="$newline" />
409 </xsl:template>
410
411 <xsl:template match="dl">
412  <dl><xsl:value-of select="$newline" />
413   <xsl:apply-templates />
414  </dl><xsl:value-of select="$newline" />
415 </xsl:template>
416
417 <xsl:template match="dt">
418  <dt><xsl:apply-templates /></dt>
419  <xsl:value-of select="$newline" />
420 </xsl:template>
421
422 <xsl:template match="dd">
423  <dd><xsl:apply-templates /></dd>
424  <xsl:value-of select="$newline" />
425 </xsl:template>
426
427 <xsl:template match="li">
428  <li><xsl:apply-templates /></li>
429  <xsl:value-of select="$newline" />
430 </xsl:template>
431
432 <xsl:template match="table">
433  <table border="1" cellspacing="0" cellpadding="2">
434   <xsl:apply-templates />
435  </table>
436  <xsl:value-of select="$newline" />
437 </xsl:template>
438
439 <xsl:template match="tr">
440  <tr>
441   <xsl:apply-templates />
442  </tr>
443 </xsl:template>
444
445 <xsl:template match="th">
446  <th>
447   <xsl:if test="@align"><xsl:attribute name="align"><xsl:value-of select="@align" /></xsl:attribute></xsl:if>
448   <xsl:if test="@valign"><xsl:attribute name="valign"><xsl:value-of select="@valign" /></xsl:attribute></xsl:if>
449   <xsl:if test="@char"><xsl:attribute name="char"><xsl:value-of select="@char" /></xsl:attribute></xsl:if>
450   <xsl:apply-templates />
451  </th>
452 </xsl:template>
453
454 <xsl:template match="td">
455  <td>
456   <xsl:if test="@align"><xsl:attribute name="align"><xsl:value-of select="@align" /></xsl:attribute></xsl:if>
457   <xsl:if test="@valign"><xsl:attribute name="valign"><xsl:value-of select="@valign" /></xsl:attribute></xsl:if>
458   <xsl:if test="@char"><xsl:attribute name="char"><xsl:value-of select="@char" /></xsl:attribute></xsl:if>
459   <xsl:apply-templates />
460  </td>
461 </xsl:template>
462
463 <xsl:template match="combat">
464  <p class="combat">
465   <xsl:apply-templates select="enemy" />
466   <xsl:text>: </xsl:text>
467   <xsl:choose>
468    <xsl:when test="enemy-attribute[@class='combatskill']">
469     <span class="smallcaps">COMBAT<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>SKILL</span>
470     <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
471     <xsl:value-of select="enemy-attribute[@class='combatskill']" />
472    </xsl:when>
473    <xsl:when test="enemy-attribute[@class='closecombatskill']">
474     <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>
475     <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
476     <xsl:value-of select="enemy-attribute[@class='closecombatskill']" />
477    </xsl:when>
478   </xsl:choose>
479   <xsl:text disable-output-escaping="yes"> &amp;nbsp;&amp;nbsp;</xsl:text>
480   <span class="smallcaps">ENDURANCE</span>
481   <xsl:choose>
482    <xsl:when test="enemy-attribute[@class='target']">
483     <xsl:text> (</xsl:text><span class="smallcaps">TARGET</span><xsl:text> points)</xsl:text>
484     <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
485     <xsl:value-of select="enemy-attribute[@class='target']" />
486    </xsl:when>
487    <xsl:when test="enemy-attribute[@class='resistance']">
488     <xsl:text> (</xsl:text><span class="smallcaps">RESISTANCE</span><xsl:text> points)</xsl:text>
489     <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
490     <xsl:value-of select="enemy-attribute[@class='resistance']" />
491    </xsl:when>
492    <xsl:otherwise>
493     <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
494     <xsl:value-of select="enemy-attribute[@class='endurance']" />
495    </xsl:otherwise>
496   </xsl:choose>
497  </p>
498  <xsl:value-of select="$newline" />
499 </xsl:template>
500
501 <xsl:template match="choice">
502  <xsl:variable name="link">
503   <xsl:value-of select="@idref" />
504  </xsl:variable>
505
506  <p class="choice">
507   <xsl:for-each select="* | text()">
508    <xsl:choose>
509     <xsl:when test="self::link-text">
510      <a href="{$link}.htm">
511       <xsl:apply-templates />
512      </a>
513     </xsl:when>
514     <xsl:otherwise>
515      <xsl:apply-templates select="." />
516     </xsl:otherwise>
517    </xsl:choose>
518   </xsl:for-each>
519  </p>
520  <xsl:value-of select="$newline" />
521 </xsl:template>
522
523 <xsl:template match="signpost">
524  <div class="signpost">
525   <xsl:apply-templates />
526  </div>
527  <xsl:value-of select="$newline" />
528 </xsl:template>
529
530 <xsl:template match="blockquote">
531  <blockquote><xsl:value-of select="$newline" />
532   <xsl:apply-templates /><xsl:value-of select="$newline" />
533  </blockquote><xsl:value-of select="$newline" />
534 </xsl:template>
535
536 <xsl:template match="illustration">
537  <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
538  <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
539  <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
540
541  <xsl:variable name="illustration-width-adjusted"><xsl:number value="$illustration-width div 2" /></xsl:variable>
542  <xsl:variable name="illustration-height-adjusted"><xsl:number value="$illustration-height div 2" /></xsl:variable>
543
544  <xsl:if test="instance[@class='html'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
545   <xsl:choose>
546    <xsl:when test="@class='float'">
547     <div class="illustration"><div align="center"><xsl:value-of select="$newline" />
548      <table border="0" cellpadding="0" cellspacing="0"><xsl:value-of select="$newline" />
549       <tr><xsl:value-of select="$newline" />
550        <td><img src="brdrtpl.gif" width="32" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
551        <td><img src="brdrtp.gif" width="{$illustration-width-adjusted}" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
552        <td><img src="brdrtpr.gif" width="32" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
553       </tr><xsl:value-of select="$newline" />
554       <tr><xsl:value-of select="$newline" />
555        <td><img src="brdrl.gif" width="32" height="{$illustration-height-adjusted}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
556         <td>
557         <a>
558          <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>
559          <img src="{$illustration-src}" width="{$illustration-width-adjusted}" height="{$illustration-height-adjusted}" border="0" align="middle" alt="[illustration]" />
560         </a>
561        </td><xsl:value-of select="$newline" />
562        <td><img src="brdrr.gif" width="32" height="{$illustration-height-adjusted}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
563       </tr><xsl:value-of select="$newline" />
564       <tr><xsl:value-of select="$newline" />
565        <td><img src="brdrbtl.gif" width="32" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
566        <td><img src="brdrbt.gif" width="{$illustration-width-adjusted}" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
567        <td><img src="brdrbtr.gif" width="32" height="32" align="middle" alt=""/></td><xsl:value-of select="$newline" />
568       </tr><xsl:value-of select="$newline" />
569      </table><br /><xsl:value-of select="$newline" />
570     </div></div><xsl:value-of select="$newline" />
571
572     <xsl:call-template name="xhtml-wrapper">
573      <xsl:with-param name="document-type">illustration</xsl:with-param>
574      <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>
575     </xsl:call-template>
576    </xsl:when>
577
578    <xsl:when test="@class='accent'" />
579
580    <xsl:otherwise>
581     <div class="illustration"><div align="center"><xsl:value-of select="$newline" />
582      <table border="0" cellpadding="0" cellspacing="0"><xsl:value-of select="$newline" />
583       <tr><xsl:value-of select="$newline" />
584        <td><img src="brdrtpl.gif" width="32" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
585        <td><img src="brdrtp.gif" width="{$illustration-width}" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
586        <td><img src="brdrtpr.gif" width="32" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
587       </tr><xsl:value-of select="$newline" />
588       <tr><xsl:value-of select="$newline" />
589        <td><img src="brdrl.gif" width="32" height="{$illustration-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
590        <td><img src="{$illustration-src}" width="{$illustration-width}" height="{$illustration-height}" border="0" align="middle" alt="[illustration]" /></td><xsl:value-of select="$newline" />
591        <td><img src="brdrr.gif" width="32" height="{$illustration-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
592       </tr><xsl:value-of select="$newline" />
593       <tr><xsl:value-of select="$newline" />
594        <td><img src="brdrbtl.gif" width="32" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
595        <td><img src="brdrbt.gif" width="{$illustration-width}" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
596        <td><img src="brdrbtr.gif" width="32" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
597       </tr><xsl:value-of select="$newline" />
598      </table><br /><xsl:value-of select="$newline" />
599     </div></div><xsl:value-of select="$newline" />
600    </xsl:otherwise>
601   </xsl:choose>
602
603  </xsl:if>
604 </xsl:template>
605
606 <xsl:template match="instance" />
607
608 <xsl:template match="footnotes" />
609
610 <xsl:template match="footnote" />
611
612 <xsl:template match="hr">
613  <hr />
614  <xsl:value-of select="$newline" />
615 </xsl:template>
616
617 <!-- ==================== inline elements ======================= -->
618
619 <xsl:template match="a">
620  <xsl:choose>
621   <xsl:when test="@href">
622    <a>
623     <xsl:attribute name="href"><xsl:value-of select="@href" /></xsl:attribute>
624     <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
625     <xsl:apply-templates />
626    </a>
627   </xsl:when>
628   <xsl:otherwise>
629    <a>
630     <xsl:if test="@idref">
631      <xsl:variable name="my-idref" select="@idref" />
632      <xsl:attribute name="href">
633       <xsl:choose>
634        <!-- The order of these tests is deliberate. They are ordered roughly from most to least specific. -->
635        <xsl:when test="/gamebook/section[@id=$my-idref] | /gamebook/section/data/section[@id=$my-idref]">
636         <xsl:value-of select="$my-idref" /><xsl:text>.htm</xsl:text>
637        </xsl:when>
638        <xsl:when test="/gamebook/section/data/section/data/section[@class='frontmatter-separate' and @id=$my-idref]">
639         <xsl:value-of select="$my-idref" /><xsl:text>.htm</xsl:text>
640        </xsl:when>
641        <xsl:when test="/gamebook/section/data/section/data/section[@class='mainmatter-separate' and @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='numbered' 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='glossary-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='frontmatter-separate' and descendant::*[@id=$my-idref]]">
651         <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" />
652        </xsl:when>
653        <xsl:when test="/gamebook/section/data/section/data/section[@class='mainmatter-separate' and descendant::*[@id=$my-idref]]">
654         <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" />
655        </xsl:when>
656        <xsl:when test="/gamebook/section/data/section/data/section[@class='glossary-separate' and descendant::*[@id=$my-idref]]">
657         <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" />
658        </xsl:when>
659        <xsl:when test="/gamebook/section/data/section[descendant::*[@id=$my-idref]]">
660         <xsl:value-of select="/gamebook/section/data/section[descendant::*[@id=$my-idref]]/@id" /><xsl:text>.htm#</xsl:text><xsl:value-of select="$my-idref" />
661        </xsl:when>
662        <xsl:otherwise>
663         <xsl:text>[error: a template]</xsl:text>
664        </xsl:otherwise>
665       </xsl:choose>
666      </xsl:attribute>
667     </xsl:if>
668     <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
669     <xsl:apply-templates />
670    </a>
671   </xsl:otherwise>
672  </xsl:choose>
673 </xsl:template>
674
675 <xsl:template match="a[@class='footnote']">
676  <xsl:apply-templates />
677  <sup>
678   <a>
679    <xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="@idref" /></xsl:attribute>
680    <xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute>
681    <xsl:number count="a[@class='footnote']" from="/" level="any" format="1" />
682   </a>
683  </sup>
684 </xsl:template>
685
686 <xsl:template match="a[@class='accent-illustration']">
687  <xsl:for-each select="id( @idref )">
688   <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
689   <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
690   <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
691   <xsl:if test="instance[@class='html'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
692    <img src="{$illustration-src}" class="accent" width="{$illustration-width}" height="{$illustration-height}" alt="" border="" align="left" />
693   </xsl:if>
694  </xsl:for-each>
695 </xsl:template>
696
697 <xsl:template match="em">
698  <em><xsl:apply-templates /></em>
699 </xsl:template>
700
701 <xsl:template match="strong">
702  <strong><xsl:apply-templates /></strong>
703 </xsl:template>
704
705 <xsl:template match="thought">
706  <i><xsl:apply-templates /></i>
707 </xsl:template>
708
709 <xsl:template match="onomatopoeia">
710  <i><xsl:apply-templates /></i>
711 </xsl:template>
712
713 <xsl:template match="spell">
714  <i><xsl:apply-templates /></i>
715 </xsl:template>
716
717 <xsl:template match="item">
718  <xsl:apply-templates />
719 </xsl:template>
720
721 <xsl:template match="foreign">
722  <i><xsl:apply-templates /></i>
723 </xsl:template>
724
725 <xsl:template match="quote">
726  <xsl:text>&apos;</xsl:text>
727   <xsl:apply-templates />
728  <xsl:text>&apos;</xsl:text>
729 </xsl:template>
730
731 <xsl:template match="quote//quote">
732  <xsl:text>&quot;</xsl:text>
733   <xsl:apply-templates />
734  <xsl:text>&quot;</xsl:text>
735 </xsl:template>
736
737 <xsl:template match="cite">
738  <cite><xsl:apply-templates /></cite>
739 </xsl:template>
740
741 <xsl:template match="code">
742  <tt><xsl:apply-templates /></tt>
743 </xsl:template>
744
745 <xsl:template match="br">
746  <br />
747 </xsl:template>
748
749 <xsl:template match="typ[@class='attribute']">
750  <span class="smallcaps"><xsl:apply-templates /></span>
751 </xsl:template>
752
753 <!-- ==================== named templates ======================= -->
754
755 <xsl:template name="xhtml-wrapper">
756  <xsl:param name="document-type">undefined</xsl:param>
757  <xsl:param name="filename">undefined</xsl:param>
758  <xsl:param name="glossary-id-prefix"></xsl:param>
759
760 <!-- <redirect:write file="{$book-path}/{$filename}.htm">-->
761  <redirect:write file="{$filename}.htm">
762   <xsl:fallback>
763    <xsl:text>xhtml-wrapper: Cannot write to filename: "</xsl:text>
764    <xsl:value-of select="$filename" /><xsl:text>.htm"</xsl:text>
765   </xsl:fallback>
766
767   <html xml:lang="en-UK" lang="en-UK">
768
769    <xsl:value-of select="$newline" />
770    <xsl:value-of select="$newline" />
771
772    <head><xsl:value-of select="$newline" />
773     <title>
774      <xsl:value-of select="/gamebook/meta/title[1]" />
775      <xsl:text>: </xsl:text>
776      <xsl:choose>
777       <xsl:when test="$document-type='illustration'">
778        <xsl:text>Illustration </xsl:text>
779        <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
780       </xsl:when>
781       <xsl:otherwise><xsl:value-of select="meta/title[1]" /></xsl:otherwise>
782      </xsl:choose>
783     </title><xsl:value-of select="$newline" />
784     <meta http-equiv="Content-type" content="text/html; charset=ISO-8859-1" /><xsl:value-of select="$newline" />
785     <meta name="robots" content="noindex,nofollow" /><xsl:value-of select="$newline" />
786     <link rel="stylesheet" href="main.css" type="text/css" /><xsl:value-of select="$newline" />
787    </head>
788
789    <xsl:value-of select="$newline" />
790    <xsl:value-of select="$newline" />
791
792    <xsl:comment>
793     <xsl:text> </xsl:text>
794     <xsl:apply-templates select="/gamebook/meta/rights[@class='copyrights']" />
795     <xsl:text> Published by </xsl:text>
796     <xsl:apply-templates select="/gamebook/meta/publisher[1]" />
797     <xsl:text>. </xsl:text>
798    </xsl:comment>
799
800    <xsl:value-of select="$newline" />
801    <xsl:value-of select="$newline" />
802
803    <body>
804     <xsl:attribute name="text"><xsl:value-of select="$text-color" /></xsl:attribute>
805     <xsl:attribute name="bgcolor"><xsl:value-of select="$background-color" /></xsl:attribute>
806     <xsl:attribute name="background"><xsl:text>bckgrnd.gif</xsl:text></xsl:attribute>
807     <xsl:attribute name="link"><xsl:value-of select="$link-color" /></xsl:attribute>
808     <xsl:attribute name="alink"><xsl:value-of select="$alink-color" /></xsl:attribute>
809     <xsl:attribute name="vlink"><xsl:value-of select="$vlink-color" /></xsl:attribute>
810
811     <xsl:value-of select="$newline" />
812     <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" />
813     <div id="body"><xsl:value-of select="$newline" />
814
815      <xsl:choose>
816
817 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~ top-level ~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
818
819       <xsl:when test="$document-type='top-level'">
820        <div class="frontmatter"><xsl:value-of select="$newline" />
821
822         <xsl:apply-templates select="/gamebook/meta/description[@class='blurb']" />
823         <xsl:apply-templates select="/gamebook/meta/creator[@class='long']" />
824
825         <hr />
826
827         <xsl:apply-templates select="/gamebook/meta/description[@class='publication']" />
828
829         <p>
830          <xsl:text>Publication Date: </xsl:text>
831          <xsl:value-of select="/gamebook/meta/date[@class='publication']/day" />
832          <xsl:text> </xsl:text>
833          <xsl:choose>
834           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 1">
835            <xsl:text>January</xsl:text>
836           </xsl:when>
837           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 2">
838            <xsl:text>February</xsl:text>
839           </xsl:when>
840           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 3">
841            <xsl:text>March</xsl:text>
842           </xsl:when>
843           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 4">
844            <xsl:text>April</xsl:text>
845           </xsl:when>
846           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 5">
847            <xsl:text>May</xsl:text>
848           </xsl:when>
849           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 6">
850            <xsl:text>June</xsl:text>
851           </xsl:when>
852           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 7">
853            <xsl:text>July</xsl:text>
854           </xsl:when>
855           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 8">
856            <xsl:text>August</xsl:text>
857           </xsl:when>
858           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 9">
859            <xsl:text>September</xsl:text>
860           </xsl:when>
861           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 10">
862            <xsl:text>October</xsl:text>
863           </xsl:when>
864           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 11">
865            <xsl:text>November</xsl:text>
866           </xsl:when>
867           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 12">
868            <xsl:text>December</xsl:text>
869           </xsl:when>
870           <xsl:otherwise>
871            <xsl:text>Invalid Month</xsl:text>
872           </xsl:otherwise>
873          </xsl:choose>
874          <xsl:text> </xsl:text>
875          <xsl:value-of select="/gamebook/meta/date[@class='publication']/year" />
876         </p>
877
878         <xsl:apply-templates select="/gamebook/meta/rights[@class='license-notification']" />
879
880         <xsl:value-of select="$newline" />
881
882         <xsl:call-template name="navigation-bar" />
883
884         <xsl:value-of select="$newline" />
885        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
886
887       </xsl:when>
888
889 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ toc ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
890
891       <xsl:when test="$document-type='toc'">
892        <div class="frontmatter"><xsl:value-of select="$newline" />
893         <h2>Table of Contents</h2><xsl:value-of select="$newline" />
894
895         <xsl:value-of select="$newline" />
896         <xsl:value-of select="$newline" />
897
898         <ul><xsl:value-of select="$newline" />
899          <li><a href="title.htm">Title Page</a></li><xsl:value-of select="$newline" />
900          <xsl:for-each select="/gamebook/section/data/section">
901           <li>
902            <a><xsl:attribute name="href"><xsl:value-of select="@id" /><xsl:text>.htm</xsl:text></xsl:attribute>
903             <xsl:value-of select="meta/title[1]" />
904            </a>
905            <xsl:if test="data/section[@class='frontmatter-separate' or @class='mainmatter-separate']">
906             <xsl:value-of select="$newline" />
907             <ul><xsl:value-of select="$newline" />
908              <xsl:for-each select="data/section[@class='frontmatter-separate' or @class='mainmatter-separate']">
909               <li>
910                <a><xsl:attribute name="href"><xsl:value-of select="@id" /><xsl:text>.htm</xsl:text></xsl:attribute>
911                 <xsl:value-of select ="meta/title[1]" />
912                </a>
913               </li><xsl:value-of select="$newline" />
914              </xsl:for-each>
915             </ul><xsl:value-of select="$newline" />
916            </xsl:if>
917           </li><xsl:value-of select="$newline" />
918          </xsl:for-each>
919         </ul><xsl:value-of select="$newline" />
920
921         <xsl:value-of select="$newline" />
922         <xsl:value-of select="$newline" />
923         <xsl:call-template name="navigation-bar" />
924        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
925       </xsl:when>
926
927 <!-- ~~~~~~~~~~~~~~~~ second-level-frontmatter ~~~~~~~~~~~~~~~~~~~ -->
928
929       <xsl:when test="$document-type='second-level-frontmatter'">
930        <div class="frontmatter"><xsl:value-of select="$newline" />
931         <h2><xsl:value-of select="meta/title" /></h2><xsl:value-of select="$newline" />
932
933         <xsl:value-of select="$newline" />
934
935         <xsl:apply-templates />
936
937         <xsl:value-of select="$newline" />
938
939         <xsl:call-template name="navigation-bar" />
940
941        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
942       </xsl:when>
943
944 <!-- ~~~~~~~~~~~~~ third-level-frontmatter-separate ~~~~~~~~~~~~~~ -->
945
946       <xsl:when test="$document-type='third-level-frontmatter-separate'">
947        <div class="frontmatter"><xsl:value-of select="$newline" />
948         <h3><xsl:value-of select="meta/title" /></h3><xsl:value-of select="$newline" />
949         <xsl:value-of select="$newline" />
950
951         <xsl:apply-templates />
952
953         <xsl:value-of select="$newline" />
954
955         <xsl:call-template name="navigation-bar" />
956
957        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
958       </xsl:when>
959
960 <!-- ~~~~~~~~~~~~~~~~ second-level-mainmatter ~~~~~~~~~~~~~~~~~~~ -->
961
962       <xsl:when test="$document-type='second-level-mainmatter'">
963        <div class="mainmatter"><xsl:value-of select="$newline" />
964         <h2><xsl:value-of select="meta/title" /></h2><xsl:value-of select="$newline" />
965         <xsl:value-of select="$newline" />
966
967         <xsl:apply-templates />
968
969         <xsl:value-of select="$newline" />
970
971         <xsl:call-template name="navigation-bar" />
972
973        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
974       </xsl:when>
975
976 <!-- ~~~~~~~~~~~~~ third-level-mainmatter-separate ~~~~~~~~~~~~~~ -->
977
978       <xsl:when test="$document-type='third-level-mainmatter-separate'">
979        <div class="mainmatter"><xsl:value-of select="$newline" />
980         <h3><xsl:value-of select="meta/title" /></h3><xsl:value-of select="$newline" />
981         <xsl:value-of select="$newline" />
982
983         <xsl:apply-templates />
984
985         <xsl:value-of select="$newline" />
986
987         <xsl:call-template name="navigation-bar" />
988
989        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
990       </xsl:when>
991
992 <!-- ~~~~~~~~~~~~~~~~ second-level-glossary ~~~~~~~~~~~~~~~~~~~ -->
993
994       <xsl:when test="$document-type='second-level-glossary'">
995        <div class="mainmatter"><xsl:value-of select="$newline" />
996         <h2><xsl:value-of select="meta/title" /></h2><xsl:value-of select="$newline" />
997         <xsl:value-of select="$newline" />
998
999         <xsl:apply-templates />
1000
1001         <xsl:value-of select="$newline" />
1002
1003         <xsl:call-template name="alpha-bar">
1004          <xsl:with-param name="alpha-bar-id-prefix"><xsl:value-of select="$glossary-id-prefix" /></xsl:with-param>
1005         </xsl:call-template>
1006
1007         <xsl:call-template name="navigation-bar" />
1008
1009        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1010       </xsl:when>
1011
1012 <!-- ~~~~~~~~~~~~~ third-level-glossary-separate ~~~~~~~~~~~~~~ -->
1013
1014       <xsl:when test="$document-type='third-level-glossary-separate'">
1015        <div class="glossary"><xsl:value-of select="$newline" />
1016         <h3><xsl:value-of select="meta/title" /></h3><xsl:value-of select="$newline" />
1017         <xsl:call-template name="alpha-bar">
1018          <xsl:with-param name="alpha-bar-id-prefix"><xsl:value-of select="$glossary-id-prefix" /></xsl:with-param>
1019         </xsl:call-template>
1020
1021         <xsl:value-of select="$newline" />
1022
1023         <xsl:apply-templates />
1024
1025         <xsl:value-of select="$newline" />
1026
1027         <xsl:call-template name="navigation-bar" />
1028         <xsl:value-of select="$newline" />
1029        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1030       </xsl:when>
1031
1032 <!-- ~~~~~~~~~~~~~~~~~~ second-level-numbered ~~~~~~~~~~~~~~~~~~~~ -->
1033 <!--
1034
1035 The following automatically generated section list requires that the
1036 title of each section be a simple number.
1037
1038 -->
1039       <xsl:when test="$document-type='second-level-numbered'">
1040        <div class="numbered"><xsl:value-of select="$newline" />
1041         <h2><xsl:value-of select="meta/title" /></h2><xsl:value-of select="$newline" />
1042         <xsl:value-of select="$newline" />
1043
1044         <xsl:variable name="base-section-number" select="number( data/section[1]/meta/title ) - 1" />
1045         <p>
1046          <xsl:for-each select="data/section">
1047           <xsl:if test="position( ) mod 10 = 1">
1048            <b><a><xsl:attribute name="name"><xsl:value-of select="position( ) + $base-section-number" /></xsl:attribute>
1049             <xsl:value-of select="position( ) + $base-section-number" />
1050             <xsl:if test="not( position( ) = last( ) )">
1051              <xsl:text>-</xsl:text>
1052              <xsl:choose>
1053               <xsl:when test="position( ) + 9 &lt;= last( )">
1054                <xsl:value-of select="position( ) + 9 + $base-section-number" />
1055               </xsl:when>
1056               <xsl:otherwise>
1057                <xsl:value-of select="last( ) + $base-section-number" />
1058               </xsl:otherwise>
1059              </xsl:choose>
1060             </xsl:if>
1061            </a><xsl:text>: </xsl:text></b>
1062           </xsl:if>
1063           <a>
1064            <xsl:attribute name="href"><xsl:value-of select="@id" /><xsl:text>.htm</xsl:text></xsl:attribute>
1065            <xsl:value-of select="meta/title" />
1066           </a>
1067           <xsl:choose>
1068            <xsl:when test="position( ) mod 10 = 0">
1069             <br /><xsl:value-of select="$newline" />
1070            </xsl:when>
1071            <xsl:otherwise>
1072             <xsl:text> </xsl:text>
1073            </xsl:otherwise>
1074           </xsl:choose>
1075          </xsl:for-each>
1076         </p>
1077
1078         <xsl:value-of select="$newline" />
1079         <xsl:value-of select="$newline" />
1080
1081         <xsl:call-template name="navigation-bar" />
1082         <xsl:value-of select="$newline" />
1083        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1084       </xsl:when>
1085
1086 <!-- ~~~~~~~~~~~~~~~~~~ third-level-numbered ~~~~~~~~~~~~~~~~~~~~~ -->
1087
1088       <xsl:when test="$document-type='third-level-numbered'">
1089        <div class="numbered"><xsl:value-of select="$newline" />
1090         <h3><xsl:value-of select="meta/title" /></h3><xsl:value-of select="$newline" />
1091         <xsl:value-of select="$newline" />
1092
1093         <xsl:apply-templates />
1094
1095         <xsl:value-of select="$newline" />
1096         <xsl:call-template name="navigation-bar" />
1097         <xsl:value-of select="$newline" />
1098        </div>
1099       </xsl:when>
1100
1101 <!-- ~~~~~~~~~~~~~~~~~ second-level-backmatter ~~~~~~~~~~~~~~~~~~~ -->
1102
1103       <xsl:when test="$document-type='second-level-backmatter'">
1104        <div class="frontmatter"><xsl:value-of select="$newline" />
1105         <h2><xsl:value-of select="meta/title" /></h2><xsl:value-of select="$newline" />
1106
1107         <xsl:value-of select="$newline" />
1108         <xsl:value-of select="$newline" />
1109
1110         <xsl:apply-templates />
1111
1112         <xsl:value-of select="$newline" />
1113
1114         <xsl:call-template name="navigation-bar" />
1115         <xsl:value-of select="$newline" />
1116        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1117       </xsl:when>
1118
1119 <!-- ~~~~~~~~~~~~~~~~~~~~~~~ map-adjusted ~~~~~~~~~~~~~~~~~~~~~~~~ -->
1120
1121       <xsl:when test="$document-type='map-adjusted'">
1122        <div class="frontmatter"><xsl:value-of select="$newline" />
1123         <h2><xsl:value-of select="meta/title" /></h2><xsl:value-of select="$newline" />
1124
1125         <xsl:value-of select="$newline" />
1126         <xsl:value-of select="$newline" />
1127
1128         <xsl:for-each select="data/* | data/text()">
1129          <xsl:choose>
1130           <xsl:when test="self::illustration and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
1131            <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
1132            <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
1133            <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
1134
1135            <xsl:variable name="illustration-width-adjusted"><xsl:number value="386" /></xsl:variable>
1136            <xsl:variable name="illustration-height-adjusted"><xsl:number value="$illustration-height * $illustration-width-adjusted div $illustration-width" /></xsl:variable>
1137
1138            <div class="illustration"><div align="center"><xsl:value-of select="$newline" />
1139             <table border="0" cellpadding="0" cellspacing="0"><xsl:value-of select="$newline" />
1140              <tr><xsl:value-of select="$newline" />
1141               <td><img src="brdrtpl.gif" width="31" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1142               <td><img src="brdrtp.gif" width="{$illustration-width-adjusted}" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1143               <td><img src="brdrtpr.gif" width="33" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1144              </tr><xsl:value-of select="$newline" />
1145              <tr><xsl:value-of select="$newline" />
1146               <td><img src="brdrl.gif" width="31" height="{$illustration-height-adjusted}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1147               <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" />
1148               <td><img src="brdrr.gif" width="33" height="{$illustration-height-adjusted}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1149              </tr><xsl:value-of select="$newline" />
1150              <tr><xsl:value-of select="$newline" />
1151               <td><img src="brdrbtl.gif" width="31" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1152               <td><img src="brdrbt.gif" width="{$illustration-width-adjusted}" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1153               <td><img src="brdrbtr.gif" width="33" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1154              </tr><xsl:value-of select="$newline" />
1155             </table><xsl:value-of select="$newline" />
1156             <br /><br />
1157            </div></div><xsl:value-of select="$newline" />
1158           </xsl:when>
1159           <xsl:otherwise>
1160            <xsl:apply-templates select="." />
1161           </xsl:otherwise>
1162          </xsl:choose>
1163         </xsl:for-each>
1164
1165         <xsl:value-of select="$newline" />
1166
1167         <xsl:call-template name="navigation-bar" />
1168         <xsl:value-of select="$newline" />
1169        </div>
1170       </xsl:when>
1171
1172 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ map ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
1173
1174       <xsl:when test="$document-type='map'">
1175        <div class="frontmatter"><xsl:value-of select="$newline" />
1176         <h2><xsl:value-of select="meta/title" /></h2><xsl:value-of select="$newline" />
1177
1178         <xsl:value-of select="$newline" />
1179         <xsl:value-of select="$newline" />
1180
1181         <xsl:for-each select="data/* | data/text()">
1182          <xsl:choose>
1183           <xsl:when test="self::illustration and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
1184            <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
1185            <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
1186            <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
1187
1188            <div class="illustration"><div align="center"><xsl:value-of select="$newline" />
1189             <table border="0" cellpadding="0" cellspacing="0"><xsl:value-of select="$newline" />
1190              <tr><xsl:value-of select="$newline" />
1191               <td><img src="brdrtpl.gif" width="31" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1192               <td><img src="brdrtp.gif" width="{$illustration-width}" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1193               <td><img src="brdrtpr.gif" width="33" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1194              </tr><xsl:value-of select="$newline" />
1195              <tr><xsl:value-of select="$newline" />
1196               <td><img src="brdrl.gif" width="31"  height="{$illustration-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1197               <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" />
1198               <td><img src="brdrr.gif" width="33" height="{$illustration-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1199              </tr><xsl:value-of select="$newline" />
1200              <tr><xsl:value-of select="$newline" />
1201               <td><img src="brdrbtl.gif" width="31" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1202               <td><img src="brdrbt.gif" width="{$illustration-width}" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1203               <td><img src="brdrbtr.gif" width="33" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1204              </tr><xsl:value-of select="$newline" />
1205             </table><br /><xsl:value-of select="$newline" />
1206            </div></div><xsl:value-of select="$newline" />
1207           </xsl:when>
1208           <xsl:otherwise>
1209            <xsl:apply-templates select="." />
1210           </xsl:otherwise>
1211          </xsl:choose>
1212         </xsl:for-each>
1213
1214         <xsl:value-of select="$newline" />
1215
1216         <xsl:call-template name="navigation-bar" />
1217         <xsl:value-of select="$newline" />
1218        </div>
1219       </xsl:when>
1220
1221 <!-- ~~~~~~~~~~~~~~~~~~~~~~ illustration ~~~~~~~~~~~~~~~~~~~~~~~~~ -->
1222
1223       <xsl:when test="$document-type='illustration'">
1224        <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
1225        <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
1226        <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
1227
1228        <h3>
1229         <xsl:text>Illustration </xsl:text>
1230         <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
1231        </h3><xsl:value-of select="$newline" />
1232
1233        <div class="illustration"><div align="center"><xsl:value-of select="$newline" />
1234         <table border="0" cellpadding="0" cellspacing="0"><xsl:value-of select="$newline" />
1235          <tr><xsl:value-of select="$newline" />
1236           <td><img src="brdrtpl.gif" width="31" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1237           <td><img src="brdrtp.gif" width="{$illustration-width}" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1238           <td><img src="brdrtpr.gif" width="33" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1239          </tr><xsl:value-of select="$newline" />
1240          <tr><xsl:value-of select="$newline" />
1241           <td><img src="brdrl.gif" width="31" height="{$illustration-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1242           <td><img src="{$illustration-src}" width="{$illustration-width}" height="{$illustration-height}" align="middle" border="0" alt="[illustration]" /></td><xsl:value-of select="$newline" />
1243           <td><img src="brdrr.gif" width="33" height="{$illustration-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1244          </tr><xsl:value-of select="$newline" />
1245          <tr><xsl:value-of select="$newline" />
1246           <td><img src="brdrbtl.gif" width="31" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1247           <td><img src="brdrbt.gif" width="{$illustration-width}" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1248           <td><img src="brdrbtr.gif" width="33" height="32" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1249          </tr><xsl:value-of select="$newline" />
1250         </table><br /><xsl:value-of select="$newline" />
1251        </div></div><xsl:value-of select="$newline" />
1252        <p class="caption"><strong><xsl:apply-templates select="meta/description" /></strong></p><xsl:value-of select="$newline" />
1253       </xsl:when>
1254
1255 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~ error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
1256
1257       <xsl:otherwise>
1258        <xsl:message>
1259         <xsl:text>xhtml-wrapper: Cannot process document of type "</xsl:text>
1260         <xsl:value-of select="$document-type" />
1261         <xsl:text>".</xsl:text>
1262        </xsl:message>
1263        <p>
1264         <xsl:text>xhtml-wrapper: Cannot process document of type "</xsl:text>
1265         <xsl:value-of select="$document-type" />
1266         <xsl:text>".</xsl:text>
1267        </p>
1268       </xsl:otherwise>
1269
1270      </xsl:choose>
1271
1272 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~ footer ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
1273
1274      <xsl:call-template name="process-footnotes" />
1275
1276      <p class="copyright"><xsl:apply-templates select="/gamebook/meta/rights[@class='copyrights']" /></p><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1277
1278     </div><xsl:value-of select="$newline" />
1279
1280     <map name="imagemap" id="imagemap">
1281      <area shape="rect" coords="0,0,99,99" href="http://www.projectaon.org/" alt="Project Aon" target="_top" />
1282      <area shape="default" href="title.htm">
1283       <xsl:attribute name="alt"><xsl:value-of select="/gamebook/meta/title[1]" /></xsl:attribute>
1284      </area>
1285     </map>
1286
1287    </body>
1288
1289    <xsl:value-of select="$newline" />
1290    <xsl:value-of select="$newline" />
1291
1292   </html>
1293  </redirect:write>
1294
1295 </xsl:template>
1296
1297 <xsl:template name="process-footnotes">
1298  <xsl:if test="footnotes/footnote">
1299   <div id="footnotes"><xsl:value-of select="$newline" />
1300    <xsl:for-each select="footnotes/footnote">
1301     <xsl:variable name="footnote-idref" select="@idref" />
1302     <xsl:variable name="footnote-id" select="@id" />
1303     <xsl:variable name="footnote-marker"><xsl:number count="footnotes/footnote" from="/" level="any" format="1" /></xsl:variable>
1304
1305     <xsl:for-each select="*[1]">
1306      <p>
1307       <xsl:text>[</xsl:text>
1308        <a href="#{$footnote-idref}" name="{$footnote-id}"><xsl:value-of select="$footnote-marker" /></a>
1309       <xsl:text>] </xsl:text>
1310       <xsl:apply-templates select="child::* | child::text()" />
1311      </p>
1312     </xsl:for-each>
1313
1314     <xsl:for-each select="*[position() != 1]">
1315       <xsl:apply-templates select="." />
1316     </xsl:for-each>
1317    </xsl:for-each>
1318   </div><xsl:value-of select="$newline" />
1319  </xsl:if>
1320 </xsl:template>
1321
1322 <xsl:template name="navigation-bar">
1323  <div class="navigation">
1324   <table cellspacing="0" cellpadding="0" border="0">
1325    <tr>
1326     <td>
1327      <xsl:choose>
1328       <xsl:when test="meta/link[@class='prev']">
1329        <a>
1330         <xsl:attribute name="href">
1331          <xsl:value-of select="meta/link[@class='prev']/@idref" />
1332          <xsl:text>.htm</xsl:text>
1333         </xsl:attribute>
1334         <img src="back.gif" width="150" height="30" border="0">
1335          <xsl:attribute name="alt">
1336           <xsl:value-of select="id( meta/link[@class='prev']/@idref )/meta/title" />
1337          </xsl:attribute>
1338         </img>
1339        </a>
1340       </xsl:when>
1341       <xsl:otherwise>
1342        <img src="left.gif" width="150" height="30" border="0" alt="" />
1343       </xsl:otherwise>
1344      </xsl:choose>
1345     </td>
1346     <td><a href="toc.htm"><img src="toc.gif" width="150" height="30" border="0" alt="Table of Contents" /></a></td>
1347     <td>
1348      <xsl:choose>
1349       <xsl:when test="meta/link[@class='next']">
1350        <a>
1351         <xsl:attribute name="href">
1352          <xsl:value-of select="meta/link[@class='next']/@idref" />
1353          <xsl:text>.htm</xsl:text>
1354         </xsl:attribute>
1355         <img src="forward.gif" width="150" height="30" border="0">
1356          <xsl:attribute name="alt">
1357           <xsl:choose>
1358            <xsl:when test="meta/link[@class='next']/@idref = 'sect1'">
1359             <xsl:text>Section 1</xsl:text>
1360            </xsl:when>
1361            <xsl:otherwise>
1362             <xsl:value-of select="id( meta/link[@class='next']/@idref )/meta/title" />
1363            </xsl:otherwise>
1364           </xsl:choose>
1365          </xsl:attribute>
1366         </img>
1367        </a>
1368       </xsl:when>
1369       <xsl:otherwise>
1370        <img src="right.gif" width="150" height="30" border="0" alt="" />
1371       </xsl:otherwise>
1372      </xsl:choose>
1373     </td>
1374    </tr>
1375   </table>
1376  </div>
1377 </xsl:template>
1378
1379 <xsl:template name="alpha-bar">
1380  <xsl:param name="alpha-bar-id-prefix"></xsl:param>
1381
1382   <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" />
1383
1384 </xsl:template>
1385
1386 </xsl:transform>