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