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