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