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