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