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