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