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