Reorganize XMLize script
[project-aon.git] / common / xsl / epub-xhtml.xsl
1 <?xml version="1.0"?>
2 <!DOCTYPE xsl:transform [
3  <!ENTITY % xhtml.characters SYSTEM "../../en/xml/htmlchar.mod">
4  %xhtml.characters;
5 ]>
6
7 <!--
8
9 Todo:
10
11 * Add blank whitespace handling to the paragraphed list template
12
13 -->
14
15 <xsl:transform version="1.0"
16   xmlns="http://www.w3.org/1999/xhtml"
17   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
18   xmlns:redirect="org.apache.xalan.lib.Redirect"
19   extension-element-prefixes="redirect">
20
21  <xsl:output method="xml"
22              encoding="UTF-8"
23              omit-xml-declaration="yes"
24              doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
25              doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
26
27  <xsl:strip-space elements="section data ol ul dl li dd footnotes footnote" />
28  <xsl:preserve-space elements="p choice puzzle deadend" />
29
30  <!-- ====================== parameters ========================== -->
31
32  <xsl:param name="use-illustrators" />
33  <xsl:param name="language"><xsl:text>en</xsl:text></xsl:param>
34  <xsl:param name="xhtml-ext"><xsl:text>.html</xsl:text></xsl:param>
35
36  <!-- ======================== Templates ========================= -->
37
38  <!-- ================= hierarchical sections ==================== -->
39
40  <xsl:template match="meta" />
41  <xsl:template match="section" />
42
43  <!-- ::::::::::::::::::: top-level section :::::::::::::::::::::: -->
44
45  <xsl:template match="/gamebook/section[@id='title']">
46   <xsl:call-template name="xhtml-wrapper">
47    <xsl:with-param name="document-type">top-level</xsl:with-param>
48    <xsl:with-param name="filename">title</xsl:with-param>
49   </xsl:call-template>
50
51   <xsl:apply-templates />
52  </xsl:template>
53
54  <xsl:template match="/gamebook/section[@id='toc']">
55   <xsl:call-template name="xhtml-wrapper">
56    <xsl:with-param name="document-type">toc</xsl:with-param>
57    <xsl:with-param name="filename">toc</xsl:with-param>
58   </xsl:call-template>
59
60   <xsl:apply-templates />
61  </xsl:template>
62
63  <!-- ::::::::::: second-level frontmatter sections :::::::::::::: -->
64
65  <xsl:template match="/gamebook/section/data/section[@class='frontmatter']">
66   <xsl:call-template name="xhtml-wrapper">
67    <xsl:with-param name="document-type">second-level-frontmatter</xsl:with-param>
68    <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
69   </xsl:call-template>
70  </xsl:template>
71
72  <!-- :::::::::::: third-level front matter sections ::::::::::::: -->
73
74  <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter']">
75   <h3><xsl:apply-templates select="meta/title[1]" /></h3>
76
77   <xsl:apply-templates />
78  </xsl:template>
79
80  <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter-separate']">
81   <xsl:call-template name="xhtml-wrapper">
82    <xsl:with-param name="document-type">third-level-frontmatter-separate</xsl:with-param>
83    <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
84   </xsl:call-template>
85  </xsl:template>
86
87  <!-- :::::::::::: fourth-level front matter sections :::::::::::: -->
88
89  <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='frontmatter']">
90   <h4><xsl:apply-templates select="meta/title[1]" /></h4>
91
92   <xsl:apply-templates />
93  </xsl:template>
94
95  <!-- ::::::::::::: fifth-level front matter sections :::::::::::: -->
96
97  <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='frontmatter']">
98   <h5><xsl:apply-templates select="meta/title[1]" /></h5>
99
100   <xsl:apply-templates />
101  </xsl:template>
102
103  <!-- ::::::::::: second-level main matter sections :::::::::::::: -->
104
105  <xsl:template match="/gamebook/section/data/section[@class='mainmatter']">
106   <xsl:call-template name="xhtml-wrapper">
107    <xsl:with-param name="document-type">second-level-mainmatter</xsl:with-param>
108    <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
109   </xsl:call-template>
110  </xsl:template>
111
112  <!-- :::::::::::: third-level main matter sections ::::::::::::: -->
113
114  <xsl:template match="/gamebook/section/data/section/data/section[@class='mainmatter']">
115   <h3><xsl:apply-templates select="meta/title[1]" /></h3>
116
117   <xsl:apply-templates />
118  </xsl:template>
119
120  <xsl:template match="/gamebook/section/data/section/data/section[@class='mainmatter-separate']">
121   <xsl:call-template name="xhtml-wrapper">
122    <xsl:with-param name="document-type">third-level-mainmatter-separate</xsl:with-param>
123    <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
124   </xsl:call-template>
125  </xsl:template>
126
127  <!-- :::::::::::: fourth-level main matter sections :::::::::::: -->
128
129  <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='mainmatter']">
130   <h4><xsl:apply-templates select="meta/title[1]" /></h4>
131
132   <xsl:apply-templates />
133  </xsl:template>
134
135  <!-- ::::::::::::: fifth-level main matter sections :::::::::::: -->
136
137  <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='mainmatter']">
138   <h5><xsl:apply-templates select="meta/title[1]" /></h5>
139
140   <xsl:apply-templates />
141  </xsl:template>
142
143  <!-- :::::::::::: second-level glossary sections ::::::::::::: -->
144
145  <xsl:template match="/gamebook/section/data/section[@class='glossary']">
146   <xsl:call-template name="xhtml-wrapper">
147    <xsl:with-param name="document-type">second-level-glossary</xsl:with-param>
148    <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
149    <xsl:with-param name="glossary-id-prefix">topics</xsl:with-param>
150   </xsl:call-template>
151  </xsl:template>
152
153  <!-- :::::::::::: third-level glossary sections ::::::::::::: -->
154  <!-- glossary sections should be enclosed in a second level glossary section -->
155
156  <xsl:template match="/gamebook/section/data/section/data/section[@class='glossary']">
157   <h3><xsl:apply-templates select="meta/title[1]" /></h3>
158
159   <xsl:apply-templates />
160  </xsl:template>
161
162  <xsl:template match="/gamebook/section/data/section/data/section[@class='glossary-separate']">
163   <xsl:call-template name="xhtml-wrapper">
164    <xsl:with-param name="document-type">third-level-glossary-separate</xsl:with-param>
165    <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
166    <xsl:with-param name="glossary-id-prefix">topics</xsl:with-param>
167   </xsl:call-template>
168  </xsl:template>
169
170  <!-- :::::::::::::::::: numbered sections ::::::::::::::::::::::: -->
171
172  <xsl:template match="/gamebook/section/data/section[@class='numbered']">
173   <xsl:call-template name="xhtml-wrapper">
174    <xsl:with-param name="document-type">second-level-numbered</xsl:with-param>
175    <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
176   </xsl:call-template>
177
178   <xsl:apply-templates />
179  </xsl:template>
180
181  <xsl:template match="/gamebook/section/data/section/data/section[@class='numbered']">
182   <xsl:call-template name="xhtml-wrapper">
183    <xsl:with-param name="document-type">third-level-numbered</xsl:with-param>
184    <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
185   </xsl:call-template>
186  </xsl:template>
187
188  <!-- :::::::::::: second-level backmatter sections :::::::::::::: -->
189
190  <xsl:template match="/gamebook/section/data/section[@class='backmatter']">
191   <xsl:call-template name="xhtml-wrapper">
192    <xsl:with-param name="document-type">second-level-backmatter</xsl:with-param>
193    <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
194   </xsl:call-template>
195  </xsl:template>
196
197  <!-- ::::::::::::: third-level back matter sections ::::::::::::: -->
198
199  <xsl:template match="/gamebook/section/data/section/data/section[@class='backmatter']">
200   <h3><xsl:apply-templates select="meta/title[1]" /></h3>
201
202   <xsl:apply-templates />
203  </xsl:template>
204
205  <!-- ::::::::::::: fourth-level back matter sections ::::::::::::: -->
206
207  <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='backmatter']">
208   <h4><xsl:apply-templates select="meta/title[1]" /></h4>
209
210   <xsl:apply-templates />
211  </xsl:template>
212
213  <!-- ::::::::::::::::::::: map template ::::::::::::::::::::::::: -->
214
215  <xsl:template match="id( 'map' )">
216   <xsl:call-template name="xhtml-wrapper">
217    <xsl:with-param name="document-type">map</xsl:with-param>
218    <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
219   </xsl:call-template>
220  </xsl:template>
221
222  <!-- ::::::::::::::::::::: footnotes template ::::::::::::::::::::::::: -->
223
224  <xsl:template match="id( 'footnotz' )">
225   <xsl:choose>
226    <!-- Backwards compatibility measure - if there is data content, use that, otherwise generate footnotes list -->
227    <xsl:when test="count( data/p ) = 0">
228     <xsl:call-template name="xhtml-wrapper">
229      <xsl:with-param name="document-type">footnotz</xsl:with-param>
230      <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
231     </xsl:call-template>
232    </xsl:when>
233    <xsl:otherwise>
234     <xsl:call-template name="xhtml-wrapper">
235      <xsl:with-param name="document-type">second-level-backmatter</xsl:with-param>
236      <xsl:with-param name="filename"><xsl:value-of select="@id" /></xsl:with-param>
237     </xsl:call-template>
238    </xsl:otherwise>
239   </xsl:choose>
240   <xsl:apply-templates />
241  </xsl:template>
242
243  <!-- ==================== block elements ======================== -->
244
245  <xsl:template match="p">
246   <p><xsl:apply-templates /></p>
247
248  </xsl:template>
249
250  <xsl:template match="p[@class='dedication']">
251   <p class="dedication"><xsl:apply-templates /></p>
252
253  </xsl:template>
254
255  <xsl:template match="dl[@class='paragraphed']/dd/node() | ol[@class='paragraphed']/li/node() | ul[@class='paragraphed']/li/node()">
256   <xsl:choose>
257    <xsl:when test="self::p">
258     <xsl:apply-templates /><br /><br />
259    </xsl:when>
260    <xsl:when test="self::dl">
261     <dl>
262      <xsl:apply-templates />
263     </dl><br /><br />
264    </xsl:when>
265    <xsl:when test="self::ol">
266     <ol>
267      <xsl:apply-templates />
268     </ol><br /><br />
269    </xsl:when>
270    <xsl:when test="self::ul">
271     <ul>
272      <xsl:if test="self::*[@class='unbulleted']"><xsl:attribute name="class"><xsl:text>unbulleted</xsl:text></xsl:attribute></xsl:if>
273
274      <xsl:apply-templates />
275     </ul><br /><br />
276    </xsl:when>
277    <xsl:when test="self::blockquote">
278     <blockquote>
279      <xsl:apply-templates />
280     </blockquote>
281    </xsl:when>
282    <xsl:when test="self::poetry">
283     <blockquote class="poetry"><p>
284      <xsl:apply-templates />
285     </p></blockquote>
286    </xsl:when>
287    <xsl:when test="self::illustration">
288     <!-- Backwards compatibility code -->
289     <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
290     <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
291     <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
292
293     <xsl:if test="instance[@class='html'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
294      <div class="illustration">
295
296       <xsl:call-template name="illustration-noframe">
297        <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width" /></xsl:with-param>
298        <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height" /></xsl:with-param>
299        <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
300       </xsl:call-template>
301      </div>
302     </xsl:if>
303    </xsl:when>
304    <xsl:when test="self::illref">
305     <xsl:if test="@class='html'">
306      <xsl:for-each select="id( @idref )">
307       <xsl:apply-templates select="." />
308      </xsl:for-each>
309     </xsl:if>
310    </xsl:when>
311    <xsl:otherwise>
312     <xsl:text>[error: paragraphed list template]</xsl:text>
313     <xsl:message><xsl:text>error: paragraphed list template</xsl:text></xsl:message>
314    </xsl:otherwise>
315   </xsl:choose>
316  </xsl:template>
317
318  <xsl:template match="ol">
319   <ol>
320    <xsl:if test="@start">
321     <xsl:call-template name="ol-start-for-loop">
322      <xsl:with-param name="count" select="@start"/>
323     </xsl:call-template>
324    </xsl:if>
325
326    <xsl:apply-templates />
327   </ol>
328  </xsl:template>
329
330  <xsl:template name="ol-start-for-loop">
331   <xsl:param name="i" select="0"/>
332   <xsl:param name="count"/>
333
334   <xsl:if test="number($i) &lt; number($count)">
335    <li style="visibility:hidden;height:0">&nbsp;</li>
336    <xsl:call-template name="ol-start-for-loop">
337     <xsl:with-param name="i" select="number($i) + 1"/>
338     <xsl:with-param name="count" select="$count"/>
339    </xsl:call-template>
340   </xsl:if>
341  </xsl:template>
342
343  <xsl:template match="ul">
344   <ul>
345    <xsl:if test="self::*[@class='unbulleted']"><xsl:attribute name="class"><xsl:text>unbulleted</xsl:text></xsl:attribute></xsl:if>
346
347    <xsl:apply-templates />
348   </ul>
349  </xsl:template>
350
351  <xsl:template match="dl">
352   <dl>
353    <xsl:apply-templates />
354   </dl>
355  </xsl:template>
356
357  <xsl:template match="dt">
358   <dt><xsl:apply-templates /></dt>
359
360  </xsl:template>
361
362  <xsl:template match="dd">
363   <dd><xsl:apply-templates /></dd>
364
365  </xsl:template>
366
367  <xsl:template match="li">
368   <li>
369    <xsl:if test="@value"><xsl:attribute name="value"><xsl:value-of select="@value" /></xsl:attribute></xsl:if>
370    <xsl:apply-templates />
371   </li>
372
373  </xsl:template>
374
375  <xsl:template match="table">
376   <table align="center" border="1" cellspacing="0" cellpadding="2">
377    <xsl:if test="@summary"><xsl:attribute name="summary"><xsl:value-of select="@summary" /></xsl:attribute></xsl:if>
378    <xsl:apply-templates />
379   </table>
380
381  </xsl:template>
382
383  <xsl:template match="caption">
384   <caption>
385    <xsl:apply-templates />
386   </caption>
387  </xsl:template>
388
389  <xsl:template match="colgroup[@scope]">
390   <colgroup>
391    <xsl:attribute name="scope"><xsl:value-of select="@scope" /></xsl:attribute>
392   </colgroup>
393  </xsl:template>
394
395  <xsl:template match="thead">
396   <thead>
397    <xsl:apply-templates />
398   </thead>
399  </xsl:template>
400
401  <xsl:template match="tfoot">
402   <tfoot>
403    <xsl:apply-templates />
404   </tfoot>
405  </xsl:template>
406
407  <xsl:template match="tbody">
408   <tbody>
409    <xsl:apply-templates />
410   </tbody>
411  </xsl:template>
412
413  <xsl:template match="tr">
414   <tr>
415    <xsl:apply-templates />
416   </tr>
417  </xsl:template>
418
419  <xsl:template match="th">
420   <th>
421    <xsl:if test="@align"><xsl:attribute name="align"><xsl:value-of select="@align" /></xsl:attribute></xsl:if>
422    <xsl:if test="@valign"><xsl:attribute name="valign"><xsl:value-of select="@valign" /></xsl:attribute></xsl:if>
423    <xsl:if test="@char"><xsl:attribute name="char"><xsl:value-of select="@char" /></xsl:attribute></xsl:if>
424    <xsl:if test="@rowspan"><xsl:attribute name="rowspan"><xsl:value-of select="@rowspan" /></xsl:attribute></xsl:if>
425    <xsl:if test="@colspan"><xsl:attribute name="colspan"><xsl:value-of select="@colspan" /></xsl:attribute></xsl:if>
426    <xsl:if test="@axis"><xsl:attribute name="axis"><xsl:value-of select="@axis" /></xsl:attribute></xsl:if>
427    <xsl:if test="@scope"><xsl:attribute name="scope"><xsl:value-of select="@scope" /></xsl:attribute></xsl:if>
428    <xsl:apply-templates />
429   </th>
430  </xsl:template>
431
432  <xsl:template match="td">
433   <td>
434    <xsl:if test="@align"><xsl:attribute name="align"><xsl:value-of select="@align" /></xsl:attribute></xsl:if>
435    <xsl:if test="@valign"><xsl:attribute name="valign"><xsl:value-of select="@valign" /></xsl:attribute></xsl:if>
436    <xsl:if test="@char"><xsl:attribute name="char"><xsl:value-of select="@char" /></xsl:attribute></xsl:if>
437    <xsl:if test="@rowspan"><xsl:attribute name="rowspan"><xsl:value-of select="@rowspan" /></xsl:attribute></xsl:if>
438    <xsl:if test="@colspan"><xsl:attribute name="colspan"><xsl:value-of select="@colspan" /></xsl:attribute></xsl:if>
439    <xsl:if test="@axis"><xsl:attribute name="axis"><xsl:value-of select="@axis" /></xsl:attribute></xsl:if>
440    <xsl:if test="@scope"><xsl:attribute name="scope"><xsl:value-of select="@scope" /></xsl:attribute></xsl:if>
441    <xsl:apply-templates />
442   </td>
443  </xsl:template>
444
445  <xsl:template match="combat">
446   <p class="combat">
447    <xsl:apply-templates select="enemy" />
448    <xsl:text>: </xsl:text>
449    <xsl:choose>
450     <xsl:when test="enemy-attribute[@class='combatskill']">
451      <span class="smallcaps">
452       <xsl:choose>
453        <xsl:when test="$language='es'">
454         <xsl:text>DESTREZA&nbsp;EN&nbsp;EL&nbsp;COMBATE</xsl:text>
455        </xsl:when>
456        <xsl:otherwise>
457         <xsl:text>COMBAT&nbsp;SKILL</xsl:text>
458        </xsl:otherwise>
459       </xsl:choose>
460      </span>
461      <xsl:text>&nbsp;</xsl:text>
462      <xsl:value-of select="enemy-attribute[@class='combatskill']" />
463     </xsl:when>
464     <xsl:when test="enemy-attribute[@class='closecombatskill']">
465      <span class="smallcaps">
466       <xsl:choose>
467        <xsl:when test="$language='es'">
468         <xsl:text>CLOSE&nbsp;COMBAT&nbsp;SKILL</xsl:text>
469        </xsl:when>
470        <xsl:otherwise>
471         <xsl:text>CLOSE&nbsp;COMBAT&nbsp;SKILL</xsl:text>
472        </xsl:otherwise>
473       </xsl:choose>
474      </span>
475      <xsl:text>&nbsp;</xsl:text>
476      <xsl:value-of select="enemy-attribute[@class='closecombatskill']" />
477     </xsl:when>
478    </xsl:choose>
479    <xsl:text> &nbsp;&nbsp;</xsl:text>
480    <span class="smallcaps">
481      <xsl:choose>
482       <xsl:when test="$language='es'">
483        <xsl:text>RESISTENCIA</xsl:text>
484       </xsl:when>
485       <xsl:otherwise>
486        <xsl:text>ENDURANCE</xsl:text>
487      </xsl:otherwise>
488     </xsl:choose>
489    </span>
490    <xsl:choose>
491     <xsl:when test="enemy-attribute[@class='target']">
492      <xsl:choose>
493       <xsl:when test="$language='es'">
494        <xsl:text> (o </xsl:text><span class="smallcaps">BLANCOS</span><xsl:text>)</xsl:text>
495       </xsl:when>
496       <xsl:otherwise>
497        <xsl:text> (</xsl:text><span class="smallcaps">TARGET</span><xsl:text> points)</xsl:text>
498       </xsl:otherwise>
499      </xsl:choose>
500      <xsl:text>&nbsp;</xsl:text>
501      <xsl:value-of select="enemy-attribute[@class='target']" />
502     </xsl:when>
503     <xsl:when test="enemy-attribute[@class='resistance']">
504      <xsl:choose>
505       <xsl:when test="$language='es'"></xsl:when>
506       <xsl:otherwise>
507        <xsl:text> (</xsl:text><span class="smallcaps">RESISTANCE</span><xsl:text> points)</xsl:text>
508       </xsl:otherwise>
509      </xsl:choose>
510      <xsl:text>&nbsp;</xsl:text>
511      <xsl:value-of select="enemy-attribute[@class='resistance']" />
512     </xsl:when>
513     <xsl:otherwise>
514      <xsl:text>&nbsp;</xsl:text>
515      <xsl:value-of select="enemy-attribute[@class='endurance']" />
516     </xsl:otherwise>
517    </xsl:choose>
518   </p>
519
520  </xsl:template>
521
522  <xsl:template match="choice">
523   <xsl:variable name="link">
524    <xsl:value-of select="@idref" />
525   </xsl:variable>
526
527   <p class="choice">
528    <xsl:for-each select="* | text()">
529     <xsl:choose>
530      <xsl:when test="self::link-text">
531       <a href="{$link}{$xhtml-ext}">
532        <xsl:apply-templates />
533       </a>
534      </xsl:when>
535      <xsl:otherwise>
536       <xsl:apply-templates select="." />
537      </xsl:otherwise>
538     </xsl:choose>
539    </xsl:for-each>
540   </p>
541
542  </xsl:template>
543
544  <xsl:template match="puzzle">
545   <p class="puzzle">
546    <xsl:apply-templates />
547   </p>
548  </xsl:template>
549  
550  <xsl:template match="deadend">
551   <p class="deadend">
552    <xsl:apply-templates />
553   </p>
554  </xsl:template>
555
556  <xsl:template match="data/signpost">
557   <div class="signpost">
558    <xsl:apply-templates />
559   </div>
560  </xsl:template>
561
562  <xsl:template match="signpost">
563   <span class="signpost"><xsl:apply-templates /></span>
564  </xsl:template>
565
566  <xsl:template match="blockquote">
567   <blockquote>
568    <xsl:apply-templates />
569   </blockquote>
570  </xsl:template>
571
572  <xsl:template match="poetry">
573   <blockquote class="poetry">
574    <xsl:apply-templates />
575   </blockquote>
576  </xsl:template>
577
578  <xsl:template match="illref">
579   <!-- It is important that the class is not checked right in the template - that would make this template match with higher priority, which will turn a few things upside down --> 
580   <xsl:if test="@class='html'">
581    <xsl:for-each select="id( @idref )">
582     <!-- When backwards compatibility can be dropped, most of (all?) the <illustration> processing can happen here -->
583     <xsl:apply-templates select="." />
584    </xsl:for-each>
585   </xsl:if>
586  </xsl:template>
587
588  <xsl:template match="illustrations">
589   <ul class="unbulleted">
590    <xsl:for-each select="illustration[contains( $use-illustrators, concat( ':', meta/creator, ':' ) )] | illgroup">
591     <xsl:choose>
592      <xsl:when test="self::illustration and @class='float'">
593       <!-- List item with illustration name -->
594       <li>
595        <xsl:choose>
596         <xsl:when test="$language='es'">
597          <xsl:text>Ilustraci&oacute;n </xsl:text>
598         </xsl:when>
599         <xsl:otherwise>
600          <xsl:text>Illustration </xsl:text>
601         </xsl:otherwise>
602        </xsl:choose>
603        <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
604        <!-- List the sections that the illustration appears in -->
605        <xsl:text> (</xsl:text>
606        <xsl:for-each select="//illref[@class='html' and @idref=current()/@id]">
607         <xsl:call-template name="section-title-link" />
608         <xsl:if test="position()!=last()">
609          <xsl:text>, </xsl:text>        
610         </xsl:if>
611        </xsl:for-each>
612        <xsl:text>)</xsl:text>
613       </li>
614      </xsl:when>
615
616      <xsl:when test="self::illustration"> <!-- inline and map -->
617       <!-- List the sections that the illustration appears in -->     
618       <li>
619        <!-- TODO: fix this so that sections that do not represent separate XHTML files are not linked to? -->
620        <xsl:for-each select="//illref[@class='html' and @idref=current()/@id]">
621         <xsl:call-template name="section-title-link" />
622         <xsl:if test="position()!=last()">
623          <xsl:text>, </xsl:text>     
624         </xsl:if>
625        </xsl:for-each>
626       </li>
627      </xsl:when>
628
629      <xsl:when test="self::illgroup and @class!='hidden'">
630       <!-- Check if the group contains any illustrations being used, before creating the list item -->
631        <xsl:if test="count( illustration[contains( $use-illustrators, concat( ':', meta/creator, ':' ) )] ) != 0">
632         <li>
633          <a>
634           <xsl:attribute name="href"><xsl:value-of select="@idref" /><xsl:value-of select="$xhtml-ext"/></xsl:attribute>
635           <xsl:value-of select="id(@idref)/meta/title[1]" />
636          </a>
637         </li>
638        </xsl:if>
639      </xsl:when>
640     </xsl:choose>
641    </xsl:for-each>
642   </ul>
643  </xsl:template>
644
645  <xsl:template match="illustration">
646   <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
647   <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
648   <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
649
650   <xsl:if test="instance[@class='html'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
651    <xsl:choose>
652     <xsl:when test="@class='float'">
653      <div class="illustration">
654       <xsl:call-template name="illustration-noframe">
655        <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width" /></xsl:with-param>
656        <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height" /></xsl:with-param>
657        <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
658        <xsl:with-param name="illustration-href">
659         <xsl:text>ill</xsl:text><xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="1" /><xsl:value-of select="$xhtml-ext"/>
660        </xsl:with-param>
661       </xsl:call-template>
662      </div>
663     </xsl:when>
664
665     <xsl:when test="@class='accent'" />
666
667     <xsl:otherwise>
668      <div class="illustration">
669       <xsl:call-template name="illustration-noframe">
670        <xsl:with-param name="illustration-width"><xsl:value-of select="$illustration-width" /></xsl:with-param>
671        <xsl:with-param name="illustration-height"><xsl:value-of select="$illustration-height" /></xsl:with-param>
672        <xsl:with-param name="illustration-src"><xsl:value-of select="$illustration-src" /></xsl:with-param>
673       </xsl:call-template>
674      </div>
675     </xsl:otherwise>
676    </xsl:choose>
677   </xsl:if>
678  </xsl:template>
679
680  <xsl:template match="instance" />
681
682  <xsl:template match="footnotes" />
683
684  <xsl:template match="footnote" />
685
686  <xsl:template match="hr">
687   <hr />
688
689  </xsl:template>
690
691  <xsl:template match="choose">
692   <xsl:choose>
693    <xsl:when test="@test='has-numbered-section-list'">
694     <xsl:choose>
695      <xsl:when test="when[@value='true']">
696       <xsl:apply-templates select="when[@value='true'][1]/node()" />
697      </xsl:when>
698      <xsl:when test="otherwise">
699       <!-- this should only be applied when there is no option for "true" -->
700       <xsl:apply-templates select="otherwise/node()" />
701      </xsl:when>
702     </xsl:choose>
703    </xsl:when>
704    <xsl:otherwise>
705     <xsl:message>
706      <xsl:text>choose: unrecognized test "</xsl:text>
707      <xsl:value-of select="@test" />
708      <xsl:text>" - element ignored.</xsl:text>
709     </xsl:message>
710    </xsl:otherwise>
711   </xsl:choose>
712  </xsl:template>
713
714  <!-- ==================== inline elements ======================= -->
715
716  <xsl:template match="a">
717   <xsl:choose>
718    <xsl:when test="@href">
719     <a>
720      <xsl:attribute name="href"><xsl:value-of select="@href" /></xsl:attribute>
721      <xsl:apply-templates />
722     </a>
723    </xsl:when>
724    <xsl:otherwise>
725     <a>
726      <xsl:if test="@idref">
727       <xsl:variable name="my-idref" select="@idref" />
728       <xsl:attribute name="href">
729        <xsl:choose>
730         <!-- The order of these tests is deliberate. They are ordered roughly from most to least specific. -->
731         <xsl:when test="/gamebook/section[@id=$my-idref] | /gamebook/section/data/section[@id=$my-idref]">
732          <xsl:value-of select="$my-idref" /><xsl:value-of select="$xhtml-ext"/>
733         </xsl:when>
734         <xsl:when test="/gamebook/section/data/section/data/section[@class='frontmatter-separate' and @id=$my-idref]">
735          <xsl:value-of select="$my-idref" /><xsl:value-of select="$xhtml-ext"/>
736         </xsl:when>
737         <xsl:when test="/gamebook/section/data/section/data/section[@class='mainmatter-separate' and @id=$my-idref]">
738          <xsl:value-of select="$my-idref" /><xsl:value-of select="$xhtml-ext"/>
739         </xsl:when>
740         <xsl:when test="/gamebook/section/data/section/data/section[@class='numbered' and @id=$my-idref]">
741          <xsl:value-of select="$my-idref" /><xsl:value-of select="$xhtml-ext"/>
742         </xsl:when>
743         <xsl:when test="/gamebook/section/data/section/data/section[@class='glossary-separate' and @id=$my-idref]">
744          <xsl:value-of select="$my-idref" /><xsl:value-of select="$xhtml-ext"/>
745         </xsl:when>
746         <xsl:when test="/gamebook/section/data/section/data/section[@class='frontmatter-separate' and descendant::*[@id=$my-idref]]">
747          <xsl:value-of select="/gamebook/section/data/section/data/section[@class='frontmatter-separate' and descendant::*[@id=$my-idref]]/@id" /><xsl:value-of select="$xhtml-ext"/>
748         </xsl:when>
749         <xsl:when test="/gamebook/section/data/section/data/section[@class='mainmatter-separate' and descendant::*[@id=$my-idref]]">
750          <xsl:value-of select="/gamebook/section/data/section/data/section[@class='mainmatter-separate' and descendant::*[@id=$my-idref]]/@id" /><xsl:value-of select="$xhtml-ext"/>
751         </xsl:when>
752         <xsl:when test="/gamebook/section/data/section/data/section[@class='glossary-separate' and descendant::*[@id=$my-idref]]">
753          <xsl:value-of select="/gamebook/section/data/section/data/section[@class='glossary-separate' and descendant::*[@id=$my-idref]]/@id" /><xsl:value-of select="$xhtml-ext"/>
754         </xsl:when>
755         <xsl:when test="/gamebook/section/data/section[descendant::*[@id=$my-idref]]">
756          <xsl:value-of select="/gamebook/section/data/section[descendant::*[@id=$my-idref]]/@id" /><xsl:value-of select="$xhtml-ext"/>
757         </xsl:when>
758         <xsl:otherwise>
759          <xsl:text>[error: a template]</xsl:text>
760          <xsl:message><xsl:text>error: a template</xsl:text></xsl:message>
761         </xsl:otherwise>
762        </xsl:choose>
763       </xsl:attribute>
764      </xsl:if>
765      <xsl:apply-templates />
766     </a>
767    </xsl:otherwise>
768   </xsl:choose>
769  </xsl:template>
770
771  <!-- This template is obsolete, the "footref" element should be used instead -->
772  <xsl:template match="a[@class='footnote']">
773   <!-- <xsl:message><xsl:text>WARNING: Obsolete &lt;a idref='...' class='footnote' /&gt; usage</xsl:text></xsl:message> -->
774   <xsl:apply-templates />
775   <sup>
776    <xsl:number count="a[@class='footnote']" from="/" level="any" format="1" />
777   </sup>
778  </xsl:template>
779
780  <!-- TODO: can this be made more uniform with illrefs? -->
781  <xsl:template match="a[@class='accent-illustration']">
782   <xsl:for-each select="id( @idref )">
783    <xsl:variable name="illustration-src" select="instance[@class='html']/@src" />
784    <xsl:variable name="illustration-width" select="instance[@class='html']/@width" />
785    <xsl:variable name="illustration-height" select="instance[@class='html']/@height" />
786    <xsl:if test="instance[@class='html'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
787     <img src="{$illustration-src}" class="accent" width="{$illustration-width}" height="{$illustration-height}" alt="" />
788    </xsl:if>
789   </xsl:for-each>
790  </xsl:template>
791
792  <!-- TODO: references to external books will not work in Ebooks -->
793  <!--       should they be skipped or modified to point to the online book? -->
794  <xsl:template match="bookref">
795  <!-- <a> -->
796  <!--  <xsl:attribute name="href"> -->
797  <!--   <xsl:variable name="my-section"> -->
798  <!--    <xsl:choose> -->
799  <!--     <xsl:when test="@section"> -->
800  <!--      <xsl:value-of select="@section" /> -->
801  <!--     </xsl:when> -->
802  <!--     <xsl:otherwise> -->
803  <!--      <xsl:text>title</xsl:text> -->
804  <!--     </xsl:otherwise> -->
805  <!--    </xsl:choose> -->
806  <!--   </xsl:variable> -->
807  <!--   <xsl:variable name="my-series"> -->
808      <!-- If series is specified, go one directory back and then to series. Otherwise, add nothing. -->
809  <!--    <xsl:choose> -->
810  <!--     <xsl:when test="@series"> -->
811  <!--      <xsl:text>/../</xsl:text><xsl:value-of select="@series" /> -->
812  <!--     </xsl:when> -->
813  <!--     <xsl:otherwise> -->
814  <!--      <xsl:text></xsl:text> -->
815  <!--     </xsl:otherwise> -->
816  <!--    </xsl:choose> -->
817  <!--   </xsl:variable> -->
818  <!--   <xsl:text>..</xsl:text><xsl:value-of select="$my-series" /><xsl:text>/</xsl:text><xsl:value-of select="@book" /><xsl:text>/</xsl:text><xsl:value-of select="$my-section" /><xsl:value-of select="$xhtml-ext"/> -->
819  <!--  </xsl:attribute> -->
820  <!--  <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute></xsl:if> -->
821    <xsl:apply-templates />
822  <!-- </a> -->
823  </xsl:template>
824
825  <xsl:template match="footref">
826   <xsl:apply-templates />
827   <sup>
828    <xsl:number count="footref" from="/" level="any" format="1" />
829   </sup>
830  </xsl:template>
831
832  <xsl:template match="em">
833   <em><xsl:apply-templates /></em>
834  </xsl:template>
835
836  <xsl:template match="strong">
837   <strong><xsl:apply-templates /></strong>
838  </xsl:template>
839
840  <xsl:template match="thought">
841   <span class="thought"><xsl:apply-templates /></span>
842  </xsl:template>
843
844  <xsl:template match="onomatopoeia">
845   <span class="onomatopoeia"><xsl:apply-templates /></span>
846  </xsl:template>
847
848  <xsl:template match="spell">
849   <span class="spell"><xsl:apply-templates /></span>
850  </xsl:template>
851
852  <xsl:template match="item">
853   <xsl:apply-templates />
854  </xsl:template>
855
856  <xsl:template match="foreign">
857   <span class="foreign">
858    <xsl:attribute name="xml:lang">
859     <xsl:value-of select="@xml:lang"/>
860    </xsl:attribute>
861    <xsl:apply-templates />
862   </span>
863  </xsl:template>
864
865  <xsl:template match="quote">
866   <xsl:text>&#8216;</xsl:text>
867    <xsl:apply-templates />
868   <xsl:if test="not(self::*[@class='open-ended'])"><xsl:text>&#8217;</xsl:text></xsl:if>
869  </xsl:template>
870
871  <xsl:template match="quote//quote">
872   <xsl:text>&#8220;</xsl:text>
873    <xsl:apply-templates />
874   <xsl:if test="not(self::*[@class='open-ended'])"><xsl:text>&#8221;</xsl:text></xsl:if>
875  </xsl:template>
876
877  <xsl:template match="cite">
878   <cite><xsl:apply-templates /></cite>
879  </xsl:template>
880
881  <xsl:template match="code">
882   <tt><xsl:apply-templates /></tt>
883  </xsl:template>
884
885  <xsl:template match="line">
886   <xsl:apply-templates />
887   <xsl:if test="position( ) != last( )"><br /></xsl:if>
888  </xsl:template>
889
890  <xsl:template match="br">
891   <br />
892  </xsl:template>
893
894  <xsl:template match="typ[@class='attribute']">
895   <span class="smallcaps"><xsl:apply-templates /></span>
896  </xsl:template>
897
898  <!-- ==================== character elements ==================== -->
899  <!--
900
901 These templates define the mapping between the character elements used in
902 the Project Aon instances of Gamebook XML and the Unicode characters.
903
904 Portions Copyright International Organization for Standardization 1986 
905 Permission to copy in any form is granted for use with conforming SGML 
906 systems and applications as defined in ISO 8879, provided this notice 
907 is included in all copies.
908
909 -->
910
911  <xsl:template match="ch.apos"><xsl:text>&#39;</xsl:text></xsl:template><!-- apostrophe = single quotation mark -->
912  <xsl:template match="ch.nbsp"><xsl:text>&#160;</xsl:text></xsl:template><!-- no-break space = non-breaking space, U+00A0 ISOnum -->
913  <xsl:template match="ch.iexcl"><xsl:text>&#161;</xsl:text></xsl:template><!-- inverted exclamation mark, U+00A1 ISOnum -->
914  <xsl:template match="ch.cent"><xsl:text>&#162;</xsl:text></xsl:template><!-- cent sign, U+00A2 ISOnum -->
915  <xsl:template match="ch.pound"><xsl:text>&#163;</xsl:text></xsl:template><!-- pound sign, U+00A3 ISOnum -->
916  <xsl:template match="ch.curren"><xsl:text>&#164;</xsl:text></xsl:template><!-- currency sign, U+00A4 ISOnum -->
917  <xsl:template match="ch.yen"><xsl:text>&#165;</xsl:text></xsl:template><!-- yen sign = yuan sign, U+00A5 ISOnum -->
918  <xsl:template match="ch.brvbar"><xsl:text>&#166;</xsl:text></xsl:template><!-- broken bar = broken vertical bar, U+00A6 ISOnum -->
919  <xsl:template match="ch.sect"><xsl:text>&#167;</xsl:text></xsl:template><!-- section sign, U+00A7 ISOnum -->
920  <xsl:template match="ch.uml"><xsl:text>&#168;</xsl:text></xsl:template><!-- diaeresis = spacing diaeresis, U+00A8 ISOdia -->
921  <xsl:template match="ch.copy"><xsl:text>&#169;</xsl:text></xsl:template><!-- copyright sign, U+00A9 ISOnum -->
922  <xsl:template match="ch.ordf"><xsl:text>&#170;</xsl:text></xsl:template><!-- feminine ordinal indicator, U+00AA ISOnum -->
923  <xsl:template match="ch.laquo"><xsl:text>&#171;</xsl:text></xsl:template><!-- left-pointing double angle quotation mark = left pointing guillemet, U+00AB ISOnum -->
924  <xsl:template match="ch.not"><xsl:text>&#172;</xsl:text></xsl:template><!-- not sign, U+00AC ISOnum -->
925  <xsl:template match="ch.shy"><xsl:text>&#173;</xsl:text></xsl:template><!-- soft hyphen = discretionary hyphen, U+00AD ISOnum -->
926  <xsl:template match="ch.reg"><xsl:text>&#174;</xsl:text></xsl:template><!-- registered sign = registered trade mark sign, U+00AE ISOnum -->
927  <xsl:template match="ch.macr"><xsl:text>&#175;</xsl:text></xsl:template><!-- macron = spacing macron = overline = APL overbar, U+00AF ISOdia -->
928  <xsl:template match="ch.deg"><xsl:text>&#176;</xsl:text></xsl:template><!-- degree sign, U+00B0 ISOnum -->
929  <xsl:template match="ch.plusmn"><xsl:text>&#177;</xsl:text></xsl:template><!-- plus-minus sign = plus-or-minus sign, U+00B1 ISOnum -->
930  <xsl:template match="ch.sup2"><xsl:text>&#178;</xsl:text></xsl:template><!-- superscript two = superscript digit two = squared, U+00B2 ISOnum -->
931  <xsl:template match="ch.sup3"><xsl:text>&#179;</xsl:text></xsl:template><!-- superscript three = superscript digit three = cubed, U+00B3 ISOnum -->
932  <xsl:template match="ch.acute"><xsl:text>&#180;</xsl:text></xsl:template><!-- acute accent = spacing acute, U+00B4 ISOdia -->
933  <xsl:template match="ch.micro"><xsl:text>&#181;</xsl:text></xsl:template><!-- micro sign, U+00B5 ISOnum -->
934  <xsl:template match="ch.para"><xsl:text>&#182;</xsl:text></xsl:template><!-- pilcrow sign  = paragraph sign, U+00B6 ISOnum -->
935  <xsl:template match="ch.middot"><xsl:text>&#183;</xsl:text></xsl:template><!-- middle dot = Georgian comma = Greek middle dot, U+00B7 ISOnum -->
936  <xsl:template match="ch.cedil"><xsl:text>&#184;</xsl:text></xsl:template><!-- cedilla = spacing cedilla, U+00B8 ISOdia -->
937  <xsl:template match="ch.sup1"><xsl:text>&#185;</xsl:text></xsl:template><!-- superscript one = superscript digit one, U+00B9 ISOnum -->
938  <xsl:template match="ch.ordm"><xsl:text>&#186;</xsl:text></xsl:template><!-- masculine ordinal indicator, U+00BA ISOnum -->
939  <xsl:template match="ch.raquo"><xsl:text>&#187;</xsl:text></xsl:template><!-- right-pointing double angle quotation mark = right pointing guillemet, U+00BB ISOnum -->
940  <xsl:template match="ch.frac14"><xsl:text>&#188;</xsl:text></xsl:template><!-- vulgar fraction one quarter = fraction one quarter, U+00BC ISOnum -->
941  <xsl:template match="ch.frac12"><xsl:text>&#189;</xsl:text></xsl:template><!-- vulgar fraction one half = fraction one half, U+00BD ISOnum -->
942  <xsl:template match="ch.frac34"><xsl:text>&#190;</xsl:text></xsl:template><!-- vulgar fraction three quarters = fraction three quarters, U+00BE ISOnum -->
943  <xsl:template match="ch.iquest"><xsl:text>&#191;</xsl:text></xsl:template><!-- inverted question mark = turned question mark, U+00BF ISOnum -->
944  <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 -->
945  <xsl:template match="ch.Aacute"><xsl:text>&#193;</xsl:text></xsl:template><!-- latin capital letter A with acute, U+00C1 ISOlat1 -->
946  <xsl:template match="ch.Acirc"><xsl:text>&#194;</xsl:text></xsl:template><!-- latin capital letter A with circumflex, U+00C2 ISOlat1 -->
947  <xsl:template match="ch.Atilde"><xsl:text>&#195;</xsl:text></xsl:template><!-- latin capital letter A with tilde, U+00C3 ISOlat1 -->
948  <xsl:template match="ch.Auml"><xsl:text>&#196;</xsl:text></xsl:template><!-- latin capital letter A with diaeresis, U+00C4 ISOlat1 -->
949  <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 -->
950  <xsl:template match="ch.AElig"><xsl:text>&#198;</xsl:text></xsl:template><!-- latin capital letter AE = latin capital ligature AE, U+00C6 ISOlat1 -->
951  <xsl:template match="ch.Ccedil"><xsl:text>&#199;</xsl:text></xsl:template><!-- latin capital letter C with cedilla, U+00C7 ISOlat1 -->
952  <xsl:template match="ch.Egrave"><xsl:text>&#200;</xsl:text></xsl:template><!-- latin capital letter E with grave, U+00C8 ISOlat1 -->
953  <xsl:template match="ch.Eacute"><xsl:text>&#201;</xsl:text></xsl:template><!-- latin capital letter E with acute, U+00C9 ISOlat1 -->
954  <xsl:template match="ch.Ecirc"><xsl:text>&#202;</xsl:text></xsl:template><!-- latin capital letter E with circumflex, U+00CA ISOlat1 -->
955  <xsl:template match="ch.Euml"><xsl:text>&#203;</xsl:text></xsl:template><!-- latin capital letter E with diaeresis, U+00CB ISOlat1 -->
956  <xsl:template match="ch.Igrave"><xsl:text>&#204;</xsl:text></xsl:template><!-- latin capital letter I with grave, U+00CC ISOlat1 -->
957  <xsl:template match="ch.Iacute"><xsl:text>&#205;</xsl:text></xsl:template><!-- latin capital letter I with acute, U+00CD ISOlat1 -->
958  <xsl:template match="ch.Icirc"><xsl:text>&#206;</xsl:text></xsl:template><!-- latin capital letter I with circumflex, U+00CE ISOlat1 -->
959  <xsl:template match="ch.Iuml"><xsl:text>&#207;</xsl:text></xsl:template><!-- latin capital letter I with diaeresis, U+00CF ISOlat1 -->
960  <xsl:template match="ch.ETH"><xsl:text>&#208;</xsl:text></xsl:template><!-- latin capital letter ETH, U+00D0 ISOlat1 -->
961  <xsl:template match="ch.Ntilde"><xsl:text>&#209;</xsl:text></xsl:template><!-- latin capital letter N with tilde, U+00D1 ISOlat1 -->
962  <xsl:template match="ch.Ograve"><xsl:text>&#210;</xsl:text></xsl:template><!-- latin capital letter O with grave, U+00D2 ISOlat1 -->
963  <xsl:template match="ch.Oacute"><xsl:text>&#211;</xsl:text></xsl:template><!-- latin capital letter O with acute, U+00D3 ISOlat1 -->
964  <xsl:template match="ch.Ocirc"><xsl:text>&#212;</xsl:text></xsl:template><!-- latin capital letter O with circumflex, U+00D4 ISOlat1 -->
965  <xsl:template match="ch.Otilde"><xsl:text>&#213;</xsl:text></xsl:template><!-- latin capital letter O with tilde, U+00D5 ISOlat1 -->
966  <xsl:template match="ch.Ouml"><xsl:text>&#214;</xsl:text></xsl:template><!-- latin capital letter O with diaeresis, U+00D6 ISOlat1 -->
967  <xsl:template match="ch.times"><xsl:text>&#215;</xsl:text></xsl:template><!-- multiplication sign, U+00D7 ISOnum -->
968  <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 -->
969  <xsl:template match="ch.Ugrave"><xsl:text>&#217;</xsl:text></xsl:template><!-- latin capital letter U with grave, U+00D9 ISOlat1 -->
970  <xsl:template match="ch.Uacute"><xsl:text>&#218;</xsl:text></xsl:template><!-- latin capital letter U with acute, U+00DA ISOlat1 -->
971  <xsl:template match="ch.Ucirc"><xsl:text>&#219;</xsl:text></xsl:template><!-- latin capital letter U with circumflex, U+00DB ISOlat1 -->
972  <xsl:template match="ch.Uuml"><xsl:text>&#220;</xsl:text></xsl:template><!-- latin capital letter U with diaeresis, U+00DC ISOlat1 -->
973  <xsl:template match="ch.Yacute"><xsl:text>&#221;</xsl:text></xsl:template><!-- latin capital letter Y with acute, U+00DD ISOlat1 -->
974  <xsl:template match="ch.THORN"><xsl:text>&#222;</xsl:text></xsl:template><!-- latin capital letter THORN, U+00DE ISOlat1 -->
975  <xsl:template match="ch.szlig"><xsl:text>&#223;</xsl:text></xsl:template><!-- latin small letter sharp s = ess-zed, U+00DF ISOlat1 -->
976  <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 -->
977  <xsl:template match="ch.aacute"><xsl:text>&#225;</xsl:text></xsl:template><!-- latin small letter a with acute, U+00E1 ISOlat1 -->
978  <xsl:template match="ch.acirc"><xsl:text>&#226;</xsl:text></xsl:template><!-- latin small letter a with circumflex, U+00E2 ISOlat1 -->
979  <xsl:template match="ch.atilde"><xsl:text>&#227;</xsl:text></xsl:template><!-- latin small letter a with tilde, U+00E3 ISOlat1 -->
980  <xsl:template match="ch.auml"><xsl:text>&#228;</xsl:text></xsl:template><!-- latin small letter a with diaeresis, U+00E4 ISOlat1 -->
981  <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 -->
982  <xsl:template match="ch.aelig"><xsl:text>&#230;</xsl:text></xsl:template><!-- latin small letter ae = latin small ligature ae, U+00E6 ISOlat1 -->
983  <xsl:template match="ch.ccedil"><xsl:text>&#231;</xsl:text></xsl:template><!-- latin small letter c with cedilla, U+00E7 ISOlat1 -->
984  <xsl:template match="ch.egrave"><xsl:text>&#232;</xsl:text></xsl:template><!-- latin small letter e with grave, U+00E8 ISOlat1 -->
985  <xsl:template match="ch.eacute"><xsl:text>&#233;</xsl:text></xsl:template><!-- latin small letter e with acute, U+00E9 ISOlat1 -->
986  <xsl:template match="ch.ecirc"><xsl:text>&#234;</xsl:text></xsl:template><!-- latin small letter e with circumflex, U+00EA ISOlat1 -->
987  <xsl:template match="ch.euml"><xsl:text>&#235;</xsl:text></xsl:template><!-- latin small letter e with diaeresis, U+00EB ISOlat1 -->
988  <xsl:template match="ch.igrave"><xsl:text>&#236;</xsl:text></xsl:template><!-- latin small letter i with grave, U+00EC&n