Make it possible to generate new book design
[project-aon.git] / common / xsl / xhtml-compatible.xsl
1 <?xml version="1.0"?>
2 <!DOCTYPE xsl:transform [
3  <!ENTITY % xhtml.characters SYSTEM "../../en/xml/htmlchar.mod">
4  %xhtml.characters;
5 ]>
6
7 <!--
8
9 Todo:
10
11 * Add blank whitespace handling to the paragraphed list template
12
13 -->
14
15 <xsl:transform version="1.0"
16   xmlns="http://www.w3.org/1999/xhtml"
17   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
18   xmlns:redirect="org.apache.xalan.lib.Redirect"
19   extension-element-prefixes="redirect">
20
21 <xsl:output method="xml"
22             encoding="ISO-8859-1"
23             omit-xml-declaration="yes"
24             doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
25             doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
26
27 <xsl:strip-space elements="section data ol ul dl li dd footnotes footnote" />
28 <xsl:preserve-space elements="p choice" />
29
30 <!-- ====================== parameters ========================== -->
31
32 <xsl:param name="use-illustrators" />
33 <xsl:param name="language"><xsl:text>en</xsl:text></xsl:param>
34  
35 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~ colors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
36
37 <xsl:param name="link-color"><xsl:text>#ff0000</xsl:text></xsl:param>
38 <xsl:param name="alink-color"><xsl:value-of select="$link-color" /></xsl:param>
39 <xsl:param name="vlink-color"><xsl:value-of select="$link-color" /></xsl:param>
40
41 <xsl:param name="text-color"><xsl:text>#000000</xsl:text></xsl:param>
42 <xsl:param name="background-color"><xsl:text>#ffffe4</xsl:text></xsl:param>
43
44 <!-- ======================= variables ========================== -->
45
46 <xsl:variable name="newline">
47 <xsl:text>
48 </xsl:text>
49 </xsl:variable>
50
51 <!-- ======================== Templates ========================= -->
52
53 <!-- ================= hierarchical sections ==================== -->
54
55 <xsl:template match="meta" />
56 <xsl:template match="section" />
57
58 <!-- ::::::::::::::::::: top-level section :::::::::::::::::::::: -->
59
60 <xsl:template match="/gamebook/section[@id='title']">
61  <xsl:call-template name="xhtml-wrapper">
62   <xsl:with-param name="document-type">top-level</xsl:with-param>
63   <xsl:with-param name="filename">title</xsl:with-param>
64  </xsl:call-template>
65
66  <xsl:apply-templates />
67 </xsl:template>
68
69 <xsl:template match="/gamebook/section[@id='toc']">
70  <xsl:call-template name="xhtml-wrapper">
71   <xsl:with-param name="document-type">toc</xsl:with-param>
72   <xsl:with-param name="filename">toc</xsl:with-param>
73  </xsl:call-template>
74
75  <xsl:apply-templates />
76 </xsl:template>
77
78 <!-- ::::::::::: second-level frontmatter sections :::::::::::::: -->
79
80 <xsl:template match="/gamebook/section/data/section[@class='frontmatter']">
81  <xsl:call-template name="xhtml-wrapper">
82   <xsl:with-param name="document-type">second-level-frontmatter</xsl:with-param>
83   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
84  </xsl:call-template>
85 </xsl:template>
86
87 <!-- :::::::::::: third-level front matter sections ::::::::::::: -->
88
89 <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter']">
90  <h3><xsl:apply-templates select="meta/title[1]" /></h3>
91
92  <xsl:value-of select="$newline" />
93  <xsl:value-of select="$newline" />
94
95  <xsl:apply-templates />
96 </xsl:template>
97
98 <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter-separate']">
99  <xsl:call-template name="xhtml-wrapper">
100   <xsl:with-param name="document-type">third-level-frontmatter-separate</xsl:with-param>
101   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
102  </xsl:call-template>
103 </xsl:template>
104
105 <!-- :::::::::::: fourth-level front matter sections :::::::::::: -->
106
107 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='frontmatter']">
108  <h4><xsl:apply-templates select="meta/title[1]" /></h4>
109
110  <xsl:value-of select="$newline" />
111  <xsl:value-of select="$newline" />
112
113  <xsl:apply-templates />
114 </xsl:template>
115
116 <!-- ::::::::::::: fifth-level front matter sections :::::::::::: -->
117
118 <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='frontmatter']">
119  <h5><xsl:apply-templates select="meta/title[1]" /></h5>
120
121  <xsl:value-of select="$newline" />
122  <xsl:value-of select="$newline" />
123
124  <xsl:apply-templates />
125 </xsl:template>
126
127 <!-- ::::::::::: second-level main matter sections :::::::::::::: -->
128
129 <xsl:template match="/gamebook/section/data/section[@class='mainmatter']">
130  <xsl:call-template name="xhtml-wrapper">
131   <xsl:with-param name="document-type">second-level-mainmatter</xsl:with-param>
132   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
133  </xsl:call-template>
134 </xsl:template>
135
136 <!-- :::::::::::: third-level main matter sections ::::::::::::: -->
137
138 <xsl:template match="/gamebook/section/data/section/data/section[@class='mainmatter']">
139  <h3><xsl:apply-templates select="meta/title[1]" /></h3>
140
141  <xsl:value-of select="$newline" />
142  <xsl:value-of select="$newline" />
143
144  <xsl:apply-templates />
145 </xsl:template>
146
147 <xsl:template match="/gamebook/section/data/section/data/section[@class='mainmatter-separate']">
148  <xsl:call-template name="xhtml-wrapper">
149   <xsl:with-param name="document-type">third-level-mainmatter-separate</xsl:with-param>
150   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
151  </xsl:call-template>
152 </xsl:template>
153
154 <!-- :::::::::::: fourth-level main matter sections :::::::::::: -->
155
156 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='mainmatter']">
157  <h4><xsl:apply-templates select="meta/title[1]" /></h4>
158
159  <xsl:value-of select="$newline" />
160  <xsl:value-of select="$newline" />
161
162  <xsl:apply-templates />
163 </xsl:template>
164
165 <!-- ::::::::::::: fifth-level main matter sections :::::::::::: -->
166
167 <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='mainmatter']">
168  <h5><xsl:apply-templates select="meta/title[1]" /></h5>
169
170  <xsl:value-of select="$newline" />
171  <xsl:value-of select="$newline" />
172
173  <xsl:apply-templates />
174 </xsl:template>
175
176 <!-- :::::::::::: second-level glossary sections ::::::::::::: -->
177
178 <xsl:template match="/gamebook/section/data/section[@class='glossary']">
179  <xsl:call-template name="xhtml-wrapper">
180   <xsl:with-param name="document-type">second-level-glossary</xsl:with-param>
181   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
182   <xsl:with-param name="glossary-id-prefix">topics</xsl:with-param>
183  </xsl:call-template>
184 </xsl:template>
185
186 <!-- :::::::::::: third-level glossary sections ::::::::::::: -->
187 <!-- glossary sections should be enclosed in a second level glossary section -->
188
189 <xsl:template match="/gamebook/section/data/section/data/section[@class='glossary']">
190  <h3><xsl:apply-templates select="meta/title[1]" /></h3>
191
192  <xsl:value-of select="$newline" />
193  <xsl:value-of select="$newline" />
194
195  <xsl:apply-templates />
196 </xsl:template>
197
198 <xsl:template match="/gamebook/section/data/section/data/section[@class='glossary-separate']">
199  <xsl:call-template name="xhtml-wrapper">
200   <xsl:with-param name="document-type">third-level-glossary-separate</xsl:with-param>
201   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
202   <xsl:with-param name="glossary-id-prefix">topics</xsl:with-param>
203  </xsl:call-template>
204 </xsl:template>
205
206 <!-- :::::::::::::::::: numbered sections ::::::::::::::::::::::: -->
207
208 <xsl:template match="/gamebook/section/data/section[@class='numbered']">
209  <xsl:call-template name="xhtml-wrapper">
210   <xsl:with-param name="document-type">second-level-numbered</xsl:with-param>
211   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
212  </xsl:call-template>
213
214  <xsl:apply-templates />
215 </xsl:template>
216
217 <xsl:template match="/gamebook/section/data/section/data/section[@class='numbered']">
218  <xsl:call-template name="xhtml-wrapper">
219   <xsl:with-param name="document-type">third-level-numbered</xsl:with-param>
220   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
221  </xsl:call-template>
222 </xsl:template>
223
224 <!-- :::::::::::: second-level backmatter sections :::::::::::::: -->
225
226 <xsl:template match="/gamebook/section/data/section[@class='backmatter']">
227  <xsl:call-template name="xhtml-wrapper">
228   <xsl:with-param name="document-type">second-level-backmatter</xsl:with-param>
229   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
230  </xsl:call-template>
231 </xsl:template>
232
233 <!-- ::::::::::::: third-level back matter sections ::::::::::::: -->
234
235 <xsl:template match="/gamebook/section/data/section/data/section[@class='backmatter']">
236  <h3><xsl:apply-templates select="meta/title[1]" /></h3>
237
238  <xsl:value-of select="$newline" />
239  <xsl:value-of select="$newline" />
240
241  <xsl:apply-templates />
242 </xsl:template>
243
244 <!-- ::::::::::::: fourth-level back matter sections ::::::::::::: -->
245
246 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='backmatter']">
247  <h4><xsl:apply-templates select="meta/title[1]" /></h4>
248
249  <xsl:value-of select="$newline" />
250  <xsl:value-of select="$newline" />
251
252  <xsl:apply-templates />
253 </xsl:template>
254
255 <!-- ::::::::::::::::::::: map template ::::::::::::::::::::::::: -->
256
257 <xsl:template match="id( 'map' )">
258  <xsl:call-template name="xhtml-wrapper">
259   <xsl:with-param name="document-type">map-adjusted</xsl:with-param>
260   <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
261  </xsl:call-template>
262
263  <xsl:call-template name="xhtml-wrapper">
264   <xsl:with-param name="document-type">map</xsl:with-param>
265   <xsl:with-param name="filename"><xsl:value-of select="@id" /><xsl:text>large</xsl:text></xsl:with-param>
266  </xsl:call-template>
267 </xsl:template>
268
269 <!-- ::::::::::::::::::::: footnotes template ::::::::::::::::::::::::: -->
270
271 <xsl:template match="id( 'footnotz' )">
272  <xsl:choose>
273   <!-- Backwards compatibility measure - if there is data content, use that, otherwise generate footnotes list -->
274   <xsl:when test="count( data/p ) = 0">
275    <xsl:call-template name="xhtml-wrapper">
276     <xsl:with-param name="document-type">footnotz</xsl:with-param>
277     <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
278    </xsl:call-template>
279   </xsl:when>
280   <xsl:otherwise>
281    <xsl:call-template name="xhtml-wrapper">
282     <xsl:with-param name="document-type">second-level-backmatter</xsl:with-param>
283     <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
284    </xsl:call-template>
285   </xsl:otherwise>
286  </xsl:choose>
287  <xsl:apply-templates />
288 </xsl:template>
289
290 <!-- ==================== block elements ======================== -->
291
292 <xsl:template match="p">
293  <p><xsl:apply-templates /></p>
294  <xsl:value-of select="$newline" />
295 </xsl:template>
296
297 <xsl:template match="p[@class='dedication']">
298  <p class="dedication"><xsl:apply-templates /></p>
299  <xsl:value-of select="$newline" />
300 </xsl:template>
301
302 <xsl:template match="dl[@class='paragraphed']/dd/node() | ol[@class='paragraphed']/li/node() | ul[@class='paragraphed']/li/node()">
303  <xsl:choose>
304   <xsl:when test="self::p">
305    <xsl:apply-templates /><br /><br /><xsl:value-of select="$newline" />
306   </xsl:when>
307   <xsl:when test="self::dl">
308    <dl><xsl:value-of select="$newline" />
309     <xsl:apply-templates />
310    </dl><br /><br /><xsl:value-of select="$newline" />
311   </xsl:when>
312   <xsl:when test="self::ol">
313    <ol><xsl:value-of select="$newline" />
314     <xsl:apply-templates />
315    </ol><br /><br /><xsl:value-of select="$newline" />
316   </xsl:when>
317   <xsl:when test="self::ul">
318    <ul>
319     <xsl:if test="self::*[@class='unbulleted']"><xsl:attribute name="class"><xsl:text>unbulleted</xsl:text></xsl:attribute></xsl:if>
320     <xsl:value-of select="$newline" />
321     <xsl:apply-templates />
322    </ul><br /><br /><xsl:value-of select="$newline" />
323   </xsl:when>
324   <xsl:when test="self::blockquote">
325    <blockquote><xsl:value-of select="$newline" />
326     <xsl:apply-templates />
327    </blockquote><xsl:value-of select="$newline" />
328   </xsl:when>
329   <xsl:when test="self::illustration">
330    <!-- Backwards compatibility code -->
331    <xsl:variable name="illustration-width" select="instance[@class='html-compatible']/@width" />
332    <xsl:variable name="illustration-height" select="instance[@class='html-compatible']/@height" />
333    <xsl:variable name="illustration-src" select="instance[@class='html-compatible']/@src" />
334
335    <xsl:if test="instance[@class='html-compatible'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
336     <div class="illustration">
337      <div align="center"><xsl:value-of select="$newline" />
338      <xsl:call-template name="illustration-framed">
339       <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width" /></xsl:with-param>
340       <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height" /></xsl:with-param>
341       <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
342      </xsl:call-template>
343      <br /><xsl:value-of select="$newline" />
344     </div></div><xsl:value-of select="$newline" />
345    </xsl:if>
346   </xsl:when>
347   <xsl:when test="self::illref">
348    <xsl:if test="@class='html-compatible'">
349     <xsl:for-each select="id( @idref )">
350      <xsl:apply-templates select="." />
351     </xsl:for-each>
352    </xsl:if>
353   </xsl:when>
354   <xsl:otherwise>
355    <xsl:text>[error: paragraphed list template]</xsl:text>
356    <xsl:message><xsl:text>error: paragraphed list template</xsl:text></xsl:message>
357   </xsl:otherwise>
358  </xsl:choose>
359 </xsl:template>
360
361 <xsl:template match="ol">
362  <ol><xsl:value-of select="$newline" />
363   <xsl:apply-templates />
364  </ol><xsl:value-of select="$newline" />
365 </xsl:template>
366
367 <xsl:template match="ul">
368  <ul>
369   <xsl:if test="self::*[@class='unbulleted']"><xsl:attribute name="class"><xsl:text>unbulleted</xsl:text></xsl:attribute></xsl:if>
370   <xsl:value-of select="$newline" />
371   <xsl:apply-templates />
372  </ul><xsl:value-of select="$newline" />
373 </xsl:template>
374
375 <xsl:template match="dl">
376  <dl><xsl:value-of select="$newline" />
377   <xsl:apply-templates />
378  </dl><xsl:value-of select="$newline" />
379 </xsl:template>
380
381 <xsl:template match="dt">
382  <dt><xsl:apply-templates /></dt>
383  <xsl:value-of select="$newline" />
384 </xsl:template>
385
386 <xsl:template match="dd">
387  <dd><xsl:apply-templates /></dd>
388  <xsl:value-of select="$newline" />
389 </xsl:template>
390
391 <xsl:template match="li">
392  <li><xsl:apply-templates /></li>
393  <xsl:value-of select="$newline" />
394 </xsl:template>
395
396 <xsl:template match="table">
397  <table border="1" cellspacing="0" cellpadding="2">
398   <xsl:if test="@summary"><xsl:attribute name="summary"><xsl:value-of select="@summary" /></xsl:attribute></xsl:if>
399   <xsl:apply-templates />
400  </table>
401  <xsl:value-of select="$newline" />
402 </xsl:template>
403
404 <xsl:template match="caption">
405  <caption>
406   <xsl:apply-templates />
407  </caption>
408 </xsl:template>
409
410 <xsl:template match="colgroup[@scope]">
411  <colgroup>
412   <xsl:attribute name="scope"><xsl:value-of select="@scope" /></xsl:attribute>
413  </colgroup>
414 </xsl:template>
415
416 <xsl:template match="thead">
417  <thead>
418   <xsl:apply-templates />
419  </thead>
420 </xsl:template>
421
422 <xsl:template match="tfoot">
423  <tfoot>
424   <xsl:apply-templates />
425  </tfoot>
426 </xsl:template>
427
428 <xsl:template match="tbody">
429  <tbody>
430   <xsl:apply-templates />
431  </tbody>
432 </xsl:template>
433
434 <xsl:template match="tr">
435  <tr>
436   <xsl:apply-templates />
437  </tr>
438 </xsl:template>
439
440 <xsl:template match="th">
441  <th>
442   <xsl:if test="@align"><xsl:attribute name="align"><xsl:value-of select="@align" /></xsl:attribute></xsl:if>
443   <xsl:if test="@valign"><xsl:attribute name="valign"><xsl:value-of select="@valign" /></xsl:attribute></xsl:if>
444   <xsl:if test="@char"><xsl:attribute name="char"><xsl:value-of select="@char" /></xsl:attribute></xsl:if>
445   <xsl:if test="@rowspan"><xsl:attribute name="rowspan"><xsl:value-of select="@rowspan" /></xsl:attribute></xsl:if>
446   <xsl:if test="@colspan"><xsl:attribute name="colspan"><xsl:value-of select="@colspan" /></xsl:attribute></xsl:if>
447   <xsl:if test="@axis"><xsl:attribute name="axis"><xsl:value-of select="@axis" /></xsl:attribute></xsl:if>
448   <xsl:if test="@scope"><xsl:attribute name="scope"><xsl:value-of select="@scope" /></xsl:attribute></xsl:if>
449   <xsl:apply-templates />
450  </th>
451 </xsl:template>
452
453 <xsl:template match="td">
454  <td>
455   <xsl:if test="@align"><xsl:attribute name="align"><xsl:value-of select="@align" /></xsl:attribute></xsl:if>
456   <xsl:if test="@valign"><xsl:attribute name="valign"><xsl:value-of select="@valign" /></xsl:attribute></xsl:if>
457   <xsl:if test="@char"><xsl:attribute name="char"><xsl:value-of select="@char" /></xsl:attribute></xsl:if>
458   <xsl:if test="@rowspan"><xsl:attribute name="rowspan"><xsl:value-of select="@rowspan" /></xsl:attribute></xsl:if>
459   <xsl:if test="@colspan"><xsl:attribute name="colspan"><xsl:value-of select="@colspan" /></xsl:attribute></xsl:if>
460   <xsl:if test="@axis"><xsl:attribute name="axis"><xsl:value-of select="@axis" /></xsl:attribute></xsl:if>
461   <xsl:if test="@scope"><xsl:attribute name="scope"><xsl:value-of select="@scope" /></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">
473      <xsl:choose>
474       <xsl:when test="$language='es'">
475        <xsl:text>DESTREZA&nbsp;EN&nbsp;EL&nbsp;COMBATE</xsl:text>
476       </xsl:when>
477       <xsl:otherwise>
478        <xsl:text>COMBAT&nbsp;SKILL</xsl:text>
479       </xsl:otherwise>
480      </xsl:choose>
481     </span>
482     <xsl:text>&nbsp;</xsl:text>
483     <xsl:value-of select="enemy-attribute[@class='combatskill']" />
484    </xsl:when>
485    <xsl:when test="enemy-attribute[@class='closecombatskill']">
486     <span class="smallcaps">
487      <xsl:choose>
488       <xsl:when test="$language='es'">
489        <xsl:text>CLOSE&nbsp;COMBAT&nbsp;SKILL</xsl:text>
490       </xsl:when>
491       <xsl:otherwise>
492        <xsl:text>CLOSE&nbsp;COMBAT&nbsp;SKILL</xsl:text>
493       </xsl:otherwise>
494      </xsl:choose>
495     </span>
496     <xsl:text>&nbsp;</xsl:text>
497     <xsl:value-of select="enemy-attribute[@class='closecombatskill']" />
498    </xsl:when>
499   </xsl:choose>
500   <xsl:text> &nbsp;&nbsp;</xsl:text>
501   <span class="smallcaps">
502     <xsl:choose>
503      <xsl:when test="$language='es'">
504       <xsl:text>RESISTENCIA</xsl:text>
505      </xsl:when>
506      <xsl:otherwise>
507       <xsl:text>ENDURANCE</xsl:text>
508     </xsl:otherwise>
509    </xsl:choose>
510   </span>
511   <xsl:choose>
512    <xsl:when test="enemy-attribute[@class='target']">
513     <xsl:choose>
514      <xsl:when test="$language='es'">
515       <xsl:text> (o </xsl:text><span class="smallcaps">BLANCOS</span><xsl:text>)</xsl:text>
516      </xsl:when>
517      <xsl:otherwise>
518       <xsl:text> (</xsl:text><span class="smallcaps">TARGET</span><xsl:text> points)</xsl:text>
519      </xsl:otherwise>
520     </xsl:choose>
521     <xsl:text>&nbsp;</xsl:text>
522     <xsl:value-of select="enemy-attribute[@class='target']" />
523    </xsl:when>
524    <xsl:when test="enemy-attribute[@class='resistance']">
525     <xsl:choose>
526      <xsl:when test="$language='es'"></xsl:when>
527      <xsl:otherwise>
528       <xsl:text> (</xsl:text><span class="smallcaps">RESISTANCE</span><xsl:text> points)</xsl:text>
529      </xsl:otherwise>
530     </xsl:choose>
531     <xsl:text>&nbsp;</xsl:text>
532     <xsl:value-of select="enemy-attribute[@class='resistance']" />
533    </xsl:when>
534    <xsl:otherwise>
535     <xsl:text>&nbsp;</xsl:text>
536     <xsl:value-of select="enemy-attribute[@class='endurance']" />
537    </xsl:otherwise>
538   </xsl:choose>
539  </p>
540  <xsl:value-of select="$newline" />
541 </xsl:template>
542
543 <xsl:template match="choice">
544  <xsl:variable name="link">
545   <xsl:value-of select="@idref" />
546  </xsl:variable>
547
548  <p class="choice">
549   <xsl:for-each select="* | text()">
550    <xsl:choose>
551     <xsl:when test="self::link-text">
552      <a href="{$link}.htm">
553       <xsl:apply-templates />
554      </a>
555     </xsl:when>
556     <xsl:otherwise>
557      <xsl:apply-templates select="." />
558     </xsl:otherwise>
559    </xsl:choose>
560   </xsl:for-each>
561  </p>
562  <xsl:value-of select="$newline" />
563 </xsl:template>
564
565 <xsl:template match="signpost">
566  <div class="signpost">
567   <xsl:apply-templates />
568  </div>
569  <xsl:value-of select="$newline" />
570 </xsl:template>
571
572 <xsl:template match="blockquote">
573  <blockquote><xsl:value-of select="$newline" />
574   <xsl:apply-templates /><xsl:value-of select="$newline" />
575  </blockquote><xsl:value-of select="$newline" />
576 </xsl:template>
577
578 <xsl:template match="illref">
579  <!-- It is important that the class is not checked right in the template - that would make this template match with higher priority, which will turn a few things upside down --> 
580  <xsl:if test="@class='html-compatible'">
581   <xsl:for-each select="id( @idref )">
582    <!-- This creates unneccessary regeneration of float illustration pages, but it is easiest to keep things this way as long as we have to be backwards compatible... -->
583    <!-- When backwards compatibility can be dropped, most of (all?) the <illustration> processing can happen here -->
584    <xsl:apply-templates select="." />
585   </xsl:for-each>
586  </xsl:if>
587 </xsl:template>
588
589 <xsl:template match="illustrations">
590  <ul class="unbulleted">
591   <xsl:for-each select="illustration[contains( $use-illustrators, concat( ':', meta/creator, ':' ) )] | illgroup">
592    <xsl:choose>
593     <xsl:when test="self::illustration and @class='float'">
594      <!-- List item with illustration name as link -->
595      <li>
596       <a>
597        <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>
598        <xsl:choose>
599         <xsl:when test="$language='es'">
600          <xsl:text>Ilustraci&oacute;n </xsl:text>
601         </xsl:when>
602         <xsl:otherwise>
603          <xsl:text>Illustration </xsl:text>
604         </xsl:otherwise>
605        </xsl:choose>
606        <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
607       </a>
608       <!-- List the sections that the illustration appears in -->
609       <xsl:text> (</xsl:text>
610       <xsl:for-each select="//illref[@class='html-compatible' and @idref=current()/@id]">
611        <xsl:call-template name="section-title-link" />
612        <xsl:if test="position()!=last()">
613         <xsl:text>, </xsl:text>        
614        </xsl:if>
615       </xsl:for-each>
616       <xsl:text>)</xsl:text><xsl:value-of select="$newline" />
617      </li>
618      <!-- Call the backwards compatible template for generating the illustration page -->
619      <xsl:call-template name="xhtml-wrapper">
620       <xsl:with-param name="document-type">illustration</xsl:with-param>
621       <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>
622      </xsl:call-template>
623     </xsl:when>
624
625     <xsl:when test="self::illustration"> <!-- inline and map -->
626      <!-- List the sections that the illustration appears in -->     
627      <li>
628       <!-- TODO: fix this so that sections that do not represent separate XHTML files are not linked to? -->
629       <xsl:for-each select="//illref[@class='html-compatible' and @idref=current()/@id]">
630        <xsl:call-template name="section-title-link" />
631        <xsl:if test="position()!=last()">
632         <xsl:text>, </xsl:text>     
633        </xsl:if>
634       </xsl:for-each>
635      </li>
636     </xsl:when>
637
638     <xsl:when test="self::illgroup and @class!='hidden'">
639      <!-- Check if the group contains any illustrations being used, before creating the list item -->
640       <xsl:if test="count( illustration[contains( $use-illustrators, concat( ':', meta/creator, ':' ) )] ) != 0">
641        <li>
642         <a>
643          <xsl:attribute name="href"><xsl:value-of select="@idref" /><xsl:text>.htm</xsl:text></xsl:attribute>
644          <xsl:value-of select="id(@idref)/meta/title[1]" />
645         </a>
646        </li>
647       </xsl:if>
648     </xsl:when>
649    </xsl:choose>
650   </xsl:for-each>
651  </ul><xsl:value-of select="$newline" />
652 </xsl:template>
653
654 <xsl:template match="illustration">
655  <xsl:variable name="illustration-width" select="instance[@class='html-compatible']/@width" />
656  <xsl:variable name="illustration-height" select="instance[@class='html-compatible']/@height" />
657  <xsl:variable name="illustration-src" select="instance[@class='html-compatible']/@src" />
658
659  <xsl:variable name="illustration-width-adjusted"><xsl:number value="$illustration-width div 2" /></xsl:variable>
660  <xsl:variable name="illustration-height-adjusted"><xsl:number value="$illustration-height div 2" /></xsl:variable>
661
662  <xsl:if test="instance[@class='html-compatible'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
663   <xsl:choose>
664    <xsl:when test="@class='float'">
665     <div class="illustration">
666      <div align="center"><xsl:value-of select="$newline" />
667      <xsl:call-template name="illustration-framed">
668       <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width-adjusted" /></xsl:with-param>
669       <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height-adjusted" /></xsl:with-param>
670       <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
671       <xsl:with-param name="illustration-href">
672        <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>
673       </xsl:with-param>
674      </xsl:call-template>
675      <br /><xsl:value-of select="$newline" />
676     </div></div><xsl:value-of select="$newline" />
677
678     <xsl:call-template name="xhtml-wrapper">
679      <xsl:with-param name="document-type">illustration</xsl:with-param>
680      <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>
681     </xsl:call-template>
682    </xsl:when>
683
684    <xsl:when test="@class='accent'" />
685
686    <xsl:otherwise>
687     <div class="illustration">
688      <div align="center"><xsl:value-of select="$newline" />
689      <xsl:call-template name="illustration-framed">
690       <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width" /></xsl:with-param>
691       <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height" /></xsl:with-param>
692       <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
693      </xsl:call-template>
694      <br /><xsl:value-of select="$newline" />
695     </div></div><xsl:value-of select="$newline" />
696    </xsl:otherwise>
697   </xsl:choose>
698  </xsl:if>
699 </xsl:template>
700
701 <xsl:template match="instance" />
702
703 <xsl:template match="footnotes" />
704
705 <xsl:template match="footnote" />
706
707 <xsl:template match="hr">
708  <hr />
709  <xsl:value-of select="$newline" />
710 </xsl:template>
711
712 <!-- ==================== inline elements ======================= -->
713
714 <xsl:template match="a">
715  <xsl:choose>
716   <xsl:when test="@href">
717    <a>
718     <xsl:attribute name="href"><xsl:value-of select="@href" /></xsl:attribute>
719     <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
720     <xsl:apply-templates />
721    </a>
722   </xsl:when>
723   <xsl:otherwise>
724    <a>
725     <xsl:if test="@idref">
726      <xsl:variable name="my-idref" select="@idref" />
727      <xsl:attribute name="href">
728       <xsl:choose>
729        <!-- The order of these tests is deliberate. They are ordered roughly from most to least specific. -->
730        <xsl:when test="/gamebook/section[@id=$my-idref] | /gamebook/section/data/section[@id=$my-idref]">
731         <xsl:value-of select="$my-idref" /><xsl:text>.htm</xsl:text>
732        </xsl:when>
733        <xsl:when test="/gamebook/section/data/section/data/section[@class='frontmatter-separate' and @id=$my-idref]">
734         <xsl:value-of select="$my-idref" /><xsl:text>.htm</xsl:text>
735        </xsl:when>
736        <xsl:when test="/gamebook/section/data/section/data/section[@class='mainmatter-separate' and @id=$my-idref]">
737         <xsl:value-of select="$my-idref" /><xsl:text>.htm</xsl:text>
738        </xsl:when>
739        <xsl:when test="/gamebook/section/data/section/data/section[@class='numbered' and @id=$my-idref]">
740         <xsl:value-of select="$my-idref" /><xsl:text>.htm</xsl:text>
741        </xsl:when>
742        <xsl:when test="/gamebook/section/data/section/data/section[@class='glossary-separate' and @id=$my-idref]">
743         <xsl:value-of select="$my-idref" /><xsl:text>.htm</xsl:text>
744        </xsl:when>
745        <xsl:when test="/gamebook/section/data/section/data/section[@class='frontmatter-separate' and descendant::*[@id=$my-idref]]">
746         <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" />
747        </xsl:when>
748        <xsl:when test="/gamebook/section/data/section/data/section[@class='mainmatter-separate' and descendant::*[@id=$my-idref]]">
749         <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" />
750        </xsl:when>
751        <xsl:when test="/gamebook/section/data/section/data/section[@class='glossary-separate' and descendant::*[@id=$my-idref]]">
752         <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" />
753        </xsl:when>
754        <xsl:when test="/gamebook/section/data/section[descendant::*[@id=$my-idref]]">
755         <xsl:value-of select="/gamebook/section/data/section[descendant::*[@id=$my-idref]]/@id" /><xsl:text>.htm#</xsl:text><xsl:value-of select="$my-idref" />
756        </xsl:when>
757        <xsl:otherwise>
758         <xsl:text>[error: a template]</xsl:text>
759         <xsl:message><xsl:text>error: a template</xsl:text></xsl:message>
760        </xsl:otherwise>
761       </xsl:choose>
762      </xsl:attribute>
763     </xsl:if>
764     <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
765     <xsl:apply-templates />
766    </a>
767   </xsl:otherwise>
768  </xsl:choose>
769 </xsl:template>
770
771 <!-- This template is obsolete, the "footref" element should be used instead -->
772 <xsl:template match="a[@class='footnote']">
773  <!-- <xsl:message><xsl:text>WARNING: Obsolete &lt;a idref='...' class='footnote' /&gt; usage</xsl:text></xsl:message> -->
774  <xsl:apply-templates />
775  <sup>
776   <a>
777    <xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="@idref" /></xsl:attribute>
778    <xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute>
779    <xsl:number count="a[@class='footnote']" from="/" level="any" format="1" />
780   </a>
781  </sup>
782 </xsl:template>
783
784 <!-- TODO: can this be made more uniform with illrefs? -->
785 <xsl:template match="a[@class='accent-illustration']">
786  <xsl:for-each select="id( @idref )">
787   <xsl:variable name="illustration-src" select="instance[@class='html-compatible']/@src" />
788   <xsl:variable name="illustration-width" select="instance[@class='html-compatible']/@width" />
789   <xsl:variable name="illustration-height" select="instance[@class='html-compatible']/@height" />
790   <xsl:if test="instance[@class='html-compatible'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
791    <img src="{$illustration-src}" class="accent" width="{$illustration-width}" height="{$illustration-height}" alt="" border="" align="left" />
792   </xsl:if>
793  </xsl:for-each>
794 </xsl:template>
795
796 <xsl:template match="bookref">
797  <a>
798   <xsl:attribute name="href">
799    <xsl:variable name="my-section">
800     <xsl:choose>
801      <xsl:when test="@section">
802       <xsl:value-of select="@section" />
803      </xsl:when>
804      <xsl:otherwise>
805       <xsl:text>title</xsl:text>
806      </xsl:otherwise>
807     </xsl:choose>
808    </xsl:variable>
809    <xsl:variable name="my-series">
810     <!-- If series is specified, go one directory back and then to series. Otherwise, add nothing. -->
811     <xsl:choose>
812      <xsl:when test="@series">
813       <xsl:text>/../</xsl:text><xsl:value-of select="@series" />
814      </xsl:when>
815      <xsl:otherwise>
816       <xsl:text></xsl:text>
817      </xsl:otherwise>
818     </xsl:choose>
819    </xsl:variable>
820    <xsl:text>..</xsl:text><xsl:value-of select="$my-series" /><xsl:text>/</xsl:text><xsl:value-of select="@book" /><xsl:text>/</xsl:text><xsl:value-of select="$my-section" /><xsl:text>.htm</xsl:text>
821   </xsl:attribute>
822   <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
823   <xsl:apply-templates />
824  </a>
825 </xsl:template>
826
827 <xsl:template match="footref">
828  <xsl:apply-templates />
829  <sup>
830   <a>
831    <xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="@idref" /></xsl:attribute>
832    <xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute>
833    <xsl:number count="footref" from="/" level="any" format="1" />
834   </a>
835  </sup>
836 </xsl:template>
837
838 <xsl:template match="em">
839  <em><xsl:apply-templates /></em>
840 </xsl:template>
841
842 <xsl:template match="strong">
843  <strong><xsl:apply-templates /></strong>
844 </xsl:template>
845
846 <xsl:template match="thought">
847  <i><xsl:apply-templates /></i>
848 </xsl:template>
849
850 <xsl:template match="onomatopoeia">
851  <i><xsl:apply-templates /></i>
852 </xsl:template>
853
854 <xsl:template match="spell">
855  <i><xsl:apply-templates /></i>
856 </xsl:template>
857
858 <xsl:template match="item">
859  <strong><xsl:apply-templates /></strong>
860 </xsl:template>
861
862 <xsl:template match="foreign">
863  <i><xsl:apply-templates /></i>
864 </xsl:template>
865
866 <xsl:template match="quote">
867  <xsl:text>&apos;</xsl:text>
868   <xsl:apply-templates />
869  <xsl:if test="not(self::*[@class='open-ended'])"><xsl:text>&apos;</xsl:text></xsl:if>
870 </xsl:template>
871
872 <xsl:template match="quote//quote">
873  <xsl:text>&quot;</xsl:text>
874   <xsl:apply-templates />
875  <xsl:if test="not(self::*[@class='open-ended'])"><xsl:text>&quot;</xsl:text></xsl:if>
876 </xsl:template>
877
878 <xsl:template match="cite">
879  <cite><xsl:apply-templates /></cite>
880 </xsl:template>
881
882 <xsl:template match="code">
883  <tt><xsl:apply-templates /></tt>
884 </xsl:template>
885
886 <xsl:template match="line">
887  <xsl:apply-templates />
888  <xsl:if test="position( ) != last( )"><br /></xsl:if>
889 </xsl:template>
890
891 <xsl:template match="br">
892  <br />
893 </xsl:template>
894
895 <xsl:template match="typ[@class='attribute']">
896  <span class="smallcaps"><xsl:apply-templates /></span>
897 </xsl:template>
898
899 <!-- ==================== character elements ==================== -->
900 <!--
901
902 These templates define the mapping between the character elements used in
903 the Project Aon instances of Gamebook XML and the ISO-8859-1
904 characters.
905
906 Portions Copyright International Organization for Standardization 1986 
907 Permission to copy in any form is granted for use with conforming SGML 
908 systems and applications as defined in ISO 8879, provided this notice 
909 is included in all copies.
910
911 -->
912
913 <xsl:template match="ch.apos"><xsl:text>&#39;</xsl:text></xsl:template><!-- apostrophe = single quotation mark -->
914 <xsl:template match="ch.nbsp"><xsl:text>&#160;</xsl:text></xsl:template><!-- no-break space = non-breaking space, U+00A0 ISOnum -->
915 <xsl:template match="ch.iexcl"><xsl:text>&#161;</xsl:text></xsl:template><!-- inverted exclamation mark, U+00A1 ISOnum -->
916 <xsl:template match="ch.cent"><xsl:text>&#162;</xsl:text></xsl:template><!-- cent sign, U+00A2 ISOnum -->
917 <xsl:template match="ch.pound"><xsl:text>&#163;</xsl:text></xsl:template><!-- pound sign, U+00A3 ISOnum -->
918 <xsl:template match="ch.curren"><xsl:text>&#164;</xsl:text></xsl:template><!-- currency sign, U+00A4 ISOnum -->
919 <xsl:template match="ch.yen"><xsl:text>&#165;</xsl:text></xsl:template><!-- yen sign = yuan sign, U+00A5 ISOnum -->
920 <xsl:template match="ch.brvbar"><xsl:text>&#166;</xsl:text></xsl:template><!-- broken bar = broken vertical bar, U+00A6 ISOnum -->
921 <xsl:template match="ch.sect"><xsl:text>&#167;</xsl:text></xsl:template><!-- section sign, U+00A7 ISOnum -->
922 <xsl:template match="ch.uml"><xsl:text>&#168;</xsl:text></xsl:template><!-- diaeresis = spacing diaeresis, U+00A8 ISOdia -->
923 <xsl:template match="ch.copy"><xsl:text>&#169;</xsl:text></xsl:template><!-- copyright sign, U+00A9 ISOnum -->
924 <xsl:template match="ch.ordf"><xsl:text>&#170;</xsl:text></xsl:template><!-- feminine ordinal indicator, U+00AA ISOnum -->
925 <xsl:template match="ch.laquo"><xsl:text>&#171;</xsl:text></xsl:template><!-- left-pointing double angle quotation mark = left pointing guillemet, U+00AB ISOnum -->
926 <xsl:template match="ch.not"><xsl:text>&#172;</xsl:text></xsl:template><!-- not sign, U+00AC ISOnum -->
927 <xsl:template match="ch.shy"><xsl:text>&#173;</xsl:text></xsl:template><!-- soft hyphen = discretionary hyphen, U+00AD ISOnum -->
928 <xsl:template match="ch.reg"><xsl:text>&#174;</xsl:text></xsl:template><!-- registered sign = registered trade mark sign, U+00AE ISOnum -->
929 <xsl:template match="ch.macr"><xsl:text>&#175;</xsl:text></xsl:template><!-- macron = spacing macron = overline = APL overbar, U+00AF ISOdia -->
930 <xsl:template match="ch.deg"><xsl:text>&#176;</xsl:text></xsl:template><!-- degree sign, U+00B0 ISOnum -->
931 <xsl:template match="ch.plusmn"><xsl:text>&#177;</xsl:text></xsl:template><!-- plus-minus sign = plus-or-minus sign, U+00B1 ISOnum -->
932 <xsl:template match="ch.sup2"><xsl:text>&#178;</xsl:text></xsl:template><!-- superscript two = superscript digit two = squared, U+00B2 ISOnum -->
933 <xsl:template match="ch.sup3"><xsl:text>&#179;</xsl:text></xsl:template><!-- superscript three = superscript digit three = cubed, U+00B3 ISOnum -->
934 <xsl:template match="ch.acute"><xsl:text>&#180;</xsl:text></xsl:template><!-- acute accent = spacing acute, U+00B4 ISOdia -->
935 <xsl:template match="ch.micro"><xsl:text>&#181;</xsl:text></xsl:template><!-- micro sign, U+00B5 ISOnum -->
936 <xsl:template match="ch.para"><xsl:text>&#182;</xsl:text></xsl:template><!-- pilcrow sign  = paragraph sign, U+00B6 ISOnum -->
937 <xsl:template match="ch.middot"><xsl:text>&#183;</xsl:text></xsl:template><!-- middle dot = Georgian comma = Greek middle dot, U+00B7 ISOnum -->
938 <xsl:template match="ch.cedil"><xsl:text>&#184;</xsl:text></xsl:template><!-- cedilla = spacing cedilla, U+00B8 ISOdia -->
939 <xsl:template match="ch.sup1"><xsl:text>&#185;</xsl:text></xsl:template><!-- superscript one = superscript digit one, U+00B9 ISOnum -->
940 <xsl:template match="ch.ordm"><xsl:text>&#186;</xsl:text></xsl:template><!-- masculine ordinal indicator, U+00BA ISOnum -->
941 <xsl:template match="ch.raquo"><xsl:text>&#187;</xsl:text></xsl:template><!-- right-pointing double angle quotation mark = right pointing guillemet, U+00BB ISOnum -->
942 <xsl:template match="ch.frac14"><xsl:text>&#188;</xsl:text></xsl:template><!-- vulgar fraction one quarter = fraction one quarter, U+00BC ISOnum -->
943 <xsl:template match="ch.frac12"><xsl:text>&#189;</xsl:text></xsl:template><!-- vulgar fraction one half = fraction one half, U+00BD ISOnum -->
944 <xsl:template match="ch.frac34"><xsl:text>&#190;</xsl:text></xsl:template><!-- vulgar fraction three quarters = fraction three quarters, U+00BE ISOnum -->
945 <xsl:template match="ch.frac13"><xsl:text>&#x2153;</xsl:text></xsl:template><!-- vulgar fraction 1/3, U+2153 ISOnum -->
946 <xsl:template match="ch.frac23"><xsl:text>&#x2154;</xsl:text></xsl:template><!-- vulgar fraction 2/3, U+2154 ISOnum -->
947 <xsl:template match="ch.frac15"><xsl:text>&#x2155;</xsl:text></xsl:template><!-- vulgar fraction 1/5, U+2155 ISOnum -->
948 <xsl:template match="ch.frac25"><xsl:text>&#x2156;</xsl:text></xsl:template><!-- vulgar fraction 2/5, U+2156 ISOnum -->
949 <xsl:template match="ch.frac35"><xsl:text>&#x2157;</xsl:text></xsl:template><!-- vulgar fraction 3/5, U+2157 ISOnum -->
950 <xsl:template match="ch.frac45"><xsl:text>&#x2158;</xsl:text></xsl:template><!-- vulgar fraction 4/5, U+2158 ISOnum -->
951 <xsl:template match="ch.frac16"><xsl:text>&#x2159;</xsl:text></xsl:template><!-- vulgar fraction 1/6, U+2159 ISOnum -->
952 <xsl:template match="ch.frac56"><xsl:text>&#x215A;</xsl:text></xsl:template><!-- vulgar fraction 5/6, U+215A ISOnum -->
953 <xsl:template match="ch.frac17"><xsl:text>&#x2150;</xsl:text></xsl:template><!-- vulgar fraction 1/7, U+2150 ISOnum -->
954 <xsl:template match="ch.frac18"><xsl:text>&#x215B;</xsl:text></xsl:template><!-- vulgar fraction 1/8, U+215B ISOnum -->
955 <xsl:template match="ch.frac38"><xsl:text>&#x215C;</xsl:text></xsl:template><!-- vulgar fraction 3/8, U+215C ISOnum -->
956 <xsl:template match="ch.frac58"><xsl:text>&#x215D;</xsl:text></xsl:template><!-- vulgar fraction 5/8, U+215D ISOnum -->
957 <xsl:template match="ch.frac78"><xsl:text>&#x215E;</xsl:text></xsl:template><!-- vulgar fraction 7/8, U+215E ISOnum -->
958 <xsl:template match="ch.frac19"><xsl:text>&#x2151;</xsl:text></xsl:template><!-- vulgar fraction 1/9, U+2151 ISOnum -->
959 <xsl:template match="ch.frac110"><xsl:text>&#x2152;</xsl:text></xsl:template><!-- vulgar fraction 1/10, U+2152 ISO num -->
960 <xsl:template match="ch.iquest"><xsl:text>&#191;</xsl:text></xsl:template><!-- inverted question mark = turned question mark, U+00BF ISOnum -->
961 <xsl:template match="ch.Agrave"><xsl:text>&#192;</xsl:text></xsl:template><!-- latin capital letter A with grave = latin capital letter A grave, U+00C0 ISOlat1 -->
962 <xsl:template match="ch.Aacute"><xsl:text>&#193;</xsl:text></xsl:template><!-- latin capital letter A with acute, U+00C1 ISOlat1 -->
963 <xsl:template match="ch.Acirc"><xsl:text>&#194;</xsl:text></xsl:template><!-- latin capital letter A with circumflex, U+00C2 ISOlat1 -->
964 <xsl:template match="ch.Atilde"><xsl:text>&#195;</xsl:text></xsl:template><!-- latin capital letter A with tilde, U+00C3 ISOlat1 -->
965 <xsl:template match="ch.Auml"><xsl:text>&#196;</xsl:text></xsl:template><!-- latin capital letter A with diaeresis, U+00C4 ISOlat1 -->
966 <xsl:template match="ch.Aring"><xsl:text>&#197;</xsl:text></xsl:template><!-- latin capital letter A with ring above = latin capital letter A ring, U+00C5 ISOlat1 -->
967 <xsl:template match="ch.AElig"><xsl:text>&#198;</xsl:text></xsl:template><!-- latin capital letter AE = latin capital ligature AE, U+00C6 ISOlat1 -->
968 <xsl:template match="ch.Ccedil"><xsl:text>&#199;</xsl:text></xsl:template><!-- latin capital letter C with cedilla, U+00C7 ISOlat1 -->
969 <xsl:template match="ch.Egrave"><xsl:text>&#200;</xsl:text></xsl:template><!-- latin capital letter E with grave, U+00C8 ISOlat1 -->
970 <xsl:template match="ch.Eacute"><xsl:text>&#201;</xsl:text></xsl:template><!-- latin capital letter E with acute, U+00C9 ISOlat1 -->
971 <xsl:template match="ch.Ecirc"><xsl:text>&#202;</xsl:text></xsl:template><!-- latin capital letter E with circumflex, U+00CA ISOlat1 -->
972 <xsl:template match="ch.Euml"><xsl:text>&#203;</xsl:text></xsl:template><!-- latin capital letter E with diaeresis, U+00CB ISOlat1 -->
973 <xsl:template match="ch.Igrave"><xsl:text>&#204;</xsl:text></xsl:template><!-- latin capital letter I with grave, U+00CC ISOlat1 -->
974 <xsl:template match="ch.Iacute"><xsl:text>&#205;</xsl:text></xsl:template><!-- latin capital letter I with acute, U+00CD ISOlat1 -->
975 <xsl:template match="ch.Icirc"><xsl:text>&#206;</xsl:text></xsl:template><!-- latin capital letter I with circumflex, U+00CE ISOlat1 -->
976 <xsl:template match="ch.Iuml"><xsl:text>&#207;</xsl:text></xsl:template><!-- latin capital letter I with diaeresis, U+00CF ISOlat1 -->
977 <xsl:template match="ch.ETH"><xsl:text>&#208;</xsl:text></xsl:template><!-- latin capital letter ETH, U+00D0 ISOlat1 -->
978 <xsl:template match="ch.Ntilde"><xsl:text>&#209;</xsl:text></xsl:template><!-- latin capital letter N with tilde, U+00D1 ISOlat1 -->
979 <xsl:template match="ch.Ograve"><xsl:text>&#210;</xsl:text></xsl:template><!-- latin capital letter O with grave, U+00D2 ISOlat1 -->
980 <xsl:template match="ch.Oacute"><xsl:text>&#211;</xsl:text></xsl:template><!-- latin capital letter O with acute, U+00D3 ISOlat1 -->
981 <xsl:template match="ch.Ocirc"><xsl:text>&#212;</xsl:text></xsl:template><!-- latin capital letter O with circumflex, U+00D4 ISOlat1 -->
982 <xsl:template match="ch.Otilde"><xsl:text>&#213;</xsl:text></xsl:template><!-- latin capital letter O with tilde, U+00D5 ISOlat1 -->
983 <xsl:template match="ch.Ouml"><xsl:text>&#214;</xsl:text></xsl:template><!-- latin capital letter O with diaeresis, U+00D6 ISOlat1 -->
984 <xsl:template match="ch.times"><xsl:text>&#215;</xsl:text></xsl:template><!-- multiplication sign, U+00D7 ISOnum -->
985 <xsl:template match="ch.Oslash"><xsl:text>&#216;</xsl:text></xsl:template><!-- latin capital letter O with stroke = latin capital letter O slash, U+00D8 ISOlat1 -->
986 <xsl:template match="ch.Ugrave"><xsl:text>&#217;</xsl:text></xsl:template><!-- latin capital letter U with grave, U+00D9 ISOlat1 -->
987 <xsl:template match="ch.Uacute"><xsl:text>&#218;</xsl:text></xsl:template><!-- latin capital letter U with acute, U+00DA ISOlat1 -->
988 <xsl:template match="ch.Ucirc"><xsl:text>&#219;</xsl:text></xsl:template><!-- latin capital letter U with circumflex, U+00DB ISOlat1 -->
989 <xsl:template match="ch.Uuml"><xsl:text>&#220;</xsl:text></xsl:template><!-- latin capital letter U with diaeresis, U+00DC ISOlat1 -->
990 <xsl:template match="ch.Yacute"><xsl:text>&#221;</xsl:text></xsl:template><!-- latin capital letter Y with acute, U+00DD ISOlat1 -->
991 <xsl:template match="ch.THORN"><xsl:text>&#222;</xsl:text></xsl:template><!-- latin capital letter THORN, U+00DE ISOlat1 -->
992 <xsl:template match="ch.szlig"><xsl:text>&#223;</xsl:text></xsl:template><!-- latin small letter sharp s = ess-zed, U+00DF ISOlat1 -->
993 <xsl:template match="ch.agrave"><xsl:text>&#224;</xsl:text></xsl:template><!-- latin small letter a with grave = latin small letter a grave, U+00E0 ISOlat1 -->
994 <xsl:template match="ch.aacute"><xsl:text>&#225;</xsl:text></xsl:template><!-- latin small letter a with acute, U+00E1 ISOlat1 -->
995 <xsl:template match="ch.acirc"><xsl:text>&#226;</xsl:text></xsl:template><!-- latin small letter a with circumflex, U+00E2 ISOlat1 -->
996 <xsl:template match="ch.atilde"><xsl:text>&#227;</xsl:text></xsl:template><!-- latin small letter a with tilde, U+00E3 ISOlat1 -->
997 <xsl:template match="ch.auml"><xsl:text>&#228;</xsl:text></xsl:template><!-- latin small letter a with diaeresis, U+00E4 ISOlat1 -->
998 <xsl:template match="ch.aring"><xsl:text>&#229;</xsl:text></xsl:template><!-- latin small letter a with ring above = latin small letter a ring, U+00E5 ISOlat1 -->
999 <xsl:template match="ch.aelig"><xsl:text>&#230;</xsl:text></xsl:template><!-- latin small letter ae = latin small ligature ae, U+00E6 ISOlat1 -->
1000 <xsl:template match="ch.ccedil"><xsl:text>&#231;</xsl:text></xsl:template><!-- latin small letter c with cedilla, U+00E7 ISOlat1 -->
1001 <xsl:template match="ch.egrave"><xsl:text>&#232;</xsl:text></xsl:template><!-- latin small letter e with grave, U+00E8 ISOlat1 -->
1002 <xsl:template match="ch.eacute"><xsl:text>&#233;</xsl:text></xsl:template><!-- latin small letter e with acute, U+00E9 ISOlat1 -->
1003 <xsl:template match="ch.ecirc"><xsl:text>&#234;</xsl:text></xsl:template><!-- latin small letter e with circumflex, U+00EA ISOlat1 -->
1004 <xsl:template match="ch.euml"><xsl:text>&#235;</xsl:text></xsl:template><!-- latin small letter e with diaeresis, U+00EB ISOlat1 -->
1005 <xsl:template match="ch.igrave"><xsl:text>&#236;</xsl:text></xsl:template><!-- latin small letter i with grave, U+00EC ISOlat1 -->
1006 <xsl:template match="ch.iacute"><xsl:text>&#237;</xsl:text></xsl:template><!-- latin small letter i with acute, U+00ED ISOlat1 -->
1007 <xsl:template match="ch.icirc"><xsl:text>&#238;</xsl:text></xsl:template><!-- latin small letter i with circumflex, U+00EE ISOlat1 -->
1008 <xsl:template match="ch.iuml"><xsl:text>&#239;</xsl:text></xsl:template><!-- latin small letter i with diaeresis, U+00EF ISOlat1 -->
1009 <xsl:template match="ch.eth"><xsl:text>&#240;</xsl:text></xsl:template><!-- latin small letter eth, U+00F0 ISOlat1 -->
1010 <xsl:template match="ch.ntilde"><xsl:text>&#241;</xsl:text></xsl:template><!-- latin small letter n with tilde, U+00F1 ISOlat1 -->
1011 <xsl:template match="ch.ograve"><xsl:text>&#242;</xsl:text></xsl:template><!-- latin small letter o with grave, U+00F2 ISOlat1 -->
1012 <xsl:template match="ch.oacute"><xsl:text>&#243;</xsl:text></xsl:template><!-- latin small letter o with acute, U+00F3 ISOlat1 -->
1013 <xsl:template match="ch.ocirc"><xsl:text>&#244;</xsl:text></xsl:template><!-- latin small letter o with circumflex, U+00F4 ISOlat1 -->
1014 <xsl:template match="ch.otilde"><xsl:text>&#245;</xsl:text></xsl:template><!-- latin small letter o with tilde, U+00F5 ISOlat1 -->
1015 <xsl:template match="ch.ouml"><xsl:text>&#246;</xsl:text></xsl:template><!-- latin small letter o with diaeresis, U+00F6 ISOlat1 -->
1016 <xsl:template match="ch.divide"><xsl:text>&#247;</xsl:text></xsl:template><!-- division sign, U+00F7 ISOnum -->
1017 <xsl:template match="ch.oslash"><xsl:text>&#248;</xsl:text></xsl:template><!-- latin small letter o with stroke, = latin small letter o slash, U+00F8 ISOlat1 -->
1018 <xsl:template match="ch.ugrave"><xsl:text>&#249;</xsl:text></xsl:template><!-- latin small letter u with grave, U+00F9 ISOlat1 -->
1019 <xsl:template match="ch.uacute"><xsl:text>&#250;</xsl:text></xsl:template><!-- latin small letter u with acute, U+00FA ISOlat1 -->
1020 <xsl:template match="ch.ucirc"><xsl:text>&#251;</xsl:text></xsl:template><!-- latin small letter u with circumflex, U+00FB ISOlat1 -->
1021 <xsl:template match="ch.uuml"><xsl:text>&#252;</xsl:text></xsl:template><!-- latin small letter u with diaeresis, U+00FC ISOlat1 -->
1022 <xsl:template match="ch.yacute"><xsl:text>&#253;</xsl:text></xsl:template><!-- latin small letter y with acute, U+00FD ISOlat1 -->
1023 <xsl:template match="ch.thorn"><xsl:text>&#254;</xsl:text></xsl:template><!-- latin small letter thorn, U+00FE ISOlat1 -->
1024 <xsl:template match="ch.yuml"><xsl:text>&#255;</xsl:text></xsl:template><!-- latin small letter y with diaeresis, U+00FF ISOlat1 -->
1025
1026 <!-- ~~~~~~~~~~~~~~~~~~~~~ Special Characters ~~~~~~~~~~~~~~~~~~~~ -->
1027
1028 <xsl:template match="ch.ampersand">&amp;</xsl:template><!-- ampersand -->
1029 <xsl:template match="ch.lsquot">&apos;</xsl:template><!-- opening left quotation mark -->
1030 <xsl:template match="ch.rsquot">&apos;</xsl:template><!-- closing right quotation mark -->
1031 <xsl:template match="ch.ldquot">&quot;</xsl:template><!-- opening left double quotation mark -->
1032 <xsl:template match="ch.rdquot">&quot;</xsl:template><!-- closing right double quotation mark -->
1033 <xsl:template match="ch.minus">-</xsl:template><!-- mathematical minus -->
1034 <xsl:template match="ch.endash">-</xsl:template><!-- endash -->
1035 <xsl:template match="ch.emdash">--</xsl:template><!-- emdash -->
1036 <xsl:template match="ch.ellips">&nbsp;.&nbsp;.&nbsp;.</xsl:template><!-- ellipsis -->
1037 <xsl:template match="ch.lellips">.&nbsp;.&nbsp;.&nbsp;</xsl:template><!-- left ellipsis, used at the beginning of edited material -->
1038 <xsl:template match="ch.blankline">_______</xsl:template><!-- blank line to be filled in -->
1039 <xsl:template match="ch.percent"><xsl:text>&#37;</xsl:text></xsl:template><!-- percent sign -->
1040 <xsl:template match="ch.thinspace"><xsl:text></xsl:text></xsl:template><!-- small horizontal space for use between adjacent quotation marks - added mainly for LaTeX's sake -->
1041 <xsl:template match="ch.frac116"><xsl:text>1/16</xsl:text></xsl:template><!-- vulgar fraction one sixteenth = fraction on sixteenth -->
1042 <xsl:template match="ch.plus"><xsl:text>+</xsl:text></xsl:template><!-- mathematical plus -->
1043
1044 <!-- ==================== named templates ======================= -->
1045
1046 <xsl:template name="xhtml-wrapper">
1047  <xsl:param name="document-type">undefined</xsl:param>
1048  <xsl:param name="filename">undefined</xsl:param>
1049  <xsl:param name="glossary-id-prefix"></xsl:param>
1050
1051 <!-- <redirect:write file="{$filename}.htm">-->
1052  <redirect:write file="{$filename}.htm">
1053   <xsl:fallback>
1054    <xsl:text>xhtml-wrapper: Cannot write to filename: "</xsl:text>
1055    <xsl:value-of select="$filename" /><xsl:text>.htm"</xsl:text>
1056   </xsl:fallback>
1057
1058   <html xml:lang="en-UK" lang="en-UK">
1059
1060    <xsl:value-of select="$newline" />
1061    <xsl:value-of select="$newline" />
1062
1063    <head><xsl:value-of select="$newline" />
1064     <title>
1065      <xsl:apply-templates select="/gamebook/meta/title[1]" />
1066      <xsl:text>: </xsl:text>
1067      <xsl:choose>
1068       <xsl:when test="$document-type='illustration'">
1069        <xsl:choose>
1070         <xsl:when test="$language='es'">
1071          <xsl:text>Ilustraci&oacute;n </xsl:text>
1072         </xsl:when>
1073         <xsl:otherwise>
1074          <xsl:text>Illustration </xsl:text>
1075         </xsl:otherwise>
1076        </xsl:choose>
1077        <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
1078       </xsl:when>
1079       <xsl:otherwise><xsl:apply-templates select="meta/title[1]" /></xsl:otherwise>
1080      </xsl:choose>
1081     </title><xsl:value-of select="$newline" />
1082     <meta http-equiv="Content-type" content="text/html; charset=ISO-8859-1" /><xsl:value-of select="$newline" />
1083     <meta name="robots" content="noindex,nofollow" /><xsl:value-of select="$newline" />
1084     <link rel="stylesheet" href="main.css" type="text/css" /><xsl:value-of select="$newline" />
1085    </head>
1086
1087    <xsl:value-of select="$newline" />
1088    <xsl:value-of select="$newline" />
1089
1090    <xsl:comment>
1091     <xsl:text> </xsl:text>
1092     <xsl:apply-templates select="/gamebook/meta/rights[@class='copyrights']" />
1093     <xsl:choose>
1094      <xsl:when test="$language='es'">
1095       <xsl:text> Publicado por </xsl:text>
1096      </xsl:when>
1097      <xsl:otherwise>
1098       <xsl:text> Published by </xsl:text>
1099      </xsl:otherwise>
1100     </xsl:choose>
1101     <xsl:apply-templates select="/gamebook/meta/publisher[1]" />
1102     <xsl:text>. </xsl:text>
1103    </xsl:comment>
1104
1105    <xsl:value-of select="$newline" />
1106    <xsl:value-of select="$newline" />
1107
1108    <body>
1109     <xsl:attribute name="text"><xsl:value-of select="$text-color" /></xsl:attribute>
1110     <xsl:attribute name="bgcolor"><xsl:value-of select="$background-color" /></xsl:attribute>
1111     <xsl:attribute name="background"><xsl:text>bckgrnd.gif</xsl:text></xsl:attribute>
1112     <xsl:attribute name="link"><xsl:value-of select="$link-color" /></xsl:attribute>
1113     <xsl:attribute name="alink"><xsl:value-of select="$alink-color" /></xsl:attribute>
1114     <xsl:attribute name="vlink"><xsl:value-of select="$vlink-color" /></xsl:attribute>
1115
1116     <xsl:value-of select="$newline" />
1117     <div id="title"><img src="title.gif" width="550" height="100" border="0" align="middle" usemap="#imagemap"><xsl:attribute name="alt"><xsl:apply-templates select="/gamebook/meta/title[1]" /></xsl:attribute></img></div><xsl:value-of select="$newline" />
1118     <div id="body"><xsl:value-of select="$newline" />
1119
1120      <xsl:choose>
1121
1122 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~ top-level ~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
1123
1124       <xsl:when test="$document-type='top-level'">
1125        <div class="frontmatter"><xsl:value-of select="$newline" />
1126
1127         <xsl:apply-templates select="/gamebook/meta/description[@class='blurb']" />
1128         <xsl:apply-templates select="/gamebook/meta/creator[@class='long']" />
1129
1130         <hr />
1131
1132         <xsl:apply-templates select="/gamebook/meta/description[@class='publication']" />
1133
1134         <p>
1135          <xsl:choose>
1136           <xsl:when test="$language='es'">
1137            <xsl:text>Fecha de Publicaci&oacute;n: </xsl:text>
1138           </xsl:when>
1139           <xsl:otherwise>
1140            <xsl:text>Publication Date: </xsl:text>
1141           </xsl:otherwise>
1142          </xsl:choose>
1143          <xsl:value-of select="/gamebook/meta/date[@class='publication']/day" />
1144          <xsl:text> </xsl:text>
1145          <xsl:choose>
1146           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 1">
1147            <xsl:choose>
1148             <xsl:when test="$language='es'"><xsl:text>de enero de</xsl:text></xsl:when>
1149             <xsl:otherwise><xsl:text>January</xsl:text></xsl:otherwise>
1150            </xsl:choose>
1151           </xsl:when>
1152           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 2">
1153            <xsl:choose>
1154             <xsl:when test="$language='es'"><xsl:text>de febrero de</xsl:text></xsl:when>
1155             <xsl:otherwise><xsl:text>February</xsl:text></xsl:otherwise>
1156            </xsl:choose>
1157           </xsl:when>
1158           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 3">
1159            <xsl:choose>
1160             <xsl:when test="$language='es'"><xsl:text>de marzo de</xsl:text></xsl:when>
1161             <xsl:otherwise><xsl:text>March</xsl:text></xsl:otherwise>
1162            </xsl:choose>
1163           </xsl:when>
1164           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 4">
1165            <xsl:choose>
1166             <xsl:when test="$language='es'"><xsl:text>de abril de</xsl:text></xsl:when>
1167             <xsl:otherwise><xsl:text>April</xsl:text></xsl:otherwise>
1168            </xsl:choose>
1169           </xsl:when>
1170           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 5">
1171            <xsl:choose>
1172             <xsl:when test="$language='es'"><xsl:text>de mayo de</xsl:text></xsl:when>
1173             <xsl:otherwise><xsl:text>May</xsl:text></xsl:otherwise>
1174            </xsl:choose>
1175           </xsl:when>
1176           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 6">
1177            <xsl:choose>
1178             <xsl:when test="$language='es'"><xsl:text>de junio de</xsl:text></xsl:when>
1179             <xsl:otherwise><xsl:text>June</xsl:text></xsl:otherwise>
1180            </xsl:choose>
1181           </xsl:when>
1182           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 7">
1183            <xsl:choose>
1184             <xsl:when test="$language='es'"><xsl:text>de julio de</xsl:text></xsl:when>
1185             <xsl:otherwise><xsl:text>July</xsl:text></xsl:otherwise>
1186            </xsl:choose>
1187           </xsl:when>
1188           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 8">
1189            <xsl:choose>
1190             <xsl:when test="$language='es'"><xsl:text>de agosto de</xsl:text></xsl:when>
1191             <xsl:otherwise><xsl:text>August</xsl:text></xsl:otherwise>
1192            </xsl:choose>
1193           </xsl:when>
1194           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 9">
1195            <xsl:choose>
1196             <xsl:when test="$language='es'"><xsl:text>de septiembre de</xsl:text></xsl:when>
1197             <xsl:otherwise><xsl:text>September</xsl:text></xsl:otherwise>
1198            </xsl:choose>
1199           </xsl:when>
1200           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 10">
1201            <xsl:choose>
1202             <xsl:when test="$language='es'"><xsl:text>de octubre de</xsl:text></xsl:when>
1203             <xsl:otherwise><xsl:text>October</xsl:text></xsl:otherwise>
1204            </xsl:choose>
1205           </xsl:when>
1206           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 11">
1207            <xsl:choose>
1208             <xsl:when test="$language='es'"><xsl:text>de noviembre de</xsl:text></xsl:when>
1209             <xsl:otherwise><xsl:text>November</xsl:text></xsl:otherwise>
1210            </xsl:choose>
1211           </xsl:when>
1212           <xsl:when test="/gamebook/meta/date[@class='publication']/month = 12">
1213            <xsl:choose>
1214             <xsl:when test="$language='es'"><xsl:text>de diciembre de</xsl:text></xsl:when>
1215             <xsl:otherwise><xsl:text>December</xsl:text></xsl:otherwise>
1216            </xsl:choose>
1217           </xsl:when>
1218           <xsl:otherwise>
1219            <xsl:text>Invalid Month</xsl:text>
1220           </xsl:otherwise>
1221          </xsl:choose>
1222          <xsl:text> </xsl:text>
1223          <xsl:value-of select="/gamebook/meta/date[@class='publication']/year" />
1224         </p>
1225
1226         <xsl:apply-templates select="/gamebook/meta/rights[@class='license-notification']" />
1227
1228         <xsl:value-of select="$newline" />
1229
1230         <xsl:call-template name="navigation-bar" />
1231
1232         <xsl:value-of select="$newline" />
1233        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1234
1235       </xsl:when>
1236
1237 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ toc ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
1238
1239       <xsl:when test="$document-type='toc'">
1240        <div class="frontmatter"><xsl:value-of select="$newline" />
1241         <h2>
1242          <xsl:choose>
1243           <xsl:when test="$language='es'">
1244            <xsl:text>&Iacute;ndice de Contenidos</xsl:text>
1245           </xsl:when>
1246           <xsl:otherwise>
1247            <xsl:text>Table of Contents</xsl:text>
1248           </xsl:otherwise>
1249          </xsl:choose>
1250         </h2><xsl:value-of select="$newline" />
1251
1252         <xsl:value-of select="$newline" />
1253         <xsl:value-of select="$newline" />
1254
1255         <ul><xsl:value-of select="$newline" />
1256          <xsl:variable name="title-page">
1257           <xsl:choose>
1258            <xsl:when test="$language='es'">
1259             <xsl:text>P&aacute;gina Principal</xsl:text>
1260            </xsl:when>
1261            <xsl:otherwise>
1262             <xsl:text>Title Page</xsl:text>
1263            </xsl:otherwise>
1264           </xsl:choose>
1265          </xsl:variable>
1266
1267          <li><a href="title.htm"><xsl:value-of select="$title-page"/></a></li><xsl:value-of select="$newline" />
1268          <xsl:for-each select="/gamebook/section/data/section">
1269           <li>
1270            <a><xsl:attribute name="href"><xsl:value-of select="@id" /><xsl:text>.htm</xsl:text></xsl:attribute>
1271             <xsl:apply-templates select="meta/title[1]" />
1272            </a>
1273            <xsl:if test="data/section[@class='frontmatter-separate' or @class='mainmatter-separate']">
1274             <xsl:value-of select="$newline" />
1275             <ul><xsl:value-of select="$newline" />
1276              <xsl:for-each select="data/section[@class='frontmatter-separate' or @class='mainmatter-separate']">
1277               <li>
1278                <a><xsl:attribute name="href"><xsl:value-of select="@id" /><xsl:text>.htm</xsl:text></xsl:attribute>
1279                 <xsl:value-of select ="meta/title[1]" />
1280                </a>
1281               </li><xsl:value-of select="$newline" />
1282              </xsl:for-each>
1283             </ul><xsl:value-of select="$newline" />
1284            </xsl:if>
1285           </li><xsl:value-of select="$newline" />
1286          </xsl:for-each>
1287         </ul><xsl:value-of select="$newline" />
1288
1289         <xsl:value-of select="$newline" />
1290         <xsl:value-of select="$newline" />
1291         <xsl:call-template name="navigation-bar" />
1292        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1293       </xsl:when>
1294
1295 <!-- ~~~~~~~~~~~~~~~~ second-level-frontmatter ~~~~~~~~~~~~~~~~~~~ -->
1296
1297       <xsl:when test="$document-type='second-level-frontmatter'">
1298        <div class="frontmatter"><xsl:value-of select="$newline" />
1299         <h2><xsl:apply-templates select="meta/title" /></h2><xsl:value-of select="$newline" />
1300
1301         <xsl:value-of select="$newline" />
1302
1303         <xsl:apply-templates />
1304
1305         <xsl:value-of select="$newline" />
1306
1307         <xsl:call-template name="navigation-bar" />
1308
1309        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1310       </xsl:when>
1311
1312 <!-- ~~~~~~~~~~~~~ third-level-frontmatter-separate ~~~~~~~~~~~~~~ -->
1313
1314       <xsl:when test="$document-type='third-level-frontmatter-separate'">
1315        <div class="frontmatter"><xsl:value-of select="$newline" />
1316         <h3><xsl:apply-templates select="meta/title" /></h3><xsl:value-of select="$newline" />
1317         <xsl:value-of select="$newline" />
1318
1319         <xsl:apply-templates />
1320
1321         <xsl:value-of select="$newline" />
1322
1323         <xsl:call-template name="navigation-bar" />
1324
1325        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1326       </xsl:when>
1327
1328 <!-- ~~~~~~~~~~~~~~~~ second-level-mainmatter ~~~~~~~~~~~~~~~~~~~ -->
1329
1330       <xsl:when test="$document-type='second-level-mainmatter'">
1331        <div class="mainmatter"><xsl:value-of select="$newline" />
1332         <h2><xsl:apply-templates select="meta/title" /></h2><xsl:value-of select="$newline" />
1333         <xsl:value-of select="$newline" />
1334
1335         <xsl:apply-templates />
1336
1337         <xsl:value-of select="$newline" />
1338
1339         <xsl:call-template name="navigation-bar" />
1340
1341        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1342       </xsl:when>
1343
1344 <!-- ~~~~~~~~~~~~~ third-level-mainmatter-separate ~~~~~~~~~~~~~~ -->
1345
1346       <xsl:when test="$document-type='third-level-mainmatter-separate'">
1347        <div class="mainmatter"><xsl:value-of select="$newline" />
1348         <h3><xsl:apply-templates select="meta/title" /></h3><xsl:value-of select="$newline" />
1349         <xsl:value-of select="$newline" />
1350
1351         <xsl:apply-templates />
1352
1353         <xsl:value-of select="$newline" />
1354
1355         <xsl:call-template name="navigation-bar" />
1356
1357        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1358       </xsl:when>
1359
1360 <!-- ~~~~~~~~~~~~~~~~ second-level-glossary ~~~~~~~~~~~~~~~~~~~ -->
1361
1362       <xsl:when test="$document-type='second-level-glossary'">
1363        <div class="mainmatter"><xsl:value-of select="$newline" />
1364         <h2><xsl:apply-templates select="meta/title" /></h2><xsl:value-of select="$newline" />
1365         <xsl:value-of select="$newline" />
1366
1367         <xsl:apply-templates />
1368
1369         <xsl:value-of select="$newline" />
1370
1371         <xsl:call-template name="alpha-bar">
1372          <xsl:with-param name="alpha-bar-id-prefix"><xsl:value-of select="$glossary-id-prefix" /></xsl:with-param>
1373         </xsl:call-template>
1374
1375         <xsl:call-template name="navigation-bar" />
1376
1377        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1378       </xsl:when>
1379
1380 <!-- ~~~~~~~~~~~~~ third-level-glossary-separate ~~~~~~~~~~~~~~ -->
1381
1382       <xsl:when test="$document-type='third-level-glossary-separate'">
1383        <div class="glossary"><xsl:value-of select="$newline" />
1384         <h3><xsl:apply-templates select="meta/title" /></h3><xsl:value-of select="$newline" />
1385         <xsl:call-template name="alpha-bar">
1386          <xsl:with-param name="alpha-bar-id-prefix"><xsl:value-of select="$glossary-id-prefix" /></xsl:with-param>
1387         </xsl:call-template>
1388
1389         <xsl:value-of select="$newline" />
1390
1391         <xsl:apply-templates />
1392
1393         <xsl:value-of select="$newline" />
1394
1395         <xsl:call-template name="navigation-bar" />
1396         <xsl:value-of select="$newline" />
1397        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1398       </xsl:when>
1399
1400 <!-- ~~~~~~~~~~~~~~~~~~ second-level-numbered ~~~~~~~~~~~~~~~~~~~~ -->
1401 <!--
1402
1403 The following automatically generated section list requires that the
1404 title of each section be a simple number.
1405
1406 -->
1407       <xsl:when test="$document-type='second-level-numbered'">
1408        <div class="numbered"><xsl:value-of select="$newline" />
1409         <h2><xsl:apply-templates select="meta/title" /></h2><xsl:value-of select="$newline" />
1410         <xsl:value-of select="$newline" />
1411
1412         <xsl:variable name="base-section-number" select="number( data/section[1]/meta/title ) - 1" />
1413         <p>
1414          <xsl:for-each select="data/section">
1415           <xsl:if test="position( ) mod 10 = 1">
1416            <b><a><xsl:attribute name="name"><xsl:value-of select="position( ) + $base-section-number" /></xsl:attribute>
1417             <xsl:value-of select="position( ) + $base-section-number" />
1418             <xsl:if test="not( position( ) = last( ) )">
1419              <xsl:text>-</xsl:text>
1420              <xsl:choose>
1421               <xsl:when test="position( ) + 9 &lt;= last( )">
1422                <xsl:value-of select="position( ) + 9 + $base-section-number" />
1423               </xsl:when>
1424               <xsl:otherwise>
1425                <xsl:value-of select="last( ) + $base-section-number" />
1426               </xsl:otherwise>
1427              </xsl:choose>
1428             </xsl:if>
1429            </a><xsl:text>: </xsl:text></b>
1430           </xsl:if>
1431           <a>
1432            <xsl:attribute name="href"><xsl:value-of select="@id" /><xsl:text>.htm</xsl:text></xsl:attribute>
1433            <xsl:apply-templates select="meta/title" />
1434           </a>
1435           <xsl:choose>
1436            <xsl:when test="position( ) mod 10 = 0">
1437             <br /><xsl:value-of select="$newline" />
1438            </xsl:when>
1439            <xsl:otherwise>
1440             <xsl:text> </xsl:text>
1441            </xsl:otherwise>
1442           </xsl:choose>
1443          </xsl:for-each>
1444         </p>
1445
1446         <xsl:value-of select="$newline" />
1447         <xsl:value-of select="$newline" />
1448
1449         <xsl:call-template name="navigation-bar" />
1450         <xsl:value-of select="$newline" />
1451        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1452       </xsl:when>
1453
1454 <!-- ~~~~~~~~~~~~~~~~~~ third-level-numbered ~~~~~~~~~~~~~~~~~~~~~ -->
1455
1456       <xsl:when test="$document-type='third-level-numbered'">
1457        <div class="numbered"><xsl:value-of select="$newline" />
1458         <h3><xsl:apply-templates select="meta/title" /></h3><xsl:value-of select="$newline" />
1459         <xsl:value-of select="$newline" />
1460
1461         <xsl:apply-templates />
1462
1463         <xsl:value-of select="$newline" />
1464         <xsl:call-template name="navigation-bar" />
1465         <xsl:value-of select="$newline" />
1466        </div>
1467       </xsl:when>
1468
1469 <!-- ~~~~~~~~~~~~~~~~~ footnotes ~~~~~~~~~~~~~~~~~~~ -->
1470
1471       <xsl:when test="$document-type='footnotz'">
1472        <div class="backmatter">
1473         <xsl:value-of select="$newline" />
1474         <!-- No particular reason to code title here -->
1475         <h2><xsl:apply-templates select="meta/title" /></h2><xsl:value-of select="$newline" />
1476         <xsl:value-of select="$newline" />
1477         <xsl:value-of select="$newline" />
1478         
1479         <!-- Generate list of footnotes -->
1480         <xsl:for-each select="//footnotes/footnote">
1481          <div class="footnote">
1482           <!-- will the list always contain the closest ancestor first? -->
1483           <xsl:variable name="footnote-section"><xsl:value-of select="ancestor::section[position()=1]/@id" /></xsl:variable>
1484           <xsl:variable name="footnote-marker"><xsl:number count="footnotes/footnote" from="/" level="any" format="1" /></xsl:variable>
1485           <xsl:variable name="footnote-idref"><xsl:value-of select="@idref" /></xsl:variable>
1486           
1487           <xsl:for-each select="*[1]">
1488            <p>
1489             <xsl:text>[</xsl:text>
1490             <a>
1491              <xsl:attribute name="href"><xsl:value-of select="$footnote-section" /><xsl:text>.htm#</xsl:text><xsl:value-of select="$footnote-idref" /></xsl:attribute>
1492              <xsl:value-of select="$footnote-marker" />
1493             </a>
1494             <xsl:text>] </xsl:text>
1495
1496             <xsl:text> (</xsl:text>
1497             <xsl:call-template name="section-title-link" />
1498             <xsl:text>) </xsl:text>
1499
1500             <xsl:apply-templates select="child::* | child::text()" />
1501            </p>
1502           </xsl:for-each>
1503           
1504           <xsl:for-each select="*[position() != 1]">
1505            <xsl:apply-templates select="." />
1506           </xsl:for-each>
1507           
1508          </div>
1509         </xsl:for-each>
1510         
1511         <!-- Backwards compatibility... needed? Probably not. -->
1512         <xsl:apply-templates />
1513         
1514         <xsl:value-of select="$newline" />
1515        
1516         <xsl:call-template name="navigation-bar" />
1517         <xsl:value-of select="$newline" />
1518        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1519       </xsl:when>
1520
1521 <!-- ~~~~~~~~~~~~~~~~~ second-level-backmatter ~~~~~~~~~~~~~~~~~~~ -->
1522
1523       <xsl:when test="$document-type='second-level-backmatter'">
1524        <div class="frontmatter"><xsl:value-of select="$newline" />
1525         <h2><xsl:apply-templates select="meta/title" /></h2><xsl:value-of select="$newline" />
1526
1527         <xsl:value-of select="$newline" />
1528         <xsl:value-of select="$newline" />
1529
1530         <xsl:apply-templates />
1531
1532         <xsl:value-of select="$newline" />
1533
1534         <xsl:call-template name="navigation-bar" />
1535         <xsl:value-of select="$newline" />
1536        </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1537       </xsl:when>
1538
1539 <!-- ~~~~~~~~~~~~~~~~~~~~~~~ map-adjusted ~~~~~~~~~~~~~~~~~~~~~~~~ -->
1540
1541       <xsl:when test="$document-type='map-adjusted'">
1542        <div class="frontmatter"><xsl:value-of select="$newline" />
1543         <h2><xsl:apply-templates select="meta/title" /></h2><xsl:value-of select="$newline" />
1544
1545         <xsl:value-of select="$newline" />
1546         <xsl:value-of select="$newline" />
1547
1548         <xsl:for-each select="data/* | data/text()">
1549          <xsl:variable name="map-illustration-alt-text">
1550           <xsl:choose>
1551            <xsl:when test="$language='es'">
1552             <xsl:text>mapa</xsl:text>
1553            </xsl:when>
1554            <xsl:otherwise>
1555             <xsl:text>map</xsl:text>
1556            </xsl:otherwise>
1557           </xsl:choose>
1558          </xsl:variable>
1559
1560          <!-- duplicated stuff here, no good way to avoid this while retaining backwards compatibility -->         
1561          <xsl:choose>
1562           <xsl:when test="self::illustration and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
1563            <xsl:variable name="illustration-width" select="instance[@class='html-compatible']/@width" />
1564            <xsl:variable name="illustration-height" select="instance[@class='html-compatible']/@height" />
1565            <xsl:variable name="illustration-src" select="instance[@class='html-compatible']/@src" />
1566
1567            <xsl:variable name="illustration-width-adjusted"><xsl:number value="386" /></xsl:variable>
1568            <xsl:variable name="illustration-height-adjusted"><xsl:number value="$illustration-height * $illustration-width-adjusted div $illustration-width" /></xsl:variable>
1569
1570            <div class="illustration"><div align="center"><xsl:value-of select="$newline" />
1571             <xsl:call-template name="illustration-framed">
1572              <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width-adjusted" /></xsl:with-param>
1573              <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height-adjusted" /></xsl:with-param>
1574              <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
1575              <xsl:with-param name="illustration-href">maplarge.htm</xsl:with-param>
1576              <xsl:with-param name="illustration-alt-text">
1577               <xsl:text>[</xsl:text>
1578               <xsl:value-of select="$map-illustration-alt-text"/>
1579               <xsl:text>]</xsl:text>
1580              </xsl:with-param>
1581             </xsl:call-template>
1582             <br /><br />
1583            </div></div><xsl:value-of select="$newline" />
1584
1585            <xsl:if test="instance[@class='text']">
1586             <xsl:apply-templates select="instance[@class='text']/*"/>
1587            </xsl:if>
1588           </xsl:when>
1589
1590           <xsl:when test="self::illref and @class='html-compatible'">
1591            <xsl:for-each select="id( @idref )">
1592             <xsl:if test="contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
1593              <xsl:variable name="illustration-width" select="instance[@class='html-compatible']/@width" />
1594              <xsl:variable name="illustration-height" select="instance[@class='html-compatible']/@height" />
1595              <xsl:variable name="illustration-src" select="instance[@class='html-compatible']/@src" />
1596
1597              <xsl:variable name="illustration-width-adjusted"><xsl:number value="386" /></xsl:variable>
1598              <xsl:variable name="illustration-height-adjusted"><xsl:number value="$illustration-height * $illustration-width-adjusted div $illustration-width" /></xsl:variable>
1599
1600              <div class="illustration">
1601               <div align="center"><xsl:value-of select="$newline" />
1602               <xsl:call-template name="illustration-framed">
1603                <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width-adjusted" /></xsl:with-param>
1604                <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height-adjusted" /></xsl:with-param>
1605                <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
1606                <xsl:with-param name="illustration-href">maplarge.htm</xsl:with-param>
1607                <xsl:with-param name="illustration-alt-text">
1608                 <xsl:text>[</xsl:text>
1609                 <xsl:value-of select="$map-illustration-alt-text"/>
1610                 <xsl:text>]</xsl:text>
1611                </xsl:with-param>
1612               </xsl:call-template>
1613               <br /><br />
1614              </div></div><xsl:value-of select="$newline" />
1615
1616              <xsl:if test="instance[@class='text']">
1617               <xsl:apply-templates select="instance[@class='text']/*"/>
1618              </xsl:if>
1619
1620             </xsl:if>
1621            </xsl:for-each>
1622           </xsl:when>
1623           <xsl:otherwise>
1624            <xsl:apply-templates select="." />
1625           </xsl:otherwise>
1626          </xsl:choose>
1627         </xsl:for-each>
1628
1629         <xsl:value-of select="$newline" />
1630
1631         <xsl:call-template name="navigation-bar" />
1632         <xsl:value-of select="$newline" />
1633        </div>
1634       </xsl:when>
1635
1636 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ map ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
1637
1638       <xsl:when test="$document-type='map'">
1639        <div class="frontmatter"><xsl:value-of select="$newline" />
1640         <h2><xsl:apply-templates select="meta/title" /></h2><xsl:value-of select="$newline" />
1641
1642         <xsl:value-of select="$newline" />
1643         <xsl:value-of select="$newline" />
1644
1645         <xsl:for-each select="data/* | data/text()">
1646          <xsl:variable name="map-illustration-alt-text">
1647           <xsl:choose>
1648            <xsl:when test="$language='es'">
1649             <xsl:text>mapa</xsl:text>
1650            </xsl:when>
1651            <xsl:otherwise>
1652             <xsl:text>map</xsl:text>
1653            </xsl:otherwise>
1654           </xsl:choose>
1655          </xsl:variable>
1656
1657          <!-- duplicated stuff here, no good way to avoid this while retaining backwards compatibility -->
1658          <xsl:choose>
1659           <xsl:when test="self::illustration and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
1660            <xsl:variable name="illustration-width" select="instance[@class='html-compatible']/@width" />
1661            <xsl:variable name="illustration-height" select="instance[@class='html-compatible']/@height" />
1662            <xsl:variable name="illustration-src" select="instance[@class='html-compatible']/@src" />
1663
1664            <div class="illustration"><div align="center"><xsl:value-of select="$newline" />
1665             <xsl:call-template name="illustration-framed">
1666              <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width" /></xsl:with-param>
1667              <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height" /></xsl:with-param>
1668              <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
1669              <xsl:with-param name="illustration-href">map.htm</xsl:with-param>
1670              <xsl:with-param name="illustration-alt-text">
1671               <xsl:text>[</xsl:text>
1672               <xsl:value-of select="$map-illustration-alt-text"/>
1673               <xsl:text>]</xsl:text>
1674              </xsl:with-param>
1675             </xsl:call-template>
1676             <br /><xsl:value-of select="$newline" />
1677            </div></div><xsl:value-of select="$newline" />
1678           </xsl:when>
1679
1680           <xsl:when test="self::illref and @class='html-compatible'">
1681            <xsl:for-each select="id( @idref )">
1682             <xsl:if test="contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
1683              <xsl:variable name="illustration-width" select="instance[@class='html-compatible']/@width" />
1684              <xsl:variable name="illustration-height" select="instance[@class='html-compatible']/@height" />
1685              <xsl:variable name="illustration-src" select="instance[@class='html-compatible']/@src" />
1686
1687              <div class="illustration">
1688               <div align="center"><xsl:value-of select="$newline" />
1689               <xsl:call-template name="illustration-framed">
1690                <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width" /></xsl:with-param>
1691                <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height" /></xsl:with-param>
1692                <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
1693                <xsl:with-param name="illustration-href">map.htm</xsl:with-param>
1694                <xsl:with-param name="illustration-alt-text">
1695                 <xsl:text>[</xsl:text>
1696                 <xsl:value-of select="$map-illustration-alt-text"/>
1697                 <xsl:text>]</xsl:text>
1698                </xsl:with-param>
1699               </xsl:call-template>
1700               <br /><xsl:value-of select="$newline" />
1701              </div></div><xsl:value-of select="$newline" />
1702             </xsl:if>
1703            </xsl:for-each>
1704           </xsl:when>
1705           <xsl:otherwise>
1706            <xsl:apply-templates select="." />
1707           </xsl:otherwise>
1708          </xsl:choose>
1709         </xsl:for-each>
1710
1711         <xsl:value-of select="$newline" />
1712
1713         <xsl:call-template name="navigation-bar" />
1714         <xsl:value-of select="$newline" />
1715        </div>
1716       </xsl:when>
1717
1718 <!-- ~~~~~~~~~~~~~~~~~~~~~~ illustration ~~~~~~~~~~~~~~~~~~~~~~~~~ -->
1719
1720       <xsl:when test="$document-type='illustration'">
1721        <xsl:variable name="illustration-width" select="instance[@class='html-compatible']/@width" />
1722        <xsl:variable name="illustration-height" select="instance[@class='html-compatible']/@height" />
1723        <xsl:variable name="illustration-src" select="instance[@class='html-compatible']/@src" />
1724
1725        <h3>
1726         <xsl:choose>
1727          <xsl:when test="$language='es'">
1728           <xsl:text>Ilustraci&oacute;n </xsl:text>
1729          </xsl:when>
1730          <xsl:otherwise>
1731           <xsl:text>Illustration </xsl:text>
1732          </xsl:otherwise>
1733         </xsl:choose>
1734         <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
1735        </h3><xsl:value-of select="$newline" />
1736
1737        <div class="illustration"><div align="center"><xsl:value-of select="$newline" />
1738         <xsl:call-template name="illustration-framed">
1739          <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width" /></xsl:with-param>
1740          <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height" /></xsl:with-param>
1741          <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
1742         </xsl:call-template>
1743         <br /><xsl:value-of select="$newline" />
1744        </div></div><xsl:value-of select="$newline" />
1745        <p class="caption"><strong><xsl:apply-templates select="meta/description" /></strong></p><xsl:value-of select="$newline" />
1746       </xsl:when>
1747
1748 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~ error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
1749
1750       <xsl:otherwise>
1751        <xsl:message>
1752         <xsl:text>xhtml-wrapper: Cannot process document of type "</xsl:text>
1753         <xsl:value-of select="$document-type" />
1754         <xsl:text>".</xsl:text>
1755        </xsl:message>
1756        <p>
1757         <xsl:text>xhtml-wrapper: Cannot process document of type "</xsl:text>
1758         <xsl:value-of select="$document-type" />
1759         <xsl:text>".</xsl:text>
1760        </p>
1761       </xsl:otherwise>
1762
1763      </xsl:choose>
1764
1765 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~ footer ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
1766
1767      <xsl:call-template name="process-footnotes" />
1768
1769      <p class="copyright"><xsl:apply-templates select="/gamebook/meta/rights[@class='copyrights']" /></p><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
1770
1771     </div><xsl:value-of select="$newline" />
1772
1773     <map name="imagemap" id="imagemap">
1774      <area shape="rect" coords="0,0,99,99" href="http://www.projectaon.org/" alt="Project Aon" target="_top" />
1775      <area shape="default" href="title.htm">
1776       <xsl:attribute name="alt"><xsl:apply-templates select="/gamebook/meta/title[1]" /></xsl:attribute>
1777      </area>
1778     </map>
1779
1780    </body>
1781
1782    <xsl:value-of select="$newline" />
1783    <xsl:value-of select="$newline" />
1784
1785   </html>
1786  </redirect:write>
1787
1788 </xsl:template>
1789
1790 <xsl:template name="process-footnotes">
1791  <xsl:if test="footnotes/footnote">
1792   <div id="footnotes"><xsl:value-of select="$newline" />
1793    <xsl:for-each select="footnotes/footnote">
1794     <xsl:variable name="footnote-idref" select="@idref" />
1795     <xsl:variable name="footnote-id" select="@id" />
1796     <xsl:variable name="footnote-marker"><xsl:number count="footnotes/footnote" from="/" level="any" format="1" /></xsl:variable>
1797
1798     <xsl:for-each select="*[1]">
1799      <p>
1800       <xsl:text>[</xsl:text>
1801        <a href="#{$footnote-idref}" name="{$footnote-id}"><xsl:value-of select="$footnote-marker" /></a>
1802       <xsl:text>] </xsl:text>
1803       <xsl:apply-templates select="child::* | child::text()" />
1804      </p>
1805     </xsl:for-each>
1806
1807     <xsl:for-each select="*[position() != 1]">
1808       <xsl:apply-templates select="." />
1809     </xsl:for-each>
1810    </xsl:for-each>
1811   </div><xsl:value-of select="$newline" />
1812  </xsl:if>
1813 </xsl:template>
1814
1815 <xsl:template name="navigation-bar">
1816  <xsl:variable name="table-of-contents">
1817   <xsl:choose>
1818    <xsl:when test="$language='es'">
1819     <xsl:text>&Iacute;ndice de Contenidos</xsl:text>
1820    </xsl:when>
1821    <xsl:otherwise>
1822     <xsl:text>Table of Contents</xsl:text>      
1823    </xsl:otherwise>
1824   </xsl:choose>
1825  </xsl:variable>
1826  <div class="navigation">
1827   <table cellspacing="0" cellpadding="0" border="0">
1828    <tr>
1829     <td>
1830      <xsl:choose>
1831       <xsl:when test="meta/link[@class='prev']">
1832        <a>
1833         <xsl:attribute name="href">
1834          <xsl:apply-templates select="meta/link[@class='prev']/@idref" />
1835          <xsl:text>.htm</xsl:text>
1836         </xsl:attribute>
1837         <img src="back.gif" width="150" height="30" border="0">
1838          <xsl:attribute name="alt">
1839           <xsl:value-of select="id( meta/link[@class='prev']/@idref )/meta/title" />
1840          </xsl:attribute>
1841         </img>
1842        </a>
1843       </xsl:when>
1844       <xsl:otherwise>
1845        <img src="left.gif" width="150" height="30" border="0" alt="" />
1846       </xsl:otherwise>
1847      </xsl:choose>
1848     </td>
1849     <td><a href="toc.htm"><img src="toc.gif" width="150" height="30" border="0" alt="{$table-of-contents}" /></a></td>
1850     <td>
1851      <xsl:choose>
1852       <xsl:when test="meta/link[@class='next']">
1853        <a>
1854         <xsl:attribute name="href">
1855          <xsl:value-of select="meta/link[@class='next']/@idref" />
1856          <xsl:text>.htm</xsl:text>
1857         </xsl:attribute>
1858         <img src="forward.gif" width="150" height="30" border="0">
1859          <xsl:attribute name="alt">
1860           <xsl:choose>
1861            <xsl:when test="meta/link[@class='next']/@idref = 'sect1'">
1862             <xsl:choose>
1863              <xsl:when test="$language='es'">
1864               <xsl:text>Secci&oacute;n 1</xsl:text>
1865              </xsl:when>
1866              <xsl:otherwise>
1867               <xsl:text>Section 1</xsl:text>
1868              </xsl:otherwise>
1869             </xsl:choose>
1870            </xsl:when>
1871            <xsl:otherwise>
1872             <xsl:value-of select="id( meta/link[@class='next']/@idref )/meta/title" />
1873            </xsl:otherwise>
1874           </xsl:choose>
1875          </xsl:attribute>
1876         </img>
1877        </a>
1878       </xsl:when>
1879       <xsl:otherwise>
1880        <img src="right.gif" width="150" height="30" border="0" alt="" />
1881       </xsl:otherwise>
1882      </xsl:choose>
1883     </td>
1884    </tr>
1885   </table>
1886  </div>
1887 </xsl:template>
1888
1889 <xsl:template name="alpha-bar">
1890  <xsl:param name="alpha-bar-id-prefix"></xsl:param>
1891
1892   <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" />
1893
1894 </xsl:template>
1895
1896 <xsl:template name="illustration-framed">
1897  <xsl:param name="brdrl-width">32</xsl:param>
1898  <xsl:param name="brdr-height">32</xsl:param>
1899  <xsl:param name="brdrr-width">32</xsl:param>
1900  <xsl:param name="illustration-alt-text">
1901   <xsl:choose>
1902    <xsl:when test="$language='es'">
1903     <xsl:text>ilustraci&oacute;n</xsl:text>
1904    </xsl:when>
1905    <xsl:otherwise>
1906     <xsl:text>illustration</xsl:text>
1907    </xsl:otherwise>
1908   </xsl:choose>
1909  </xsl:param>
1910
1911  <xsl:param name="illustration-width"></xsl:param>
1912  <xsl:param name="illustration-height"></xsl:param>
1913  <xsl:param name="illustration-src"></xsl:param>
1914  <xsl:param name="illustration-href"></xsl:param>
1915
1916  <table border="0" cellpadding="0" cellspacing="0">
1917   <xsl:value-of select="$newline" />
1918   <tr>
1919    <xsl:value-of select="$newline" />
1920    <td><img src="brdrtpl.gif" width="{$brdrl-width}" height="{$brdr-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1921    <td><img src="brdrtp.gif" width="{$illustration-width}" height="{$brdr-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1922    <td><img src="brdrtpr.gif" width="{$brdrr-width}" height="{$brdr-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1923   </tr><xsl:value-of select="$newline" />
1924   <tr>
1925    <xsl:value-of select="$newline" />
1926    <td><img src="brdrl.gif" width="{$brdrl-width}" height="{$illustration-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1927    <td>
1928     <xsl:choose>
1929      <xsl:when test="$illustration-href">
1930       <a href="{$illustration-href}">
1931        <img src="{$illustration-src}" width="{$illustration-width}" height="{$illustration-height}" align="middle" border="0" alt="{$illustration-alt-text}" />
1932       </a>
1933      </xsl:when>
1934      <xsl:otherwise>
1935       <img src="{$illustration-src}" width="{$illustration-width}" height="{$illustration-height}" align="middle" border="0" alt="[{$illustration-alt-text}]" />
1936      </xsl:otherwise>
1937     </xsl:choose>
1938    </td><xsl:value-of select="$newline" />
1939    <td><img src="brdrr.gif" width="{$brdrr-width}" height="{$illustration-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1940   </tr><xsl:value-of select="$newline" />
1941   <tr>
1942    <xsl:value-of select="$newline" />
1943    <td><img src="brdrbtl.gif" width="{$brdrl-width}" height="{$brdr-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1944    <td><img src="brdrbt.gif" width="{$illustration-width}" height="{$brdr-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1945    <td><img src="brdrbtr.gif" width="{$brdrr-width}" height="{$brdr-height}" align="middle" alt="" /></td><xsl:value-of select="$newline" />
1946   </tr><xsl:value-of select="$newline" />
1947  </table><xsl:value-of select="$newline" />
1948 </xsl:template>
1949
1950 <!--
1951  A "subroutine" to generate a link to the current section, with the section title (expanded with "Section " in case of a numbered section) as link text.
1952 -->
1953 <xsl:template name="section-title-link">
1954  <!-- will the list always contain the closest ancestor first? -->
1955  <xsl:variable name="section-title">
1956   <!-- numbered or not? -->
1957   <xsl:if test="ancestor::section[position()=1]/@class='numbered'">
1958    <xsl:choose>
1959     <xsl:when test="$language='es'">
1960      <xsl:text>Secci&oacute;n </xsl:text>
1961     </xsl:when>
1962     <xsl:otherwise>
1963      <xsl:text>Section </xsl:text>
1964     </xsl:otherwise>
1965    </xsl:choose>
1966   </xsl:if>
1967   <xsl:apply-templates select="ancestor::section[position()=1]/meta/title[1]" />
1968  </xsl:variable>
1969  
1970  <a>
1971   <xsl:attribute name="href"><xsl:value-of select="ancestor::section[position()=1]/@id" /><xsl:text>.htm</xsl:text></xsl:attribute>
1972   <xsl:value-of select="$section-title" />
1973  </a>
1974 </xsl:template>
1975
1976 </xsl:transform>