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