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