f5ff53a82a882316ff3b9faf7ff217090f8f7497
[project-aon.git] / xml / xhtml-mongoose.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 $Id$
10
11 $Log$
12 Revision 1.3  2006/12/07 01:42:28  jonathan.blake
13 Text illustrations need inclusion
14
15 Revision 1.2  2006/11/25 18:57:16  jonathan.blake
16 Fixed links to footnotes
17
18 Revision 1.1  2006/11/25 04:48:52  jonathan.blake
19 Modified to generate a single unstyled, UTF-8, HTML file which lacks any illustrations
20
21
22 ///// xhtml.xsl used as source for xhtml-mongoose.xsl
23
24 Revision 1.12  2006/06/05 23:46:46  jonathan.blake
25 Fixing the handling of titles when <ch.*/> elements are used.
26
27 Revision 1.11  2006/04/04 18:48:52  angantyr
28 Fixed paragraphed list and illref template bug.
29
30 Revision 1.10  2006/04/02 19:14:37  angantyr
31 Introduced automatic footnotes list generation and changed the illustrations
32 list generation so that links to numbered sections are titled "Section ...".
33 Backwards compatible with old XML files.
34
35 Revision 1.9  2006/03/14 21:04:03  angantyr
36 Changed the illustration handling with the introduction of 'illref's.
37 Backwards compatible.
38
39 Revision 1.8  2006/03/13 18:38:49  jonathan.blake
40 Fixed minor Spanish translation issue
41
42 Revision 1.7  2006/03/09 18:56:33  jonathan.blake
43 Added a language parameter and coding to switch between languages when the output is hard-coded into the transformation.
44
45 Revision 1.5  2006/03/02 00:33:32  jonathan.blake
46 Removed the 'book-path' parameter to work with new gbtoxhtml.pl
47
48 Revision 1.4  2005/12/27 01:51:29  angantyr
49 Added templates for the "bookref" and "footref" elements.
50
51 Revision 1.3  2005/12/05 21:29:04  jonathan.blake
52 Added the facilities to properly handle character elements.
53
54 Revision 1.2  2005/04/09 19:51:50  angantyr
55 Added handling of open-ended quotes.
56
57 Revision 1.1  2005/01/30 01:32:52  jonathan.blake
58 Initial freepository revision of XML support documents.
59
60 Revision 1.12  2003/10/07 06:05:14  Jon
61 Added capability for "accent" illustrations.
62
63 Revision 1.11  2002/12/06 22:12:04  jblake
64 Added default namespace declaration to transformation element
65 and removed all the extraneous declarations in the template
66 elements.
67
68 Revision 1.10  2002/11/17 22:37:25  jblake
69 Removed the "medium" creator entry from the templates.
70 Will they be of any use?
71
72 Revision 1.9  2002/11/17 05:06:56  jblake
73 Rearranged the title page.
74
75 Revision 1.8  2002/11/15 19:35:25  jblake
76 Fixed "Content-type" of XHTML output.
77
78 Revision 1.7  2002/11/15 00:15:39  jblake
79 Fixed a problem with the client-side image map and fixed
80 the numbered section list generation so that it will work
81 for Shadow on the Sand.
82
83 Revision 1.6  2002/10/30 05:59:45  jblake
84 Added a value for the alt attribute of the ToC image on the navigation bar.
85
86 Revision 1.5  2002/10/24 15:53:41  jblake
87 Fixed a conflict with whitespace and paragraphed lists.
88
89 Revision 1.4  2002/10/24 15:06:51  jblake
90 Added xmlns attributes to all elements that are top level in
91 their templates. This was an adjustment required by Xalan-J 2.4.
92
93 Also reinstated the comment in each document since the new
94 version of Xalan redirects it properly.
95
96 Revision 1.3  2002/10/23 05:18:29  jblake
97 Added the capability to filter which illustrators' work is used.
98 This is accomplished by the "use-illustrators" parameter.
99
100 Revision 1.2  2002/10/20 06:25:35  jblake
101 Added support for CLOSE COMBAT SKILL for Freeway Warrior books.
102
103 Revision 1.1  2002/10/15 23:29:51  jblake
104 Initial revision
105
106
107 20020327 - repurposed to be used with Xalan Java 2
108
109 Todo:
110
111 * Add blank whitespace handling to the paragraphed list template
112
113 -->
114
115 <xsl:transform version="1.0"
116   xmlns="http://www.w3.org/1999/xhtml"
117   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
118   xmlns:redirect="org.apache.xalan.lib.Redirect"
119   extension-element-prefixes="redirect">
120
121 <xsl:output method="xml"
122             encoding="utf-8"
123             omit-xml-declaration="yes"
124             doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
125             doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
126
127 <xsl:strip-space elements="section data ol ul dl li dd footnotes footnote" />
128 <xsl:preserve-space elements="p choice" />
129
130 <!-- ====================== parameters ========================== -->
131
132 <xsl:param name="use-illustrators" />
133 <xsl:param name="language"><xsl:text>en</xsl:text></xsl:param>
134  
135 <!-- ======================= variables ========================== -->
136
137 <xsl:variable name="newline">
138 <xsl:text>
139 </xsl:text>
140 </xsl:variable>
141
142 <!-- ======================== Templates ========================= -->
143
144 <!-- ================= hierarchical sections ==================== -->
145
146 <xsl:template match="meta" />
147 <xsl:template match="section" />
148
149 <xsl:template match="/gamebook">
150  <html xml:lang="en-UK" lang="en-UK">
151
152   <xsl:value-of select="$newline" />
153   <xsl:value-of select="$newline" />
154
155   <head><xsl:value-of select="$newline" />
156    <title>
157     <xsl:apply-templates select="/gamebook/meta/title[1]" />
158    </title><xsl:value-of select="$newline" />
159    <meta http-equiv="Content-type" content="text/html; charset=utf-8" /><xsl:value-of select="$newline" />
160    <meta name="robots" content="noindex,nofollow" /><xsl:value-of select="$newline" />
161   </head>
162
163   <xsl:value-of select="$newline" />
164   <xsl:value-of select="$newline" />
165
166   <body>
167    <xsl:comment>
168     <xsl:text> </xsl:text>
169     <xsl:apply-templates select="/gamebook/meta/rights[@class='copyrights']" />
170     <xsl:choose>
171      <xsl:when test="$language='es'">
172       <xsl:text> Publicado por </xsl:text>
173      </xsl:when>
174      <xsl:otherwise>
175       <xsl:text> Published by </xsl:text>
176      </xsl:otherwise>
177     </xsl:choose>
178     <xsl:apply-templates select="/gamebook/meta/publisher[1]" />
179     <xsl:text>. </xsl:text>
180    </xsl:comment>
181
182    <xsl:value-of select="$newline" />
183    <xsl:value-of select="$newline" />
184
185    <h1>
186     <a name="title">
187      <xsl:apply-templates select="/gamebook/meta/title[1]" />
188     </a>
189    </h1><xsl:value-of select="$newline" />
190
191    <xsl:apply-templates/>
192
193   </body>
194  </html>
195 </xsl:template>
196
197 <!-- ::::::::::::::::::: top-level section :::::::::::::::::::::: -->
198
199 <xsl:template match="/gamebook/section[@id='title']">
200  <div class="frontmatter"><xsl:value-of select="$newline" />
201
202   <xsl:apply-templates select="/gamebook/meta/description[@class='blurb']" />
203   <xsl:apply-templates select="/gamebook/meta/creator[@class='long']" />
204
205   <hr />
206
207   <xsl:apply-templates select="/gamebook/meta/description[@class='publication']" />
208
209   <p>
210    <xsl:choose>
211     <xsl:when test="$language='es'">
212      <xsl:text>Fecha de Publicaci&oacute;n: </xsl:text>
213     </xsl:when>
214     <xsl:otherwise>
215      <xsl:text>Publication Date: </xsl:text>
216     </xsl:otherwise>
217    </xsl:choose>
218    <xsl:value-of select="/gamebook/meta/date[@class='publication']/day" />
219    <xsl:text> </xsl:text>
220    <xsl:choose>
221     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 1">
222      <xsl:choose>
223       <xsl:when test="$language='es'"><xsl:text>de enero de</xsl:text></xsl:when>
224       <xsl:otherwise><xsl:text>January</xsl:text></xsl:otherwise>
225      </xsl:choose>
226     </xsl:when>
227     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 2">
228      <xsl:choose>
229       <xsl:when test="$language='es'"><xsl:text>de febrero de</xsl:text></xsl:when>
230       <xsl:otherwise><xsl:text>February</xsl:text></xsl:otherwise>
231      </xsl:choose>
232     </xsl:when>
233     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 3">
234      <xsl:choose>
235       <xsl:when test="$language='es'"><xsl:text>de marzo de</xsl:text></xsl:when>
236       <xsl:otherwise><xsl:text>March</xsl:text></xsl:otherwise>
237      </xsl:choose>
238     </xsl:when>
239     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 4">
240      <xsl:choose>
241       <xsl:when test="$language='es'"><xsl:text>de abril de</xsl:text></xsl:when>
242       <xsl:otherwise><xsl:text>April</xsl:text></xsl:otherwise>
243      </xsl:choose>
244     </xsl:when>
245     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 5">
246      <xsl:choose>
247       <xsl:when test="$language='es'"><xsl:text>de mayo de</xsl:text></xsl:when>
248       <xsl:otherwise><xsl:text>May</xsl:text></xsl:otherwise>
249      </xsl:choose>
250     </xsl:when>
251     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 6">
252      <xsl:choose>
253       <xsl:when test="$language='es'"><xsl:text>de junio de</xsl:text></xsl:when>
254       <xsl:otherwise><xsl:text>June</xsl:text></xsl:otherwise>
255      </xsl:choose>
256     </xsl:when>
257     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 7">
258      <xsl:choose>
259       <xsl:when test="$language='es'"><xsl:text>de julio de</xsl:text></xsl:when>
260       <xsl:otherwise><xsl:text>July</xsl:text></xsl:otherwise>
261      </xsl:choose>
262     </xsl:when>
263     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 8">
264      <xsl:choose>
265       <xsl:when test="$language='es'"><xsl:text>de agosto de</xsl:text></xsl:when>
266       <xsl:otherwise><xsl:text>August</xsl:text></xsl:otherwise>
267      </xsl:choose>
268     </xsl:when>
269     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 9">
270      <xsl:choose>
271       <xsl:when test="$language='es'"><xsl:text>de septiembre de</xsl:text></xsl:when>
272       <xsl:otherwise><xsl:text>September</xsl:text></xsl:otherwise>
273      </xsl:choose>
274     </xsl:when>
275     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 10">
276      <xsl:choose>
277       <xsl:when test="$language='es'"><xsl:text>de octubre de</xsl:text></xsl:when>
278       <xsl:otherwise><xsl:text>October</xsl:text></xsl:otherwise>
279      </xsl:choose>
280     </xsl:when>
281     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 11">
282      <xsl:choose>
283       <xsl:when test="$language='es'"><xsl:text>de noviembre de</xsl:text></xsl:when>
284       <xsl:otherwise><xsl:text>November</xsl:text></xsl:otherwise>
285      </xsl:choose>
286     </xsl:when>
287     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 12">
288      <xsl:choose>
289       <xsl:when test="$language='es'"><xsl:text>de diciembre de</xsl:text></xsl:when>
290       <xsl:otherwise><xsl:text>December</xsl:text></xsl:otherwise>
291      </xsl:choose>
292     </xsl:when>
293     <xsl:otherwise>
294      <xsl:text>Invalid Month</xsl:text>
295     </xsl:otherwise>
296    </xsl:choose>
297    <xsl:text> </xsl:text>
298    <xsl:value-of select="/gamebook/meta/date[@class='publication']/year" />
299   </p>
300
301   <xsl:apply-templates select="/gamebook/meta/rights[@class='license-notification']" />
302
303   <xsl:value-of select="$newline" />
304
305   <xsl:value-of select="$newline" />
306  </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
307
308  <xsl:apply-templates />
309 </xsl:template>
310
311 <xsl:template match="/gamebook/section[@id='toc']">
312  <div class="frontmatter"><xsl:value-of select="$newline" />
313   <h2>
314    <xsl:choose>
315     <xsl:when test="$language='es'">
316      <xsl:text>&Iacute;ndice de Contenidos</xsl:text>
317     </xsl:when>
318     <xsl:otherwise>
319      <xsl:text>Table of Contents</xsl:text>
320     </xsl:otherwise>
321    </xsl:choose>
322   </h2><xsl:value-of select="$newline" />
323
324   <xsl:value-of select="$newline" />
325   <xsl:value-of select="$newline" />
326
327   <ul><xsl:value-of select="$newline" />
328    <xsl:variable name="title-page">
329     <xsl:choose>
330      <xsl:when test="$language='es'">
331       <xsl:text>P&aacute;gina Principal</xsl:text>
332      </xsl:when>
333      <xsl:otherwise>
334       <xsl:text>Title Page</xsl:text>
335      </xsl:otherwise>
336     </xsl:choose>
337    </xsl:variable>
338
339    <xsl:for-each select="/gamebook/section/data/section">
340     <li>
341      <a><xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="@id" /></xsl:attribute>
342       <xsl:apply-templates select="meta/title[1]" />
343      </a>
344      <xsl:if test="data/section[@class='frontmatter-separate' or @class='mainmatter-separate']">
345       <xsl:value-of select="$newline" />
346       <ul><xsl:value-of select="$newline" />
347        <xsl:for-each select="data/section[@class='frontmatter-separate' or @class='mainmatter-separate']">
348         <li>
349          <a><xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="@id" /></xsl:attribute>
350           <xsl:value-of select ="meta/title[1]" />
351          </a>
352         </li><xsl:value-of select="$newline" />
353        </xsl:for-each>
354       </ul><xsl:value-of select="$newline" />
355      </xsl:if>
356     </li><xsl:value-of select="$newline" />
357    </xsl:for-each>
358   </ul><xsl:value-of select="$newline" />
359
360  </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
361 </xsl:template>
362
363 <!-- ::::::::::: second-level frontmatter sections :::::::::::::: -->
364
365 <xsl:template match="/gamebook/section/data/section[@class='frontmatter']">
366  <div class="frontmatter"><xsl:value-of select="$newline" />
367   <h2><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h2>
368
369   <xsl:value-of select="$newline" />
370   <xsl:value-of select="$newline" />
371
372   <xsl:apply-templates />
373  </div>
374 </xsl:template>
375
376 <!-- :::::::::::: third-level front matter sections ::::::::::::: -->
377
378 <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter']">
379  <h3><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h3>
380
381  <xsl:value-of select="$newline" />
382  <xsl:value-of select="$newline" />
383
384  <xsl:apply-templates />
385 </xsl:template>
386
387 <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter-separate']">
388  <h3><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h3>
389
390  <xsl:value-of select="$newline" />
391  <xsl:value-of select="$newline" />
392
393  <xsl:apply-templates />
394 </xsl:template>
395
396 <!-- :::::::::::: fourth-level front matter sections :::::::::::: -->
397
398 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='frontmatter']">
399  <h4><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h4>
400
401  <xsl:value-of select="$newline" />
402  <xsl:value-of select="$newline" />
403
404  <xsl:apply-templates />
405 </xsl:template>
406
407 <!-- ::::::::::::: fifth-level front matter sections :::::::::::: -->
408
409 <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='frontmatter']">
410  <h5><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h5>
411
412  <xsl:value-of select="$newline" />
413  <xsl:value-of select="$newline" />
414
415  <xsl:apply-templates />
416 </xsl:template>
417
418 <!-- ::::::::::: second-level main matter sections :::::::::::::: -->
419
420 <xsl:template match="/gamebook/section/data/section[@class='mainmatter']">
421  <div class="mainmatter"><xsl:value-of select="$newline" />
422   <h2><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h2>
423
424   <xsl:value-of select="$newline" />
425   <xsl:value-of select="$newline" />
426
427   <xsl:apply-templates />
428  </div>
429 </xsl:template>
430
431 <!-- :::::::::::: third-level main matter sections ::::::::::::: -->
432
433 <xsl:template match="/gamebook/section/data/section/data/section[@class='mainmatter']">
434  <h3><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h3>
435
436  <xsl:value-of select="$newline" />
437  <xsl:value-of select="$newline" />
438
439  <xsl:apply-templates />
440 </xsl:template>
441
442 <xsl:template match="/gamebook/section/data/section/data/section[@class='mainmatter-separate']">
443  <h3><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h3>
444
445  <xsl:value-of select="$newline" />
446  <xsl:value-of select="$newline" />
447
448  <xsl:apply-templates />
449 </xsl:template>
450
451 <!-- :::::::::::: fourth-level main matter sections :::::::::::: -->
452
453 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='mainmatter']">
454  <h4><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h4>
455
456  <xsl:value-of select="$newline" />
457  <xsl:value-of select="$newline" />
458
459  <xsl:apply-templates />
460 </xsl:template>
461
462 <!-- ::::::::::::: fifth-level main matter sections :::::::::::: -->
463
464 <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='mainmatter']">
465  <h5><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h5>
466
467  <xsl:value-of select="$newline" />
468  <xsl:value-of select="$newline" />
469
470  <xsl:apply-templates />
471 </xsl:template>
472
473 <!-- :::::::::::::::::: numbered sections ::::::::::::::::::::::: -->
474
475 <xsl:template match="/gamebook/section/data/section[@class='numbered']">
476  <div class="numbered"><xsl:value-of select="$newline" />
477   <h2><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h2><xsl:value-of select="$newline" />
478   <xsl:value-of select="$newline" />
479
480   <xsl:apply-templates/>
481
482  </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
483 </xsl:template>
484
485 <xsl:template match="/gamebook/section/data/section/data/section[@class='numbered']">
486  <h3><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h3><xsl:value-of select="$newline" />
487  <xsl:value-of select="$newline" />
488
489  <xsl:apply-templates />
490
491  <xsl:value-of select="$newline" />
492 </xsl:template>
493
494 <!-- :::::::::::: second-level backmatter sections :::::::::::::: -->
495
496 <xsl:template match="/gamebook/section/data/section[@class='backmatter']">
497  <div class="frontmatter"><xsl:value-of select="$newline" />
498   <h2><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h2><xsl:value-of select="$newline" />
499
500   <xsl:value-of select="$newline" />
501   <xsl:value-of select="$newline" />
502
503   <xsl:apply-templates />
504
505   <xsl:value-of select="$newline" />
506
507  </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
508 </xsl:template>
509
510 <!-- ::::::::::::: third-level back matter sections ::::::::::::: -->
511
512 <xsl:template match="/gamebook/section/data/section/data/section[@class='backmatter']">
513  <h3><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h3>
514
515  <xsl:value-of select="$newline" />
516  <xsl:value-of select="$newline" />
517
518  <xsl:apply-templates />
519 </xsl:template>
520
521 <!-- ::::::::::::: fourth-level back matter sections ::::::::::::: -->
522
523 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='backmatter']">
524  <h4><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h4>
525
526  <xsl:value-of select="$newline" />
527  <xsl:value-of select="$newline" />
528
529  <xsl:apply-templates />
530 </xsl:template>
531
532 <!-- ::::::::::::::::::::: footnotes template ::::::::::::::::::::::::: -->
533
534 <xsl:template match="id( 'footnotz' )">
535  <div class="backmatter">
536   <xsl:value-of select="$newline" />
537   <!-- No particular reason to code title here -->
538   <h2><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:apply-templates select="meta/title[1]" /></a></h2><xsl:value-of select="$newline" />
539   <xsl:value-of select="$newline" />
540   <xsl:value-of select="$newline" />
541    
542   <!-- Generate list of footnotes -->
543   <div class="footnote">
544    <xsl:for-each select="//footnotes/footnote">
545     <!-- will the list always contain the closest ancestor first? -->
546     <xsl:variable name="footnote-section"><xsl:value-of select="ancestor::section[position()=1]/@id" /></xsl:variable>
547     <xsl:variable name="footnote-marker"><xsl:number count="footnotes/footnote" from="/" level="any" format="1" /></xsl:variable>
548     <xsl:variable name="footnote-id"><xsl:value-of select="@id" /></xsl:variable>
549     <xsl:variable name="footnote-idref"><xsl:text>#</xsl:text><xsl:value-of select="@idref" /></xsl:variable>
550      
551     <xsl:for-each select="*[1]">
552      <p>
553       <xsl:text>[</xsl:text>
554       <a>
555        <xsl:attribute name="name"><xsl:value-of select="$footnote-id" /></xsl:attribute>
556        <xsl:attribute name="href"><xsl:value-of select="$footnote-idref" /></xsl:attribute>
557        <xsl:value-of select="$footnote-marker" />
558       </a>
559       <xsl:text>] </xsl:text>
560
561       <xsl:text> (</xsl:text>
562       <xsl:call-template name="section-title-link" />
563       <xsl:text>) </xsl:text>
564
565       <xsl:apply-templates select="child::* | child::text()" />
566      </p>
567     </xsl:for-each>
568      
569     <xsl:for-each select="*[position() != 1]">
570      <xsl:apply-templates select="." />
571     </xsl:for-each>
572      
573    </xsl:for-each>
574   </div>
575    
576   <!-- Backwards compatibility... needed? Probably not. -->
577   <xsl:apply-templates />
578    
579   <xsl:value-of select="$newline" />
580   
581  </div><xsl:value-of select="$newline" /><xsl:value-of select="$newline" />
582 </xsl:template>
583
584 <!-- ==================== block elements ======================== -->
585
586 <xsl:template match="p">
587  <p><xsl:apply-templates /></p>
588  <xsl:value-of select="$newline" />
589 </xsl:template>
590
591 <xsl:template match="p[@class='dedication']">
592  <p class="dedication"><xsl:apply-templates /></p>
593  <xsl:value-of select="$newline" />
594 </xsl:template>
595
596 <xsl:template match="dl[@class='paragraphed']/dd/node() | ol[@class='paragraphed']/li/node() | ul[@class='paragraphed']/li/node()">
597  <xsl:choose>
598   <xsl:when test="self::p">
599    <xsl:apply-templates /><br /><br /><xsl:value-of select="$newline" />
600   </xsl:when>
601   <xsl:when test="self::dl">
602    <dl><xsl:value-of select="$newline" />
603     <xsl:apply-templates />
604    </dl><br /><br /><xsl:value-of select="$newline" />
605   </xsl:when>
606   <xsl:when test="self::ol">
607    <ol><xsl:value-of select="$newline" />
608     <xsl:apply-templates />
609    </ol><br /><br /><xsl:value-of select="$newline" />
610   </xsl:when>
611   <xsl:when test="self::ul">
612    <ul>
613     <xsl:if test="self::*[@class='unbulleted']"><xsl:attribute name="class"><xsl:text>unbulleted</xsl:text></xsl:attribute></xsl:if>
614     <xsl:value-of select="$newline" />
615     <xsl:apply-templates />
616    </ul><br /><br /><xsl:value-of select="$newline" />
617   </xsl:when>
618   <xsl:when test="self::blockquote">
619    <blockquote><xsl:value-of select="$newline" />
620     <xsl:apply-templates />
621    </blockquote><xsl:value-of select="$newline" />
622   </xsl:when>
623   <xsl:when test="self::illustration"></xsl:when>
624   <xsl:when test="self::illref"></xsl:when>
625   <xsl:otherwise>
626    <xsl:text>[error: paragraphed list template]</xsl:text>
627    <xsl:message><xsl:text>error: paragraphed list template</xsl:text></xsl:message>
628   </xsl:otherwise>
629  </xsl:choose>
630 </xsl:template>
631
632 <xsl:template match="ol">
633  <ol><xsl:value-of select="$newline" />
634   <xsl:apply-templates />
635  </ol><xsl:value-of select="$newline" />
636 </xsl:template>
637
638 <xsl:template match="ul">
639  <ul>
640   <xsl:if test="self::*[@class='unbulleted']"><xsl:attribute name="class"><xsl:text>unbulleted</xsl:text></xsl:attribute></xsl:if>
641   <xsl:value-of select="$newline" />
642   <xsl:apply-templates />
643  </ul><xsl:value-of select="$newline" />
644 </xsl:template>
645
646 <xsl:template match="dl">
647  <dl><xsl:value-of select="$newline" />
648   <xsl:apply-templates />
649  </dl><xsl:value-of select="$newline" />
650 </xsl:template>
651
652 <xsl:template match="dt">
653  <dt><xsl:apply-templates /></dt>
654  <xsl:value-of select="$newline" />
655 </xsl:template>
656
657 <xsl:template match="dd">
658  <dd><xsl:apply-templates /></dd>
659  <xsl:value-of select="$newline" />
660 </xsl:template>
661
662 <xsl:template match="li">
663  <li><xsl:apply-templates /></li>
664  <xsl:value-of select="$newline" />
665 </xsl:template>
666
667 <xsl:template match="table">
668  <table border="1" cellspacing="0" cellpadding="2">
669   <xsl:apply-templates />
670  </table>
671  <xsl:value-of select="$newline" />
672 </xsl:template>
673
674 <xsl:template match="tr">
675  <tr>
676   <xsl:apply-templates />
677  </tr>
678 </xsl:template>
679
680 <xsl:template match="th">
681  <th>
682   <xsl:if test="@align"><xsl:attribute name="align"><xsl:value-of select="@align" /></xsl:attribute></xsl:if>
683   <xsl:if test="@valign"><xsl:attribute name="valign"><xsl:value-of select="@valign" /></xsl:attribute></xsl:if>
684   <xsl:if test="@char"><xsl:attribute name="char"><xsl:value-of select="@char" /></xsl:attribute></xsl:if>
685   <xsl:apply-templates />
686  </th>
687 </xsl:template>
688
689 <xsl:template match="td">
690  <td>
691   <xsl:if test="@align"><xsl:attribute name="align"><xsl:value-of select="@align" /></xsl:attribute></xsl:if>
692   <xsl:if test="@valign"><xsl:attribute name="valign"><xsl:value-of select="@valign" /></xsl:attribute></xsl:if>
693   <xsl:if test="@char"><xsl:attribute name="char"><xsl:value-of select="@char" /></xsl:attribute></xsl:if>
694   <xsl:apply-templates />
695  </td>
696 </xsl:template>
697
698 <xsl:template match="combat">
699  <p class="combat">
700   <xsl:apply-templates select="enemy" />
701   <xsl:text>: </xsl:text>
702   <xsl:choose>
703    <xsl:when test="enemy-attribute[@class='combatskill']">
704     <small>
705      <xsl:choose>
706       <xsl:when test="$language='es'">
707        <xsl:text>DESTREZA&nbsp;EN&nbsp;EL&nbsp;COMBATE</xsl:text>
708       </xsl:when>
709       <xsl:otherwise>
710        <xsl:text>COMBAT&nbsp;SKILL</xsl:text>
711       </xsl:otherwise>
712      </xsl:choose>
713     </small>
714     <xsl:text>&nbsp;</xsl:text>
715     <xsl:value-of select="enemy-attribute[@class='combatskill']" />
716    </xsl:when>
717    <xsl:when test="enemy-attribute[@class='closecombatskill']">
718     <small>
719      <xsl:choose>
720       <xsl:when test="$language='es'">
721        <xsl:text>CLOSE&nbsp;COMBAT&nbsp;SKILL</xsl:text>
722       </xsl:when>
723       <xsl:otherwise>
724        <xsl:text>CLOSE&nbsp;COMBAT&nbsp;SKILL</xsl:text>
725       </xsl:otherwise>
726      </xsl:choose>
727     </small>
728     <xsl:text>&nbsp;</xsl:text>
729     <xsl:value-of select="enemy-attribute[@class='closecombatskill']" />
730    </xsl:when>
731   </xsl:choose>
732   <xsl:text> &nbsp;&nbsp;</xsl:text>
733   <small>
734     <xsl:choose>
735      <xsl:when test="$language='es'">
736       <xsl:text>RESISTENCIA</xsl:text>
737      </xsl:when>
738      <xsl:otherwise>
739       <xsl:text>ENDURANCE</xsl:text>
740     </xsl:otherwise>
741    </xsl:choose>
742   </small>
743   <xsl:choose>
744    <xsl:when test="enemy-attribute[@class='target']">
745     <xsl:choose>
746      <xsl:when test="$language='es'">
747       <xsl:text> (o </xsl:text><small>BLANCOS</small><xsl:text>)</xsl:text>
748      </xsl:when>
749      <xsl:otherwise>
750       <xsl:text> (</xsl:text><small>TARGET</small><xsl:text> points)</xsl:text>
751      </xsl:otherwise>
752     </xsl:choose>
753     <xsl:text>&nbsp;</xsl:text>
754     <xsl:value-of select="enemy-attribute[@class='target']" />
755    </xsl:when>
756    <xsl:when test="enemy-attribute[@class='resistance']">
757     <xsl:choose>
758      <xsl:when test="$language='es'"></xsl:when>
759      <xsl:otherwise>
760       <xsl:text> (</xsl:text><small>RESISTANCE</small><xsl:text> points)</xsl:text>
761      </xsl:otherwise>
762     </xsl:choose>
763     <xsl:text>&nbsp;</xsl:text>
764     <xsl:value-of select="enemy-attribute[@class='resistance']" />
765    </xsl:when>
766    <xsl:otherwise>
767     <xsl:text>&nbsp;</xsl:text>
768     <xsl:value-of select="enemy-attribute[@class='endurance']" />
769    </xsl:otherwise>
770   </xsl:choose>
771  </p>
772  <xsl:value-of select="$newline" />
773 </xsl:template>
774
775 <xsl:template match="choice">
776  <xsl:variable name="link">
777   <xsl:value-of select="@idref" />
778  </xsl:variable>
779
780  <p class="choice">
781   <xsl:for-each select="* | text()">
782    <xsl:choose>
783     <xsl:when test="self::link-text">
784      <a href="#{$link}">
785       <xsl:apply-templates />
786      </a>
787     </xsl:when>
788     <xsl:otherwise>
789      <xsl:apply-templates select="." />
790     </xsl:otherwise>
791    </xsl:choose>
792   </xsl:for-each>
793  </p>
794  <xsl:value-of select="$newline" />
795 </xsl:template>
796
797 <xsl:template match="signpost">
798  <div class="signpost">
799   <xsl:apply-templates />
800  </div>
801  <xsl:value-of select="$newline" />
802 </xsl:template>
803
804 <xsl:template match="blockquote">
805  <blockquote><xsl:value-of select="$newline" />
806   <xsl:apply-templates /><xsl:value-of select="$newline" />
807  </blockquote><xsl:value-of select="$newline" />
808 </xsl:template>
809
810 <xsl:template match="illref">
811  <!-- 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 --> 
812  <xsl:if test="@class='html'">
813   <xsl:for-each select="id( @idref )">
814    <!-- 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... -->
815    <!-- When backwards compatibility can be dropped, most of (all?) the <illustration> processing can happen here -->
816    <xsl:apply-templates select="." />
817   </xsl:for-each>
818  </xsl:if>
819 </xsl:template>
820
821 <xsl:template match="illustrations">
822  <ul class="unbulleted">
823   <xsl:for-each select="illustration[contains( $use-illustrators, concat( ':', meta/creator, ':' ) )] | illgroup">
824    <xsl:choose>
825     <xsl:when test="self::illustration and @class='float'">
826      <!-- List item with illustration name as link -->
827      <li>
828       <a>
829        <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>
830        <xsl:choose>
831         <xsl:when test="$language='es'">
832          <xsl:text>Ilustraci&oacute;n </xsl:text>
833         </xsl:when>
834         <xsl:otherwise>
835          <xsl:text>Illustration </xsl:text>
836         </xsl:otherwise>
837        </xsl:choose>
838        <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
839       </a>
840       <!-- List the sections that the illustration appears in -->
841       <xsl:text> (</xsl:text>
842       <xsl:for-each select="//illref[@class='html' and @idref=current()/@id]">
843        <xsl:call-template name="section-title-link" />
844        <xsl:if test="position()!=last()">
845         <xsl:text>, </xsl:text>        
846        </xsl:if>
847       </xsl:for-each>
848       <xsl:text>)</xsl:text><xsl:value-of select="$newline" />
849      </li>
850      <!-- Call the backwards compatible template for generating the illustration page -->
851     </xsl:when>
852    </xsl:choose>
853   </xsl:for-each>
854  </ul><xsl:value-of select="$newline" />
855 </xsl:template>
856
857 <xsl:template match="illustration">
858  <xsl:choose>
859   <xsl:when test="instance[@class='text'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
860    <xsl:apply-templates select="instance[@class='text']/*"/>
861   </xsl:when>
862   <xsl:when test="instance[@class='html'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
863    <xsl:choose>
864     <xsl:when test="@class='float'">
865      <div class="illustration">
866       <xsl:text>[[Illustration </xsl:text>
867       <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
868       <xsl:text>]]</xsl:text>
869      </div><xsl:value-of select="$newline" />
870     </xsl:when>
871     <xsl:otherwise></xsl:otherwise>
872    </xsl:choose>
873   </xsl:when>
874   <xsl:otherwise></xsl:otherwise>
875  </xsl:choose>
876 </xsl:template>
877
878 <xsl:template match="instance" />
879
880 <xsl:template match="footnotes" />
881
882 <xsl:template match="footnote" />
883
884 <xsl:template match="hr">
885  <hr />
886  <xsl:value-of select="$newline" />
887 </xsl:template>
888
889 <!-- ==================== inline elements ======================= -->
890
891 <xsl:template match="a">
892  <xsl:choose>
893   <xsl:when test="@href">
894    <a>
895     <xsl:attribute name="href"><xsl:value-of select="@href" /></xsl:attribute>
896     <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
897     <xsl:apply-templates />
898    </a>
899   </xsl:when>
900   <xsl:otherwise>
901    <a>
902     <xsl:if test="@idref">
903      <xsl:attribute name="href">
904       <xsl:text>#</xsl:text><xsl:value-of select="@idref" />
905      </xsl:attribute>
906     </xsl:if>
907     <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
908     <xsl:apply-templates />
909    </a>
910   </xsl:otherwise>
911  </xsl:choose>
912 </xsl:template>
913
914 <!-- This template is obsolete, the "footref" element should be used instead -->
915 <xsl:template match="a[@class='footnote']">
916  <!-- <xsl:message><xsl:text>WARNING: Obsolete &lt;a idref='...' class='footnote' /&gt; usage</xsl:text></xsl:message> -->
917  <xsl:apply-templates />
918  <sup>
919   <a>
920    <xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="@idref" /></xsl:attribute>
921    <xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute>
922    <xsl:number count="a[@class='footnote']" from="/" level="any" format="1" />
923   </a>
924  </sup>
925 </xsl:template>
926
927 <!-- TODO: can this be made more uniform with illrefs? -->
928 <xsl:template match="a[@class='accent-illustration']"></xsl:template>
929
930 <xsl:template match="bookref">
931  <a>
932   <xsl:attribute name="href">
933    <xsl:variable name="my-section">
934     <xsl:choose>
935      <xsl:when test="@section">
936       <xsl:value-of select="@section" />
937      </xsl:when>
938      <xsl:otherwise>
939       <xsl:text>title</xsl:text>
940      </xsl:otherwise>
941     </xsl:choose>
942    </xsl:variable>
943    <xsl:variable name="my-series">
944     <!-- If series is specified, go one directory back and then to series. Otherwise, add nothing. -->
945     <xsl:choose>
946      <xsl:when test="@series">
947       <xsl:text>/../</xsl:text><xsl:value-of select="@series" />
948      </xsl:when>
949      <xsl:otherwise>
950       <xsl:text></xsl:text>
951      </xsl:otherwise>
952     </xsl:choose>
953    </xsl:variable>
954    <xsl:text>..</xsl:text><xsl:value-of select="$my-series" /><xsl:text>/</xsl:text><xsl:value-of select="@book" /><xsl:text>.htm#</xsl:text><xsl:value-of select="$my-section" />
955   </xsl:attribute>
956   <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
957   <xsl:apply-templates />
958  </a>
959 </xsl:template>
960
961 <xsl:template match="footref">
962  <xsl:apply-templates />
963  <sup>
964   <a>
965    <xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="@idref" /></xsl:attribute>
966    <xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute>
967    <xsl:number count="footref" from="/" level="any" format="1" />
968   </a>
969  </sup>
970 </xsl:template>
971
972 <xsl:template match="em">
973  <em><xsl:apply-templates /></em>
974 </xsl:template>
975
976 <xsl:template match="strong">
977  <strong><xsl:apply-templates /></strong>
978 </xsl:template>
979
980 <xsl:template match="thought">
981  <i><xsl:apply-templates /></i>
982 </xsl:template>
983
984 <xsl:template match="onomatopoeia">
985  <i><xsl:apply-templates /></i>
986 </xsl:template>
987
988 <xsl:template match="spell">
989  <i><xsl:apply-templates /></i>
990 </xsl:template>
991
992 <xsl:template match="item">
993  <xsl:apply-templates />
994 </xsl:template>
995
996 <xsl:template match="foreign">
997  <i><xsl:apply-templates /></i>
998 </xsl:template>
999
1000 <xsl:template match="quote">
1001  <xsl:text>&#8216;</xsl:text>
1002   <xsl:apply-templates />
1003  <xsl:if test="not(self::*[@class='open-ended'])"><xsl:text>&#8217;</xsl:text></xsl:if>
1004 </xsl:template>
1005
1006 <xsl:template match="quote//quote">
1007  <xsl:text>&#8220;</xsl:text>
1008   <xsl:apply-templates />
1009  <xsl:if test="not(self::*[@class='open-ended'])"><xsl:text>&#8221;</xsl:text></xsl:if>
1010 </xsl:template>
1011
1012 <xsl:template match="cite">
1013  <cite><xsl:apply-templates /></cite>
1014 </xsl:template>
1015
1016 <xsl:template match="code">
1017  <tt><xsl:apply-templates /></tt>
1018 </xsl:template>
1019
1020 <xsl:template match="br">
1021  <br />
1022 </xsl:template>
1023
1024 <xsl:template match="typ[@class='attribute']">
1025  <small><xsl:apply-templates /></small>
1026 </xsl:template>
1027
1028 <!-- ==================== character elements ==================== -->
1029 <!--
1030
1031 These templates define the mapping between the character elements used in
1032 the Project Aon instances of Gamebook XML and the ISO-8859-1
1033 characters.
1034
1035 Portions Copyright International Organization for Standardization 1986 
1036 Permission to copy in any form is granted for use with conforming SGML 
1037 systems and applications as defined in ISO 8879, provided this notice 
1038 is included in all copies.
1039
1040 -->
1041
1042 <xsl:template match="ch.apos"><xsl:text>&#39;</xsl:text></xsl:template><!-- apostrophe = single quotation mark -->
1043 <xsl:template match="ch.nbsp"><xsl:text>&#160;</xsl:text></xsl:template><!-- no-break space = non-breaking space, U+00A0 ISOnum -->
1044 <xsl:template match="ch.iexcl"><xsl:text>&#161;</xsl:text></xsl:template><!-- inverted exclamation mark, U+00A1 ISOnum -->
1045 <xsl:template match="ch.cent"><xsl:text>&#162;</xsl:text></xsl:template><!-- cent sign, U+00A2 ISOnum -->
1046 <xsl:template match="ch.pound"><xsl:text>&#163;</xsl:text></xsl:template><!-- pound sign, U+00A3 ISOnum -->
1047 <xsl:template match="ch.curren"><xsl:text>&#164;</xsl:text></xsl:template><!-- currency sign, U+00A4 ISOnum -->
1048 <xsl:template match="ch.yen"><xsl:text>&#165;</xsl:text></xsl:template><!-- yen sign = yuan sign, U+00A5 ISOnum -->
1049 <xsl:template match="ch.brvbar"><xsl:text>&#166;</xsl:text></xsl:template><!-- broken bar = broken vertical bar, U+00A6 ISOnum -->
1050 <xsl:template match="ch.sect"><xsl:text>&#167;</xsl:text></xsl:template><!-- section sign, U+00A7 ISOnum -->
1051 <xsl:template match="ch.uml"><xsl:text>&#168;</xsl:text></xsl:template><!-- diaeresis = spacing diaeresis, U+00A8 ISOdia -->
1052 <xsl:template match="ch.copy"><xsl:text>&#169;</xsl:text></xsl:template><!-- copyright sign, U+00A9 ISOnum -->
1053 <xsl:template match="ch.ordf"><xsl:text>&#170;</xsl:text></xsl:template><!-- feminine ordinal indicator, U+00AA ISOnum -->
1054 <xsl:template match="ch.laquo"><xsl:text>&#171;</xsl:text></xsl:template><!-- left-pointing double angle quotation mark = left pointing guillemet, U+00AB ISOnum -->
1055 <xsl:template match="ch.not"><xsl:text>&#172;</xsl:text></xsl:template><!-- not sign, U+00AC ISOnum -->
1056 <xsl:template match="ch.shy"><xsl:text>&#173;</xsl:text></xsl:template><!-- soft hyphen = discretionary hyphen, U+00AD ISOnum -->
1057 <xsl:template match="ch.reg"><xsl:text>&#174;</xsl:text></xsl:template><!-- registered sign = registered trade mark sign, U+00AE ISOnum -->
1058 <xsl:template match="ch.macr"><xsl:text>&#175;</xsl:text></xsl:template><!-- macron = spacing macron = overline = APL overbar, U+00AF ISOdia -->
1059 <xsl:template match="ch.deg"><xsl:text>&#176;</xsl:text></xsl:template><!-- degree sign, U+00B0 ISOnum -->
1060 <xsl:template match="ch.plusmn"><xsl:text>&#177;</xsl:text></xsl:template><!-- plus-minus sign = plus-or-minus sign, U+00B1 ISOnum -->
1061 <xsl:template match="ch.sup2"><xsl:text>&#178;</xsl:text></xsl:template><!-- superscript two = superscript digit two = squared, U+00B2 ISOnum -->
1062 <xsl:template match="ch.sup3"><xsl:text>&#179;</xsl:text></xsl:template><!-- superscript three = superscript digit three = cubed, U+00B3 ISOnum -->
1063 <xsl:template match="ch.acute"><xsl:text>&#180;</xsl:text></xsl:template><!-- acute accent = spacing acute, U+00B4 ISOdia -->
1064 <xsl:template match="ch.micro"><xsl:text>&#181;</xsl:text></xsl:template><!-- micro sign, U+00B5 ISOnum -->
1065 <xsl:template match="ch.para"><xsl:text>&#182;</xsl:text></xsl:template><!-- pilcrow sign  = paragraph sign, U+00B6 ISOnum -->
1066 <xsl:template match="ch.middot"><xsl:text>&#183;</xsl:text></xsl:template><!-- middle dot = Georgian comma = Greek middle dot, U+00B7 ISOnum -->
1067 <xsl:template match="ch.cedil"><xsl:text>&#184;</xsl:text></xsl:template><!-- cedilla = spacing cedilla, U+00B8 ISOdia -->
1068 <xsl:template match="ch.sup1"><xsl:text>&#185;</xsl:text></xsl:template><!-- superscript one = superscript digit one, U+00B9 ISOnum -->
1069 <xsl:template match="ch.ordm"><xsl:text>&#186;</xsl:text></xsl:template><!-- masculine ordinal indicator, U+00BA ISOnum -->
1070 <xsl:template match="ch.raquo"><xsl:text>&#187;</xsl:text></xsl:template><!-- right-pointing double angle quotation mark = right pointing guillemet, U+00BB ISOnum -->
1071 <xsl:template match="ch.frac14"><xsl:text>&#188;</xsl:text></xsl:template><!-- vulgar fraction one quarter = fraction one quarter, U+00BC ISOnum -->
1072 <xsl:template match="ch.frac12"><xsl:text>&#189;</xsl:text></xsl:template><!-- vulgar fraction one half = fraction one half, U+00BD ISOnum -->
1073 <xsl:template match="ch.frac34"><xsl:text>&#190;</xsl:text></xsl:template><!-- vulgar fraction three quarters = fraction three quarters, U+00BE ISOnum -->
1074 <xsl:template match="ch.iquest"><xsl:text>&#191;</xsl:text></xsl:template><!-- inverted question mark = turned question mark, U+00BF ISOnum -->
1075 <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 -->
1076 <xsl:template match="ch.Aacute"><xsl:text>&#193;</xsl:text></xsl:template><!-- latin capital letter A with acute, U+00C1 ISOlat1 -->
1077 <xsl:template match="ch.Acirc"><xsl:text>&#194;</xsl:text></xsl:template><!-- latin capital letter A with circumflex, U+00C2 ISOlat1 -->
1078 <xsl:template match="ch.Atilde"><xsl:text>&#195;</xsl:text></xsl:template><!-- latin capital letter A with tilde, U+00C3 ISOlat1 -->
1079 <xsl:template match="ch.Auml"><xsl:text>&#196;</xsl:text></xsl:template><!-- latin capital letter A with diaeresis, U+00C4 ISOlat1 -->
1080 <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 -->
1081 <xsl:template match="ch.AElig"><xsl:text>&#198;</xsl:text></xsl:template><!-- latin capital letter AE = latin capital ligature AE, U+00C6 ISOlat1 -->
1082 <xsl:template match="ch.Ccedil"><xsl:text>&#199;</xsl:text></xsl:template><!-- latin capital letter C with cedilla, U+00C7 ISOlat1 -->
1083 <xsl:template match="ch.Egrave"><xsl:text>&#200;</xsl:text></xsl:template><!-- latin capital letter E with grave, U+00C8 ISOlat1 -->
1084 <xsl:template match="ch.Eacute"><xsl:text>&#201;</xsl:text></xsl:template><!-- latin capital letter E with acute, U+00C9 ISOlat1 -->
1085 <xsl:template match="ch.Ecirc"><xsl:text>&#202;</xsl:text></xsl:template><!-- latin capital letter E with circumflex, U+00CA ISOlat1 -->
1086 <xsl:template match="ch.Euml"><xsl:text>&#203;</xsl:text></xsl:template><!-- latin capital letter E with diaeresis, U+00CB ISOlat1 -->
1087 <xsl:template match="ch.Igrave"><xsl:text>&#204;</xsl:text></xsl:template><!-- latin capital letter I with grave, U+00CC ISOlat1 -->
1088 <xsl:template match="ch.Iacute"><xsl:text>&#205;</xsl:text></xsl:template><!-- latin capital letter I with acute, U+00CD ISOlat1 -->
1089 <xsl:template match="ch.Icirc"><xsl:text>&#206;</xsl:text></xsl:template><!-- latin capital letter I with circumflex, U+00CE ISOlat1 -->
1090 <xsl:template match="ch.Iuml"><xsl:text>&#207;</xsl:text></xsl:template><!-- latin capital letter I with diaeresis, U+00CF ISOlat1 -->
1091 <xsl:template match="ch.ETH"><xsl:text>&#208;</xsl:text></xsl:template><!-- latin capital letter ETH, U+00D0 ISOlat1 -->
1092 <xsl:template match="ch.Ntilde"><xsl:text>&#209;</xsl:text></xsl:template><!-- latin capital letter N with tilde, U+00D1 ISOlat1 -->
1093 <xsl:template match="ch.Ograve"><xsl:text>&#210;</xsl:text></xsl:template><!-- latin capital letter O with grave, U+00D2 ISOlat1 -->
1094 <xsl:template match="ch.Oacute"><xsl:text>&#211;</xsl:text></xsl:template><!-- latin capital letter O with acute, U+00D3 ISOlat1 -->
1095 <xsl:template match="ch.Ocirc"><xsl:text>&#212;</xsl:text></xsl:template><!-- latin capital letter O with circumflex, U+00D4 ISOlat1 -->
1096 <xsl:template match="ch.Otilde"><xsl:text>&#213;</xsl:text></xsl:template><!-- latin capital letter O with tilde, U+00D5 ISOlat1 -->
1097 <xsl:template match="ch.Ouml"><xsl:text>&#214;</xsl:text></xsl:template><!-- latin capital letter O with diaeresis, U+00D6 ISOlat1 -->
1098 <xsl:template match="ch.times"><xsl:text>&#215;</xsl:text></xsl:template><!-- multiplication sign, U+00D7 ISOnum -->
1099 <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 -->
1100 <xsl:template match="ch.Ugrave"><xsl:text>&#217;</xsl:text></xsl:template><!-- latin capital letter U with grave, U+00D9 ISOlat1 -->
1101 <xsl:template match="ch.Uacute"><xsl:text>&#218;</xsl:text></xsl:template><!-- latin capital letter U with acute, U+00DA ISOlat1 -->
1102 <xsl:template match="ch.Ucirc"><xsl:text>&#219;</xsl:text></xsl:template><!-- latin capital letter U with circumflex, U+00DB ISOlat1 -->
1103 <xsl:template match="ch.Uuml"><xsl:text>&#220;</xsl:text></xsl:template><!-- latin capital letter U with diaeresis, U+00DC ISOlat1 -->
1104 <xsl:template match="ch.Yacute"><xsl:text>&#221;</xsl:text></xsl:template><!-- latin capital letter Y with acute, U+00DD ISOlat1 -->
1105 <xsl:template match="ch.THORN"><xsl:text>&#222;</xsl:text></xsl:template><!-- latin capital letter THORN, U+00DE ISOlat1 -->
1106 <xsl:template match="ch.szlig"><xsl:text>&#223;</xsl:text></xsl:template><!-- latin small letter sharp s = ess-zed, U+00DF ISOlat1 -->
1107 <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 -->
1108 <xsl:template match="ch.aacute"><xsl:text>&#225;</xsl:text></xsl:template><!-- latin small letter a with acute, U+00E1 ISOlat1 -->
1109 <xsl:template match="ch.acirc"><xsl:text>&#226;</xsl:text></xsl:template><!-- latin small letter a with circumflex, U+00E2 ISOlat1 -->
1110 <xsl:template match="ch.atilde"><xsl:text>&#227;</xsl:text></xsl:template><!-- latin small letter a with tilde, U+00E3 ISOlat1 -->
1111 <xsl:template match="ch.auml"><xsl:text>&#228;</xsl:text></xsl:template><!-- latin small letter a with diaeresis, U+00E4 ISOlat1 -->
1112 <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 -->
1113 <xsl:template match="ch.aelig"><xsl:text>&#230;</xsl:text></xsl:template><!-- latin small letter ae = latin small ligature ae, U+00E6 ISOlat1 -->
1114 <xsl:template match="ch.ccedil"><xsl:text>&#231;</xsl:text></xsl:template><!-- latin small letter c with cedilla, U+00E7 ISOlat1 -->
1115 <xsl:template match="ch.egrave"><xsl:text>&#232;</xsl:text></xsl:template><!-- latin small letter e with grave, U+00E8 ISOlat1 -->
1116 <xsl:template match="ch.eacute"><xsl:text>&#233;</xsl:text></xsl:template><!-- latin small letter e with acute, U+00E9 ISOlat1 -->
1117 <xsl:template match="ch.ecirc"><xsl:text>&#234;</xsl:text></xsl:template><!-- latin small letter e with circumflex, U+00EA ISOlat1 -->
1118 <xsl:template match="ch.euml"><xsl:text>&#235;</xsl:text></xsl:template><!-- latin small letter e with diaeresis, U+00EB ISOlat1 -->
1119 <xsl:template match="ch.igrave"><xsl:text>&#236;</xsl:text></xsl:template><!-- latin small letter i with grave, U+00EC ISOlat1 -->
1120 <xsl:template match="ch.iacute"><xsl:text>&#237;</xsl:text></xsl:template><!-- latin small letter i with acute, U+00ED ISOlat1 -->
1121 <xsl:template match="ch.icirc"><xsl:text>&#238;</xsl:text></xsl:template><!-- latin small letter i with circumflex, U+00EE ISOlat1 -->
1122 <xsl:template match="ch.iuml"><xsl:text>&#239;</xsl:text></xsl:template><!-- latin small letter i with diaeresis, U+00EF ISOlat1 -->
1123 <xsl:template match="ch.eth"><xsl:text>&#240;</xsl:text></xsl:template><!-- latin small letter eth, U+00F0 ISOlat1 -->
1124 <xsl:template match="ch.ntilde"><xsl:text>&#241;</xsl:text></xsl:template><!-- latin small letter n with tilde, U+00F1 ISOlat1 -->
1125 <xsl:template match="ch.ograve"><xsl:text>&#242;</xsl:text></xsl:template><!-- latin small letter o with grave, U+00F2 ISOlat1 -->
1126 <xsl:template match="ch.oacute"><xsl:text>&#243;</xsl:text></xsl:template><!-- latin small letter o with acute, U+00F3 ISOlat1 -->
1127 <xsl:template match="ch.ocirc"><xsl:text>&#244;</xsl:text></xsl:template><!-- latin small letter o with circumflex, U+00F4 ISOlat1 -->
1128 <xsl:template match="ch.otilde"><xsl:text>&#245;</xsl:text></xsl:template><!-- latin small letter o with tilde, U+00F5 ISOlat1 -->
1129 <xsl:template match="ch.ouml"><xsl:text>&#246;</xsl:text></xsl:template><!-- latin small letter o with diaeresis, U+00F6 ISOlat1 -->
1130 <xsl:template match="ch.divide"><xsl:text>&#247;</xsl:text></xsl:template><!-- division sign, U+00F7 ISOnum -->
1131 <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 -->
1132 <xsl:template match="ch.ugrave"><xsl:text>&#249;</xsl:text></xsl:template><!-- latin small letter u with grave, U+00F9 ISOlat1 -->
1133 <xsl:template match="ch.uacute"><xsl:text>&#250;</xsl:text></xsl:template><!-- latin small letter u with acute, U+00FA ISOlat1 -->
1134 <xsl:template match="ch.ucirc"><xsl:text>&#251;</xsl:text></xsl:template><!-- latin small letter u with circumflex, U+00FB ISOlat1 -->
1135 <xsl:template match="ch.uuml"><xsl:text>&#252;</xsl:text></xsl:template><!-- latin small letter u with diaeresis, U+00FC ISOlat1 -->
1136 <xsl:template match="ch.yacute"><xsl:text>&#253;</xsl:text></xsl:template><!-- latin small letter y with acute, U+00FD ISOlat1 -->
1137 <xsl:template match="ch.thorn"><xsl:text>&#254;</xsl:text></xsl:template><!-- latin small letter thorn, U+00FE ISOlat1 -->
1138 <xsl:template match="ch.yuml"><xsl:text>&#255;</xsl:text></xsl:template><!-- latin small letter y with diaeresis, U+00FF ISOlat1 -->
1139
1140 <!-- ~~~~~~~~~~~~~~~~~~~~~ Special Characters ~~~~~~~~~~~~~~~~~~~~ -->
1141
1142 <xsl:template match="ch.ampersand">&amp;</xsl:template><!-- ampersand -->
1143 <xsl:template match="ch.lsquot">&#8216;</xsl:template><!-- opening left quotation mark -->
1144 <xsl:template match="ch.rsquot">&#8217;</xsl:template><!-- closing right quotation mark -->
1145 <xsl:template match="ch.ldquot">&#8220;</xsl:template><!-- opening left double quotation mark -->
1146 <xsl:template match="ch.rdquot">&#8221;</xsl:template><!-- closing right double quotation mark -->
1147 <xsl:template match="ch.minus">&#8722;</xsl:template><!-- mathematical minus -->
1148 <xsl:template match="ch.endash">&#8211;</xsl:template><!-- endash -->
1149 <xsl:template match="ch.emdash">&#8212;</xsl:template><!-- emdash -->
1150 <xsl:template match="ch.ellips">&nbsp;&#8230;</xsl:template><!-- ellipsis -->
1151 <xsl:template match="ch.lellips">&#8230;&nbsp;</xsl:template><!-- left ellipsis, used at the beginning of edited material -->
1152 <xsl:template match="ch.blankline">_______</xsl:template><!-- blank line to be filled in -->
1153 <xsl:template match="ch.percent"><xsl:text>&#37;</xsl:text></xsl:template><!-- percent sign -->
1154 <xsl:template match="ch.thinspace"><xsl:text>&#8201;</xsl:text></xsl:template><!-- small horizontal space for use between adjacent quotation marks - added mainly for LaTeX's sake -->
1155 <xsl:template match="ch.frac116"><xsl:text>1/16</xsl:text></xsl:template><!-- vulgar fraction one sixteenth = fraction on sixteenth -->
1156 <xsl:template match="ch.plus"><xsl:text>+</xsl:text></xsl:template><!-- mathematical plus -->
1157
1158 <!-- ==================== named templates ======================= -->
1159
1160 <!--
1161  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.
1162 -->
1163 <xsl:template name="section-title-link">
1164  <!-- will the list always contain the closest ancestor first? -->
1165  <xsl:variable name="section-title">
1166   <!-- numbered or not? -->
1167   <xsl:if test="ancestor::section[position()=1]/@class='numbered'">
1168    <xsl:choose>
1169     <xsl:when test="$language='es'">
1170      <xsl:text>Secci&oacute;n </xsl:text>
1171     </xsl:when>
1172     <xsl:otherwise>
1173      <xsl:text>Section </xsl:text>
1174     </xsl:otherwise>
1175    </xsl:choose>
1176   </xsl:if>
1177   <xsl:apply-templates select="ancestor::section[position()=1]/meta/title[1]" />
1178  </xsl:variable>
1179  
1180  <a>
1181   <xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="ancestor::section[position()=1]/@id" /></xsl:attribute>
1182   <xsl:value-of select="$section-title" />
1183  </a>
1184 </xsl:template>
1185
1186 </xsl:transform>