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