Some fixes made to the Errata page. No impact on the actual text of the book.
[project-aon.git] / latex.xsl
1 <?xml version="1.0"?>
2 <!DOCTYPE xsl:transform [
3  <!ENTITY % latex.characters SYSTEM "ltexchar.mod">
4  %latex.characters;
5 ]>
6
7 <xsl:transform version="1.0"
8   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
9
10 <xsl:output method="text" encoding="ISO-8859-1" />
11
12 <xsl:strip-space elements="gamebook meta section data ol ul dl li dd footnotes footnote illustration instance" />
13 <xsl:preserve-space elements="p choice" />
14
15 <!--
16
17 $Log$
18 Revision 1.3  2006/04/04 22:02:14  cvsuser
19 Fix two bugs (one } too much and a missing line break)
20
21 Revision 1.2  2005/04/09 19:51:50  angantyr
22 Added handling of open-ended quotes.
23
24 Revision 1.1  2005/01/30 01:32:52  jonathan.blake
25 Initial freepository revision of XML support documents.
26
27 Revision 1.3  2002/10/30 06:33:22  jblake
28 Added capability to filter which illustrators' work is included in the output.
29
30 Revision 1.2  2002/10/20 06:29:58  jblake
31 Added support for CLOSE COMBAT SKILL from the Freeway Warrior books.
32
33 Revision 1.1  2002/10/15 23:30:23  jblake
34 Initial revision
35
36 -->
37
38 <!--
39
40 To Implement:
41
42 The implementation of tables is incomplete and kludgy.
43
44 -->
45
46 <!-- ====================== parameters ========================== -->
47
48 <xsl:param name="title-color"><xsl:text>0.0,0.0,0.0</xsl:text></xsl:param>
49 <xsl:param name="use-illustrators" />
50 <xsl:param name="language"><xsl:text>en</xsl:text></xsl:param>
51
52 <!-- ======================= variables ========================== -->
53
54 <xsl:variable name="newline">
55 <xsl:text>
56 </xsl:text>
57 </xsl:variable>
58
59 <xsl:variable name="newparagraph">
60  <xsl:value-of select="$newline" />
61  <xsl:value-of select="$newline" />
62 </xsl:variable>
63
64 <!-- ======================== Templates ========================= -->
65
66 <!-- ================= hierarchical sections ==================== -->
67
68 <xsl:template match="meta" />
69
70 <!-- ::::::::::::::::::: top-level section :::::::::::::::::::::: -->
71
72 <xsl:template match="/gamebook/section[@id='title']">
73
74 <xsl:choose>
75 <xsl:when test="$language='es'">
76     <xsl:text>
77 %% Two-sided %%
78 %\documentclass[letterpaper,12pt,twoside]{book}
79 % For european books:
80 \documentclass[a4paper,12pt,twoside]{book}
81     </xsl:text>
82 </xsl:when>
83 <xsl:otherwise>
84 <xsl:text>
85 %% Two-sided %%
86 \documentclass[letterpaper,12pt,twoside]{book}
87 % For european books:
88 %\documentclass[a4paper,12pt,twoside]{book}
89 </xsl:text>
90 </xsl:otherwise>
91 </xsl:choose>
92
93 <xsl:text>
94 %% One-sided %%
95 %\documentclass[letterpaper,12pt,oneside]{book}
96 %\documentclass[a4paper,12pt,oneside]{book}
97
98  \usepackage[pdftex]{graphicx}
99  \usepackage{ifthen}
100 </xsl:text>
101 <xsl:choose>
102 <xsl:when test="$language='es'">
103     <xsl:text>
104 % Use this if you are compiling spanish PDFs:
105 \usepackage[spanish]{babel}
106     </xsl:text>
107 </xsl:when>
108 </xsl:choose>
109 <xsl:text>
110  %% color info %%
111  \usepackage{color}
112  \definecolor{titlecolor}{rgb}{</xsl:text><xsl:value-of select="$title-color" /><xsl:text>}
113  \definecolor{lightgray}{gray}{0.75}
114
115  %% headers and footers %%
116  \usepackage{fancyhdr}
117
118  \renewcommand{\chaptermark}[1]{}
119  \renewcommand{\sectionmark}[1]{}
120  \fancyhf{}
121
122  \ifthenelse{\boolean{@twoside}}%
123  {%% Two-sided %%
124   \fancyhead[CO]{\iffloatpage{}{</xsl:text><xsl:value-of select="/gamebook/meta/creator[@class='short']" /><xsl:text>}}
125   \fancyhead[CE]{\iffloatpage{}{\bfseries </xsl:text><xsl:value-of select="/gamebook/meta/title[1]" /><xsl:text>}}
126   \fancyhead[LO,RE]{\iffloatpage{}{\thepage}}}
127  {%% One-sided %%
128   \fancyhead[C]{\iffloatpage{}{\bfseries{</xsl:text><xsl:value-of select="/gamebook/meta/title[1]" /><xsl:text>:} \normalfont{</xsl:text><xsl:value-of select="/gamebook/meta/creator[@class='short']" /><xsl:text>}}}
129   \fancyhead[R]{\iffloatpage{}{\thepage}}}
130   \renewcommand{\headrulewidth}{\iffloatpage{0pt}{0.4pt}}
131
132  \fancypagestyle{plain}{
133   \fancyhf{}
134   \renewcommand{\headrulewidth}{0pt}
135  }
136
137  \fancypagestyle{empty}{
138   \fancyhf{}
139   \renewcommand{\headrulewidth}{0pt}
140  }
141
142  %% hyper-references %%
143  \usepackage[pdftex,colorlinks=true,linkcolor=black,bookmarks=false]{hyperref}
144
145  %% custom style info %%
146  \setlength{\parindent}{0pt}
147  \setlength{\parskip}{1em}
148  \setlength{\headheight}{18pt}
149  \addtolength{\headwidth}{\marginparwidth}
150  \addtolength{\headwidth}{\marginparsep}
151  \setlength{\textheight}{44\baselineskip}
152  \ifthenelse{\lengthtest{\paperwidth = 210mm}}%
153    {%% if A4 (210.0 mm x 297.0 mm)
154    \addtolength{\topmargin}{-1\baselineskip}}%
155    {%% else if letter (8.5" x 11" == 215.9 mm x 279.4 mm)
156    \addtolength{\topmargin}{-2.5\baselineskip}}
157
158  %% TrueType font %%
159  \usepackage[T1]{fontenc}
160  % NOTE: This font might not ve available. Uncomment if you have it configured
161  % for your LaTeX fonts:
162  %\usepackage{souvenir}
163  %\renewcommand{\rmdefault}{souvnrttf}
164
165  \raggedbottom
166
167  %% new environments %%
168  \newenvironment{aonchoice}{\begin{list}{}{\setlength{\topsep}{0pt}} \item}{\end{list}}
169  \newenvironment{aoncombat}{\begin{list}{}{\setlength{\topsep}{0pt}} \item}{\end{list}}
170  \newenvironment{aonitemize}{\begin{list}{}{\setlength{\topsep}{0pt} \setlength{\parsep}{0pt} \setlength{\itemsep}{0pt}}}{\end{list}}
171  \newenvironment{aonordereditemize}{\begin{list}{\arabic{aoncounter}.}{\usecounter{aoncounter} \setlength{\topsep}{0pt} \setlength{\parsep}{0pt} \setlength{\itemsep}{0pt}}}{\end{list}}
172  \newcounter{aoncounter}
173
174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
175 \begin{document}
176
177 \begin{titlepage}
178
179  \vspace*{\stretch{0.7}}
180  \begin{center}
181   \Huge{\textcolor{titlecolor}{\textbf{</xsl:text><xsl:value-of select="/gamebook/meta/title[1]" /><xsl:text>}}} \vspace{-0.8em}\\
182
183   \vspace*{\stretch{1}}
184   \normalsize{</xsl:text><xsl:apply-templates select="/gamebook/meta/creator[@class='medium']" /><xsl:text>}
185  \end{center}
186  \vspace*{\stretch{1.3}}
187
188  \pagestyle{empty}
189
190  \newpage
191
192  \vspace*{\stretch{1}}
193
194  </xsl:text>
195  <xsl:apply-templates select="/gamebook/meta/rights[@class='license-notification']" />
196
197    <xsl:choose>
198     <xsl:when test="$language='es'">
199      <xsl:text>Fecha de Publicaci&oacute;n: </xsl:text>
200     </xsl:when>
201     <xsl:otherwise>
202      <xsl:text>Publication Date: </xsl:text>
203     </xsl:otherwise>
204    </xsl:choose>
205    <xsl:value-of select="/gamebook/meta/date[@class='publication']/day" />
206    <xsl:text> </xsl:text>
207    <xsl:choose>
208     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 1">
209      <xsl:choose>
210       <xsl:when test="$language='es'"><xsl:text>de enero de</xsl:text></xsl:when>
211       <xsl:otherwise><xsl:text>January</xsl:text></xsl:otherwise>
212      </xsl:choose>
213     </xsl:when>
214     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 2">
215      <xsl:choose>
216       <xsl:when test="$language='es'"><xsl:text>de febrero de</xsl:text></xsl:when>
217       <xsl:otherwise><xsl:text>February</xsl:text></xsl:otherwise>
218      </xsl:choose>
219     </xsl:when>
220     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 3">
221      <xsl:choose>
222       <xsl:when test="$language='es'"><xsl:text>de marzo de</xsl:text></xsl:when>
223       <xsl:otherwise><xsl:text>March</xsl:text></xsl:otherwise>
224      </xsl:choose>
225     </xsl:when>
226     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 4">
227      <xsl:choose>
228       <xsl:when test="$language='es'"><xsl:text>de abril de</xsl:text></xsl:when>
229       <xsl:otherwise><xsl:text>April</xsl:text></xsl:otherwise>
230      </xsl:choose>
231     </xsl:when>
232     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 5">
233      <xsl:choose>
234       <xsl:when test="$language='es'"><xsl:text>de mayo de</xsl:text></xsl:when>
235       <xsl:otherwise><xsl:text>May</xsl:text></xsl:otherwise>
236      </xsl:choose>
237     </xsl:when>
238     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 6">
239      <xsl:choose>
240       <xsl:when test="$language='es'"><xsl:text>de junio de</xsl:text></xsl:when>
241       <xsl:otherwise><xsl:text>June</xsl:text></xsl:otherwise>
242      </xsl:choose>
243     </xsl:when>
244     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 7">
245      <xsl:choose>
246       <xsl:when test="$language='es'"><xsl:text>de julio de</xsl:text></xsl:when>
247       <xsl:otherwise><xsl:text>July</xsl:text></xsl:otherwise>
248      </xsl:choose>
249     </xsl:when>
250     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 8">
251      <xsl:choose>
252       <xsl:when test="$language='es'"><xsl:text>de agosto de</xsl:text></xsl:when>
253       <xsl:otherwise><xsl:text>August</xsl:text></xsl:otherwise>
254      </xsl:choose>
255     </xsl:when>
256     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 9">
257      <xsl:choose>
258       <xsl:when test="$language='es'"><xsl:text>de septiembre de</xsl:text></xsl:when>
259       <xsl:otherwise><xsl:text>September</xsl:text></xsl:otherwise>
260      </xsl:choose>
261     </xsl:when>
262     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 10">
263      <xsl:choose>
264       <xsl:when test="$language='es'"><xsl:text>de octubre de</xsl:text></xsl:when>
265       <xsl:otherwise><xsl:text>October</xsl:text></xsl:otherwise>
266      </xsl:choose>
267     </xsl:when>
268     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 11">
269      <xsl:choose>
270       <xsl:when test="$language='es'"><xsl:text>de noviembre de</xsl:text></xsl:when>
271       <xsl:otherwise><xsl:text>November</xsl:text></xsl:otherwise>
272      </xsl:choose>
273     </xsl:when>
274     <xsl:when test="/gamebook/meta/date[@class='publication']/month = 12">
275      <xsl:choose>
276       <xsl:when test="$language='es'"><xsl:text>de diciembre de</xsl:text></xsl:when>
277       <xsl:otherwise><xsl:text>December</xsl:text></xsl:otherwise>
278      </xsl:choose>
279     </xsl:when>
280     <xsl:otherwise>
281      <xsl:text>Invalid Month</xsl:text>
282     </xsl:otherwise>
283    </xsl:choose>
284  <xsl:text> </xsl:text>
285  <xsl:value-of select="/gamebook/meta/date[@class='publication']/year" />
286  <xsl:text>
287
288  </xsl:text>
289  <xsl:apply-templates select="/gamebook/meta/description[@class='publication']" />
290  <xsl:text>
291
292  \vspace*{\stretch{3}}
293
294  \pagestyle{empty}
295
296 \end{titlepage}
297
298 \clearpage{\pagestyle{empty}\cleardoublepage}
299
300  \vspace*{\stretch{1}}
301
302  \thispagestyle{empty}
303  </xsl:text>
304  <xsl:apply-templates select="/gamebook/meta/description[@class='blurb']" />
305  <xsl:apply-templates select="/gamebook/meta/creator[@class='long']" />
306  <xsl:text>
307
308  \vspace*{\stretch{3}}
309
310 \clearpage{\pagestyle{empty}\cleardoublepage}
311
312  \pagestyle{fancy}
313
314 \begin{frontmatter}
315 </xsl:text>
316
317  <xsl:apply-templates select="data/section[@class='frontmatter']" />
318
319 <xsl:text>
320 \end{frontmatter}
321
322 </xsl:text>
323 <xsl:if test="data/section[@class='mainmatter']">
324  <xsl:text>\begin{mainmatter}
325
326  </xsl:text>
327
328  <xsl:apply-templates select="data/section[@class='mainmatter']" />
329
330  <xsl:text>
331  \end{mainmatter}
332  </xsl:text>
333 </xsl:if>
334
335 <xsl:if test="data/section[@class='numbered']">
336  <xsl:apply-templates select="data/section[@class='numbered']" />
337 </xsl:if>
338
339  <xsl:text>
340 \begin{backmatter}
341 \ifthenelse{\boolean{@twoside}}%
342  {%% Two-sided %%
343   \fancyhead[RO,LE]{}}
344  {%% One-sided %%
345   \fancyhead[R]{}}
346
347  \setcounter{topnumber}{6}
348  \renewcommand{\topfraction}{1}
349  \renewcommand{\textfraction}{0}
350  \setlength{\floatsep}{10pt}
351
352  </xsl:text>
353  <xsl:apply-templates select="data/section[@class='backmatter']" />
354  <xsl:text>
355
356 \end{backmatter}
357
358 \end{document}
359 </xsl:text>
360
361 </xsl:template>
362
363 <xsl:template match="/gamebook/section[@id='toc']" />
364
365 <xsl:template match="section" />
366
367 <!-- ::::::::::: second-level frontmatter sections :::::::::::::: -->
368
369 <xsl:template match="/gamebook/section/data/section[@class='frontmatter']">
370
371  <xsl:text>\clearpage{\pagestyle{empty}\cleardoublepage}</xsl:text>
372  <xsl:value-of select="$newparagraph" />
373
374  <xsl:text>{\huge \hypertarget{</xsl:text>
375   <xsl:value-of select="@id" />
376  <xsl:text>}{</xsl:text>
377  <xsl:value-of select="meta/title" />
378  <xsl:text>}}</xsl:text>
379  <xsl:value-of select="$newline" />
380  <xsl:text>\addcontentsline{toc}{section}{\protect\numberline{}{</xsl:text>
381   <xsl:value-of select="meta/title" />
382  <xsl:text>}}</xsl:text>
383  <xsl:value-of select="$newparagraph" />
384
385  <xsl:apply-templates />
386
387 </xsl:template>
388
389 <!-- :::::::::::: third-level front matter sections ::::::::::::: -->
390
391 <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter']">
392
393  <xsl:text>{\LARGE \hypertarget{</xsl:text>
394   <xsl:value-of select="@id" />
395  <xsl:text>}{</xsl:text>
396  <xsl:value-of select="meta/title" />
397  <xsl:text>}}</xsl:text>
398  <xsl:value-of select="$newparagraph" />
399
400  <xsl:apply-templates />
401 </xsl:template>
402
403 <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter-separate']">
404
405  <xsl:text>\newpage</xsl:text><xsl:value-of select="$newline" />
406  <xsl:text>{\LARGE \hypertarget{</xsl:text>
407   <xsl:value-of select="@id" />
408  <xsl:text>}{</xsl:text>
409  <xsl:value-of select="meta/title" />
410  <xsl:text>}}</xsl:text>
411  <xsl:value-of select="$newline" />
412  <xsl:text>\addcontentsline{toc}{subsection}{\protect\numberline{}{</xsl:text>
413   <xsl:value-of select="meta/title" />
414  <xsl:text>}}</xsl:text>
415  <xsl:value-of select="$newparagraph" />
416
417  <xsl:apply-templates />
418 </xsl:template>
419
420 <!-- :::::::::::: fourth-level front matter sections :::::::::::: -->
421
422 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='frontmatter']">
423  <xsl:text>{\Large \hypertarget{</xsl:text>
424   <xsl:value-of select="@id" />
425  <xsl:text>}{</xsl:text>
426  <xsl:value-of select="meta/title" />
427  <xsl:text>}}</xsl:text>
428  <xsl:value-of select="$newparagraph" />
429
430  <xsl:apply-templates />
431 </xsl:template>
432
433 <!-- ::::::::::::: fifth-level front matter sections :::::::::::: -->
434
435 <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='frontmatter']">
436  <xsl:text>{\large \hypertarget{</xsl:text>
437   <xsl:value-of select="@id" />
438  <xsl:text>}{</xsl:text>
439  <xsl:value-of select="meta/title" />
440  <xsl:text>}}</xsl:text>
441  <xsl:value-of select="$newparagraph" />
442
443  <xsl:apply-templates />
444 </xsl:template>
445
446 <!-- ::::::::::: second-level main matter sections :::::::::::::: -->
447
448 <xsl:template match="/gamebook/section/data/section[@class='mainmatter']">
449  <xsl:text>\clearpage{\pagestyle{empty}\cleardoublepage}</xsl:text>
450  <xsl:value-of select="$newparagraph" />
451
452  <xsl:text>{\huge \hypertarget{</xsl:text>
453   <xsl:value-of select="@id" />
454  <xsl:text>}{</xsl:text>
455  <xsl:value-of select="meta/title" />
456  <xsl:text>}}</xsl:text>
457  <xsl:value-of select="$newline" />
458  <xsl:text>\addcontentsline{toc}{section}{\protect\numberline{}{</xsl:text>
459   <xsl:value-of select="meta/title" />
460  <xsl:text>}}</xsl:text>
461  <xsl:value-of select="$newparagraph" />
462
463  <xsl:apply-templates />
464
465 </xsl:template>
466
467 <!-- :::::::::::: third-level main matter sections ::::::::::::: -->
468
469 <xsl:template match="/gamebook/section/data/section/data/section[@class='mainmatter'] | /gamebook/section/data/section/data/section[@class='mainmatter-separate']">
470
471  <xsl:text>\newpage</xsl:text><xsl:value-of select="$newline" />
472  <xsl:text>{\LARGE \hypertarget{</xsl:text>
473   <xsl:value-of select="@id" />
474  <xsl:text>}{</xsl:text>
475  <xsl:value-of select="meta/title" />
476  <xsl:text>}}</xsl:text>
477  <xsl:value-of select="$newline" />
478  <xsl:text>\addcontentsline{toc}{subsection}{\protect\numberline{}{</xsl:text>
479   <xsl:value-of select="meta/title" />
480  <xsl:text>}}</xsl:text>
481  <xsl:value-of select="$newparagraph" />
482
483  <xsl:apply-templates />
484 </xsl:template>
485
486 <!-- :::::::::::: fourth-level main matter sections :::::::::::: -->
487
488 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='mainmatter'] | /gamebook/section/data/section/data/section/data/section[@class='mainmatter-separate']">
489  <xsl:text>{\Large \hypertarget{</xsl:text>
490   <xsl:value-of select="@id" />
491  <xsl:text>}{</xsl:text>
492  <xsl:value-of select="meta/title" />
493  <xsl:text>}}</xsl:text>
494  <xsl:value-of select="$newparagraph" />
495
496  <xsl:apply-templates />
497 </xsl:template>
498
499 <!-- ::::::::::::: fifth-level main matter sections :::::::::::: -->
500
501 <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='mainmatter']">
502  <xsl:text>{\large \hypertarget{</xsl:text>
503   <xsl:value-of select="@id" />
504  <xsl:text>}{</xsl:text>
505  <xsl:value-of select="meta/title" />
506  <xsl:text>}}</xsl:text>
507  <xsl:value-of select="$newparagraph" />
508
509  <xsl:apply-templates />
510 </xsl:template>
511
512 <!-- :::::::::::: third-level glossary sections ::::::::::::: -->
513 <!-- Glossary sections should be contained in a second level section. -->
514
515 <xsl:template match="/gamebook/section/data/section/data/section[@class='glossary'] | /gamebook/section/data/section/data/section[@class='glossary-separate']">
516
517  <xsl:text>\newpage</xsl:text><xsl:value-of select="$newline" />
518  <xsl:text>{\LARGE \hypertarget{</xsl:text>
519   <xsl:value-of select="@id" />
520  <xsl:text>}{</xsl:text>
521  <xsl:value-of select="meta/title" />
522  <xsl:text>}}</xsl:text>
523  <xsl:value-of select="$newparagraph" />
524
525  <xsl:apply-templates />
526 </xsl:template>
527
528 <!-- :::::::::::::::::: numbered sections ::::::::::::::::::::::: -->
529
530 <xsl:template match="/gamebook/section/data/section[@class='numbered']">
531  <xsl:text>\clearpage{\pagestyle{empty}\cleardoublepage}</xsl:text> <xsl:value-of select="$newparagraph" />
532
533  <xsl:if test="position() = 1">
534   <xsl:text>\newcommand{\aonmarks}{
535     \ifthenelse{\equal{\leftmark}{\rightmark}}
536       {\rightmark}
537       {\rightmark{} - \leftmark}
538   \ifthenelse{\boolean{@twoside}}%
539    {%% Two-sided %%
540     \fancyhead[RO,LE]{\iffloatpage{}{\large{\bfseries \aonmarks}}}
541     \fancyhead[LO,RE]{\iffloatpage{}{\thepage}}}
542    {%% One-sided %%
543     \fancyhead[R]{\iffloatpage{}{\large{\bfseries \aonmarks}}}
544     \fancyhead[L]{\iffloatpage{}{\thepage}}%
545     }
546    }</xsl:text> <xsl:value-of select="$newparagraph" />
547  </xsl:if>
548
549  <xsl:if test="not( self::node()[@id='numbered'] )">
550   <xsl:text>{\huge \hypertarget{</xsl:text>
551    <xsl:value-of select="@id" />
552   <xsl:text>}{</xsl:text>
553   <xsl:value-of select="meta/title" />
554   <xsl:text>}}</xsl:text>
555   <xsl:value-of select="$newline" />
556  </xsl:if>
557  <xsl:text>\addcontentsline{toc}{section}{\protect\numberline{}{</xsl:text>
558   <xsl:value-of select="meta/title" />
559  <xsl:text>}}</xsl:text>
560  <xsl:value-of select="$newparagraph" />
561
562  <xsl:apply-templates />
563
564  <xsl:value-of select="$newparagraph" />
565  <xsl:text>\clearpage{\pagestyle{empty}\cleardoublepage}</xsl:text>
566 </xsl:template>
567
568 <xsl:template match="/gamebook/section/data/section[@class='numbered']/data/section[@class='numbered']">
569  <xsl:variable name="section-title" select="meta/title[1]" />
570
571 <xsl:value-of select="$newline" />
572 <xsl:text>\vspace{\parskip} \hypertarget{</xsl:text>
573 <xsl:value-of select="@id" />
574 <xsl:text>}{} \hspace*{\fill} \markboth{</xsl:text>
575 <xsl:value-of select="$section-title" />
576 <xsl:text>}{</xsl:text>
577 <xsl:value-of select="$section-title" />
578 <xsl:text>} {\Large \bfseries </xsl:text>
579 <xsl:value-of select="$section-title" />
580 <xsl:text>} \hspace*{\fill}\\*[\parskip]</xsl:text>
581 <xsl:value-of select="$newline" />
582
583 <xsl:for-each select="data/illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]">
584  <xsl:text>\hspace*{\fill} \mbox{\itshape \hyperlink{ill</xsl:text>
585  <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="1" />
586        <xsl:choose>
587         <xsl:when test="$language='es'">
588  <xsl:text>}{Ilustraci&oacute;n </xsl:text>
589         </xsl:when>
590         <xsl:otherwise>
591  <xsl:text>}{Illustration </xsl:text>
592         </xsl:otherwise>
593        </xsl:choose>
594  <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
595  <xsl:text>}}\hspace*{\fill}\\*[\parskip]</xsl:text>
596 </xsl:for-each>
597
598  <xsl:apply-templates />
599
600 </xsl:template>
601
602 <!-- :::::::::::: second-level backmatter sections :::::::::::::: -->
603
604 <xsl:template match="/gamebook/section/data/section[@class='backmatter']">
605
606  <xsl:text>\clearpage{}</xsl:text>
607  <xsl:value-of select="$newparagraph" />
608
609  <xsl:text>{\huge \hypertarget{</xsl:text>
610   <xsl:value-of select="@id" />
611  <xsl:text>}{</xsl:text>
612  <xsl:value-of select="meta/title" />
613  <xsl:text>}}</xsl:text>
614  <xsl:value-of select="$newline" />
615  <xsl:text>\addcontentsline{toc}{section}{\protect\numberline{}{</xsl:text>
616   <xsl:value-of select="meta/title" />
617  <xsl:text>}}</xsl:text>
618  <xsl:value-of select="$newparagraph" />
619
620  <xsl:apply-templates />
621 </xsl:template>
622
623 <!-- ::::::::::::: third-level back matter sections ::::::::::::: -->
624
625 <xsl:template match="/gamebook/section/data/section/data/section[@class='backmatter']">
626  <xsl:text>{\LARGE \hypertarget{</xsl:text>
627   <xsl:value-of select="@id" />
628  <xsl:text>}{</xsl:text>
629  <xsl:value-of select="meta/title" />
630  <xsl:text>}}</xsl:text>
631  <xsl:value-of select="$newparagraph" />
632
633  <xsl:apply-templates />
634 </xsl:template>
635
636 <!-- ::::::::::::: fourth-level back matter sections ::::::::::::: -->
637
638 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='backmatter']">
639  <xsl:text>{\Large \hypertarget{</xsl:text>
640   <xsl:value-of select="@id" />
641  <xsl:text>}{</xsl:text>
642  <xsl:value-of select="meta/title" />
643  <xsl:text>}}</xsl:text>
644  <xsl:value-of select="$newparagraph" />
645
646  <xsl:apply-templates />
647 </xsl:template>
648
649 <!-- :::::::::::::::::: dedication template ::::::::::::::::::::: -->
650
651 <xsl:template match="id( 'dedicate' )">
652  
653  <xsl:text>\vspace*{\stretch{1}}</xsl:text>
654  <xsl:value-of select="$newparagraph" />
655  <xsl:text>\begin{center}</xsl:text>
656  <xsl:value-of select="$newline" />
657  <xsl:text>\thispagestyle{empty}</xsl:text>
658  <xsl:value-of select="$newline" />
659  <xsl:text>\itshape </xsl:text>
660  <xsl:apply-templates select="data/p" />
661  <xsl:value-of select="$newline" />
662  <xsl:text>\end{center}</xsl:text>
663  <xsl:value-of select="$newparagraph" />
664  <xsl:text>\vspace*{\stretch{3}}</xsl:text>
665  <xsl:value-of select="$newline" />
666
667  <xsl:text>\clearpage{\pagestyle{empty}\cleardoublepage}</xsl:text>
668  <xsl:value-of select="$newline" />
669  <xsl:text>\tableofcontents</xsl:text>
670  <xsl:value-of select="$newline" />
671  <xsl:text>\clearpage{\pagestyle{empty}\cleardoublepage}</xsl:text>
672  <xsl:value-of select="$newline" />
673
674  <xsl:text>\setcounter{page}{1}</xsl:text><xsl:value-of select="$newline" />
675  <xsl:text>\pagenumbering{arabic}</xsl:text><xsl:value-of select="$newline" />
676
677 </xsl:template>
678
679 <!-- ::::::::::::::::::::: map template ::::::::::::::::::::::::: -->
680
681 <xsl:template match="id( 'map' )">
682  <xsl:variable name="map-title" select="meta/title" />
683
684  <xsl:text>\clearpage{\pagestyle{empty}\cleardoublepage}</xsl:text>
685  <xsl:value-of select="$newparagraph" />
686
687   <xsl:for-each select="data/illustration[contains( $use-illustrators, concat( ':', meta/creator, ':' ) ) ]">
688    <xsl:variable name="illustration-src" select="instance[@class='pdf']/@src" />
689
690    <xsl:text>\hypertarget{map}{map}</xsl:text>
691    <xsl:value-of select="$newline" />
692    <xsl:text>\addcontentsline{toc}{section}{\protect\numberline{}{</xsl:text>
693     <xsl:value-of select="$map-title" />
694    <xsl:text>}}</xsl:text>
695    <xsl:value-of select="$newparagraph" />
696
697 <!--   <xsl:value-of select="$newline" />
698    <xsl:text>\begin{figure}[!h]</xsl:text>
699    <xsl:value-of select="$newline" />
700     <xsl:text>\centering</xsl:text>
701     <xsl:value-of select="$newline" />
702     <xsl:text>\thispagestyle{empty}</xsl:text>
703     <xsl:value-of select="$newline" />
704     <xsl:text>\rotatebox{90}{\includegraphics[width=550pt,keepaspectratio]{</xsl:text><xsl:value-of select="$illustration-src" /><xsl:text>}}%</xsl:text>
705     <xsl:value-of select="$newline" />
706    <xsl:text>\end{figure}</xsl:text> -->
707
708    <xsl:text>\thispagestyle{empty}</xsl:text><xsl:value-of select="$newline" />
709    <xsl:text>\newlength{\saveunitlength}</xsl:text><xsl:value-of select="$newline" />
710    <xsl:text>\setlength{\saveunitlength}{\unitlength}</xsl:text><xsl:value-of select="$newline" />
711    <xsl:text>\setlength{\unitlength}{1mm}</xsl:text><xsl:value-of select="$newline" />
712    <xsl:text>\ifthenelse{\boolean{@twoside}}%</xsl:text><xsl:value-of select="$newline" />
713    <xsl:text> {%% Two-sided %%</xsl:text><xsl:value-of select="$newline" />
714    <xsl:text>  \begin{picture}(10,10)</xsl:text><xsl:value-of select="$newline" />
715    <xsl:text>  \put(-23,-188){\includegraphics[angle=90,origin=c,width=20cm,height=28cm,keepaspectratio]{map.pdf}}</xsl:text><xsl:value-of select="$newline" />
716    <xsl:text>  \end{picture}}%</xsl:text><xsl:value-of select="$newline" />
717    <xsl:text> {%% One-sided %%</xsl:text><xsl:value-of select="$newline" />
718    <xsl:text>  \begin{picture}(10,10)</xsl:text><xsl:value-of select="$newline" />
719    <xsl:text>  \put(-29,-188){\includegraphics[angle=90,origin=c,width=20cm,height=28cm,keepaspectratio]{map.pdf}}</xsl:text><xsl:value-of select="$newline" />
720    <xsl:text>  \end{picture}}</xsl:text><xsl:value-of select="$newline" />
721    <xsl:text>\setlength{\unitlength}{\saveunitlength}</xsl:text><xsl:value-of select="$newline" />
722
723   </xsl:for-each>
724 </xsl:template>
725
726 <!-- ==================== block elements ======================== -->
727
728 <xsl:template match="p">
729  <xsl:apply-templates />
730  <xsl:value-of select="$newparagraph" />
731 </xsl:template>
732
733 <xsl:template match="ul">
734  <xsl:text>\begin{aonitemize}</xsl:text><xsl:value-of select="$newline" />
735  <xsl:apply-templates />
736  <xsl:text>\end{aonitemize}</xsl:text>
737  <xsl:value-of select="$newparagraph" />
738 </xsl:template>
739
740 <xsl:template match="ul[@class='unbulleted']">
741  <xsl:text>\begin{aonitemize}</xsl:text><xsl:value-of select="$newline" />
742  <xsl:apply-templates />
743  <xsl:text>\end{aonitemize}</xsl:text>
744  <xsl:value-of select="$newparagraph" />
745 </xsl:template>
746
747 <xsl:template match="ol">
748  <xsl:text>\begin{enumerate}</xsl:text><xsl:value-of select="$newline" />
749  <xsl:apply-templates />
750  <xsl:text>\end{enumerate}</xsl:text>
751  <xsl:value-of select="$newparagraph" />
752 </xsl:template>
753
754 <xsl:template match="dl">
755  <xsl:apply-templates />
756 </xsl:template>
757
758 <xsl:template match="table">
759  <xsl:text>\begin{tabular}{*{</xsl:text>
760  <xsl:for-each select="tr[1]">
761   <xsl:for-each select="th[1]">
762    <xsl:number count="th" />
763   </xsl:for-each>
764  </xsl:for-each>
765  <xsl:text>}{l}}</xsl:text>
766  <xsl:value-of select="$newline" />
767   <xsl:apply-templates />
768  <xsl:text>\end{tabular}</xsl:text>
769  <xsl:value-of select="$newparagraph" />
770 </xsl:template>
771
772 <xsl:template match="tr">
773  <xsl:apply-templates />
774  <xsl:text> \\</xsl:text>
775 </xsl:template>
776
777 <xsl:template match="th">
778  <xsl:text>\multicolumn{1}{</xsl:text>
779  <xsl:choose>
780   <xsl:when test="@align='left'"><xsl:text>l}{\bfseries </xsl:text></xsl:when>
781   <xsl:when test="@align='right'"><xsl:text>r}{\bfseries </xsl:text></xsl:when>
782   <xsl:when test="@align='center'"><xsl:text>c}{\bfseries </xsl:text></xsl:when>
783   <xsl:otherwise><xsl:text>l}{\bfseries </xsl:text></xsl:otherwise>
784  </xsl:choose>
785   <xsl:apply-templates />
786  <xsl:text>} </xsl:text>
787  <xsl:if test="position != last()"><xsl:text>&amp;</xsl:text></xsl:if>
788 </xsl:template>
789
790 <xsl:template match="td">
791  <xsl:text>\multicolumn{1}{</xsl:text>
792  <xsl:choose>
793   <xsl:when test="@align='left'"><xsl:text>l}{</xsl:text></xsl:when>
794   <xsl:when test="@align='right'"><xsl:text>r}{</xsl:text></xsl:when>
795   <xsl:when test="@align='center'"><xsl:text>c}{</xsl:text></xsl:when>
796   <xsl:otherwise><xsl:text>l}{</xsl:text></xsl:otherwise>
797  </xsl:choose>
798   <xsl:apply-templates />
799  <xsl:text>} </xsl:text>
800  <xsl:if test="position != last()"><xsl:text>&amp;</xsl:text></xsl:if>
801 </xsl:template>
802
803 <xsl:template match="combat">
804  <xsl:text>\begin{aoncombat}</xsl:text>
805   <xsl:apply-templates select="enemy" />
806   <xsl:choose>
807    <xsl:when test="enemy-attribute[@class='combatskill']">
808      <xsl:choose>
809       <xsl:when test="$language='es'">
810        <xsl:text>: {\small DESTREZA~EN~EL~COMBATE}~</xsl:text>
811       </xsl:when>
812       <xsl:otherwise>
813        <xsl:text>: {\small COMBAT~SKILL}~</xsl:text>
814       </xsl:otherwise>
815      </xsl:choose>
816     <xsl:value-of select="enemy-attribute[@class='combatskill']" />
817    </xsl:when>
818    <xsl:when test="enemy-attribute[@class='closecombatskill']">
819      <xsl:choose>
820       <xsl:when test="$language='es'">
821        <xsl:text>: {\small DESTREZA~EN~EL~COMBATE~DE~PROXIMIDAD}~</xsl:text>
822       </xsl:when>
823       <xsl:otherwise>
824        <xsl:text>: {\small CLOSE~COMBAT~SKILL}~</xsl:text>
825       </xsl:otherwise>
826      </xsl:choose>
827     <xsl:value-of select="enemy-attribute[@class='closecombatskill']" />
828    </xsl:when>
829   </xsl:choose>
830     <xsl:choose>
831      <xsl:when test="$language='es'">
832       <xsl:text> ~~{\small RESISTENCIA}~</xsl:text>
833      </xsl:when>
834      <xsl:otherwise>
835       <xsl:text> ~~{\small ENDURANCE}~</xsl:text>
836     </xsl:otherwise>
837    </xsl:choose>
838   <xsl:choose>
839    <xsl:when test="enemy-attribute[@class='target']">
840     <xsl:choose>
841      <xsl:when test="$language='es'">
842       <xsl:text>~(puntos~de~{\small OBJETIVO})~</xsl:text>
843      </xsl:when>
844      <xsl:otherwise>
845       <xsl:text>~({\small TARGET}~points)~</xsl:text>
846     </xsl:otherwise>
847    </xsl:choose>
848     <xsl:value-of select="enemy-attribute[@class='target']" />
849    </xsl:when>
850    <xsl:when test="enemy-attribute[@class='resistance']">
851     <xsl:choose>
852      <xsl:when test="$language='es'">
853       <xsl:text>~(puntos~de~{\small RESISTENCIA})~</xsl:text>
854      </xsl:when>
855      <xsl:otherwise>
856       <xsl:text>~({\small RESISTANCE}~points)~</xsl:text>
857     </xsl:otherwise>
858    </xsl:choose>
859     <xsl:value-of select="enemy-attribute[@class='resistance']" />
860    </xsl:when>
861    <xsl:otherwise>
862     <xsl:value-of select="enemy-attribute[@class='endurance']" />
863    </xsl:otherwise>
864   </xsl:choose>
865  <xsl:text>\end{aoncombat}</xsl:text>
866  <xsl:value-of select="$newparagraph" />
867 </xsl:template>
868
869 <xsl:template match="choice">
870  <xsl:variable name="link">
871   <xsl:value-of select="@idref" />
872  </xsl:variable>
873
874  <xsl:text>\begin{aonchoice}</xsl:text>
875   <xsl:for-each select="* | text()">
876    <xsl:choose>
877     <xsl:when test="self::link-text">
878      <xsl:text>\hyperlink{</xsl:text>
879      <xsl:value-of select="$link" />
880      <xsl:text>}{\bfseries </xsl:text>
881       <xsl:apply-templates />
882      <xsl:text>}</xsl:text>
883     </xsl:when>
884     <xsl:otherwise>
885      <xsl:apply-templates select="." />
886     </xsl:otherwise>
887    </xsl:choose>
888   </xsl:for-each>
889  <xsl:text>\end{aonchoice}</xsl:text>
890  <xsl:value-of select="$newparagraph" />
891 </xsl:template>
892
893 <xsl:template match="signpost">
894  <xsl:text>\begin{center}</xsl:text><xsl:apply-templates /><xsl:text>\end{center}</xsl:text>
895  <xsl:value-of select="$newparagraph" />
896 </xsl:template>
897
898 <xsl:template match="blockquote">
899  <xsl:text>\begin{quote}</xsl:text><xsl:apply-templates /><xsl:text>\end{quote}</xsl:text>
900  <xsl:value-of select="$newparagraph" />
901 </xsl:template>
902
903 <xsl:template match="illustration">
904  <xsl:choose>
905   <xsl:when test="instance[@class='pdf'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
906    <xsl:text>\begin{figure}[</xsl:text>
907    <xsl:choose>
908     <xsl:when test="@class='inline'">!ht</xsl:when>
909     <xsl:when test="@class='float'">p</xsl:when>
910     <xsl:when test="@class='accent'">bt</xsl:when>
911     <xsl:otherwise><xsl:text>invalid class</xsl:text></xsl:otherwise>
912    </xsl:choose>
913    <xsl:text>]</xsl:text>
914    <xsl:value-of select="$newline" />
915    <xsl:text>\centering</xsl:text>
916    <xsl:value-of select="$newline" />
917    <xsl:text>\includegraphics</xsl:text>
918    <xsl:if test="@class='float'">
919     <!--<xsl:text>[width=\textwidth,keepaspectratio]</xsl:text>-->
920     <xsl:text>[width=\textwidth,height=570pt,keepaspectratio]</xsl:text>
921    </xsl:if>
922    <xsl:text>{</xsl:text>
923     <xsl:value-of select="instance[@class='pdf']/@src" />
924    <xsl:text>} %</xsl:text>
925    <xsl:if test="@class='float'">
926     <xsl:value-of select="$newline" />
927     <xsl:text>\vspace*{\fill}</xsl:text>
928     <xsl:value-of select="$newline" />
929     <xsl:text>\\ \mbox{ \hypertarget{ill</xsl:text>
930      <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="1" />
931        <xsl:choose>
932         <xsl:when test="$language='es'">
933             <xsl:text>}{Ilustraci&oacute;n </xsl:text>
934         </xsl:when>
935         <xsl:otherwise>
936             <xsl:text>}{Illustration </xsl:text>
937         </xsl:otherwise>
938        </xsl:choose>
939      <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
940     <xsl:text>}}\\[1em]{\itshape </xsl:text>
941     <xsl:apply-templates select="meta/description" />
942     <xsl:text>}</xsl:text>
943    </xsl:if>
944    <xsl:value-of select="$newline" />
945    <xsl:text>\end{figure}</xsl:text>
946    <xsl:value-of select="$newline" />
947   </xsl:when>
948
949   <xsl:when test="instance[@class='tex'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
950    <xsl:value-of select="$newline" />
951    <xsl:text>\begin{figure}[!h]</xsl:text>
952    <xsl:value-of select="$newline" />
953     <xsl:text>\centering</xsl:text>
954     <xsl:value-of select="$newline" />
955     <xsl:text>\input{</xsl:text><xsl:value-of select="instance[@class='tex']/@src" /><xsl:text>}</xsl:text>
956     <xsl:value-of select="$newline" />
957    <xsl:text>\end{figure}</xsl:text>
958    <xsl:value-of select="$newline" />
959
960    <xsl:text>\clearpage{}</xsl:text>   
961    <xsl:value-of select="$newparagraph" />
962   </xsl:when>
963
964   <xsl:otherwise />
965
966  </xsl:choose>
967 </xsl:template>
968
969 <xsl:template match="instance" />
970
971 <xsl:template match="footnotes" />
972
973 <xsl:template match="footnote">
974  <xsl:apply-templates />
975 </xsl:template>
976
977 <xsl:template match="hr">
978  <xsl:text>\rule{\textwidth}{0.4pt}</xsl:text>
979  <xsl:value-of select="$newline" />
980 </xsl:template>
981
982 <xsl:template match="dt">
983  <xsl:text>{\bfseries </xsl:text><xsl:apply-templates /><xsl:text>}\\*\\*</xsl:text>
984  <xsl:value-of select="$newline" />
985 </xsl:template>
986
987 <xsl:template match="dd">
988  <xsl:apply-templates />
989  <xsl:value-of select="$newparagraph" />
990 </xsl:template>
991
992 <xsl:template match="li">
993  <xsl:text>\item </xsl:text><xsl:apply-templates />
994  <xsl:value-of select="$newline" />
995 </xsl:template>
996
997 <!-- ==================== inline elements ======================= -->
998
999 <xsl:template match="a">
1000  <xsl:if test="@idref">
1001   <xsl:text>\hyperlink{</xsl:text>
1002   <xsl:value-of select="@idref" />
1003   <xsl:text>}{</xsl:text>
1004  </xsl:if>
1005  <xsl:if test="@id">
1006   <xsl:text>\hypertarget{</xsl:text>
1007   <xsl:value-of select="@id" />
1008   <xsl:text>}{</xsl:text>
1009  </xsl:if>
1010
1011  <xsl:apply-templates />
1012
1013  <xsl:if test="@idref">
1014   <xsl:text>}</xsl:text>
1015  </xsl:if>
1016  <xsl:if test="@id">
1017   <xsl:text>}</xsl:text>
1018  </xsl:if>
1019 </xsl:template>
1020
1021 <xsl:template match="a[@class='footnote']">
1022  <xsl:apply-templates />
1023  <xsl:text>\footnote{</xsl:text>
1024  <xsl:for-each select="id( @idref )">
1025   <xsl:apply-templates />
1026  </xsl:for-each>
1027  <xsl:text>}</xsl:text>
1028 </xsl:template>
1029
1030 <xsl:template match="em">
1031  <xsl:text>\emph{</xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1032 </xsl:template>
1033
1034 <xsl:template match="strong">
1035  <xsl:text>{\bfseries </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1036 </xsl:template>
1037
1038 <xsl:template match="cite">
1039  <xsl:text>{\itshape </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1040 </xsl:template>
1041
1042 <xsl:template match="thought">
1043  <xsl:text>{\itshape </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1044 </xsl:template>
1045
1046 <xsl:template match="onomatopoeia">
1047  <xsl:text>{\itshape </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1048 </xsl:template>
1049
1050 <xsl:template match="spell">
1051  <xsl:text>{\itshape </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1052 </xsl:template>
1053
1054 <xsl:template match="item">
1055  <xsl:apply-templates />
1056 </xsl:template>
1057
1058 <xsl:template match="foreign">
1059  <xsl:text>{\itshape </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1060 </xsl:template>
1061
1062 <xsl:template match="quote">
1063  <xsl:text>&lsquot;</xsl:text>
1064   <xsl:apply-templates />
1065   <xsl:if test="not(self::*[@class='open-ended'])"><xsl:text>&rsquot;</xsl:text></xsl:if>
1066 </xsl:template>
1067
1068 <xsl:template match="quote//quote">
1069  <xsl:text>&ldquot;</xsl:text>
1070   <xsl:apply-templates />
1071   <xsl:if test="not(self::*[@class='open-ended'])"><xsl:text>&rdquot;</xsl:text></xsl:if>
1072 </xsl:template>
1073
1074 <xsl:template match="code">
1075  <xsl:text>{\ttfamily </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1076 </xsl:template>
1077
1078 <xsl:template match="br">
1079  <xsl:text>\\</xsl:text>
1080 </xsl:template>
1081
1082 <xsl:template match="typ[@class='attribute']">
1083  <xsl:text>{\small </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1084 </xsl:template>
1085
1086 <xsl:template match="footnote//typ[@class='attribute']">
1087  <xsl:text>{\scriptsize </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1088 </xsl:template>
1089
1090
1091 <!-- ==================== character elements ==================== -->
1092 <!--
1093
1094 These templates define the mapping between the character elements used in
1095 the Project Aon instances of Gamebook XML and the ISO-8859-1
1096 characters.
1097
1098 Portions Copyright International Organization for Standardization 1986 
1099 Permission to copy in any form is granted for use with conforming SGML 
1100 systems and applications as defined in ISO 8879, provided this notice 
1101 is included in all copies.
1102
1103 -->
1104
1105 <!-- JFS: TODO - probably the \definitions need to be in {} to prevent 
1106      issues if followed by text -->
1107
1108 <xsl:template match="ch.apos"><xsl:text>&#39;</xsl:text></xsl:template><!-- apostrophe = single quotation mark -->
1109 <xsl:template match="ch.nbsp"><xsl:text>~</xsl:text></xsl:template><!-- no-break space = non-breaking space, U+00A0 ISOnum -->
1110 <xsl:template match="ch.iexcl"><xsl:text>{\textexclamdown}</xsl:text></xsl:template><!-- inverted exclamation mark, U+00A1 ISOnum -->
1111 <xsl:template match="ch.cent"><xsl:text>\textcent</xsl:text></xsl:template><!-- cent sign, U+00A2 ISOnum -->
1112 <xsl:template match="ch.pound"><xsl:text>\pounds</xsl:text></xsl:template><!-- pound sign, U+00A3 ISOnum -->
1113 <xsl:template match="ch.curren"><xsl:text>\textcurrency</xsl:text></xsl:template><!-- currency sign, U+00A4 ISOnum -->
1114 <xsl:template match="ch.yen"><xsl:text>\textyen</xsl:text></xsl:template><!-- yen sign = yuan sign, U+00A5 ISOnum -->
1115 <xsl:template match="ch.brvbar"><xsl:text>\textbar</xsl:text></xsl:template><!-- broken bar = broken vertical bar, U+00A6 ISOnum -->
1116 <xsl:template match="ch.sect"><xsl:text>\textsection</xsl:text></xsl:template><!-- section sign, U+00A7 ISOnum -->
1117 <xsl:template match="ch.uml"><xsl:text>\ddot{}</xsl:text></xsl:template><!-- diaeresis = spacing diaeresis, U+00A8 ISOdia -->
1118 <xsl:template match="ch.copy"><xsl:text>\copyright</xsl:text></xsl:template><!-- copyright sign, U+00A9 ISOnum -->
1119 <xsl:template match="ch.ordf"><xsl:text>\textordfeminine</xsl:text></xsl:template><!-- feminine ordinal indicator, U+00AA ISOnum -->
1120 <xsl:template match="ch.laquo"><xsl:text>{\guillemotleft}</xsl:text></xsl:template><!-- left-pointing double angle quotation mark = left pointing guillemet, U+00AB ISOnum -->
1121 <xsl:template match="ch.not"><xsl:text>\textlnot</xsl:text></xsl:template><!-- not sign, U+00AC ISOnum -->
1122 <xsl:template match="ch.shy"><xsl:text>\-</xsl:text></xsl:template><!-- soft hyphen = discretionary hyphen, U+00AD ISOnum -->
1123 <xsl:template match="ch.reg"><xsl:text>{\texttrademark}</xsl:text></xsl:template><!-- registered sign = registered trade mark sign, U+00AE ISOnum -->
1124 <xsl:template match="ch.macr"><xsl:text>\textasciimacron</xsl:text></xsl:template><!-- macron = spacing macron = overline = APL overbar, U+00AF ISOdia -->
1125 <xsl:template match="ch.deg"><xsl:text>\textdegree</xsl:text></xsl:template><!-- degree sign, U+00B0 ISOnum -->
1126 <xsl:template match="ch.plusmn"><xsl:text>\textpm</xsl:text></xsl:template><!-- plus-minus sign = plus-or-minus sign, U+00B1 ISOnum -->
1127 <xsl:template match="ch.sup2"><xsl:text>^2</xsl:text></xsl:template><!-- superscript two = superscript digit two = squared, U+00B2 ISOnum -->
1128 <xsl:template match="ch.sup3"><xsl:text>^3</xsl:text></xsl:template><!-- superscript three = superscript digit three = cubed, U+00B3 ISOnum -->
1129 <xsl:template match="ch.acute"><xsl:text>\'</xsl:text></xsl:template><!-- acute accent = spacing acute, U+00B4 ISOdia -->
1130 <xsl:template match="ch.micro"><xsl:text>\textmu</xsl:text></xsl:template><!-- micro sign, U+00B5 ISOnum -->
1131 <xsl:template match="ch.para"><xsl:text>\textparagraph</xsl:text></xsl:template><!-- pilcrow sign  = paragraph sign, U+00B6 ISOnum -->
1132 <xsl:template match="ch.middot"><xsl:text>\textperiodcentered</xsl:text></xsl:template><!-- middle dot = Georgian comma = Greek middle dot, U+00B7 ISOnum -->
1133 <xsl:template match="ch.cedil"><xsl:text>\c{c}</xsl:text></xsl:template><!-- cedilla = spacing cedilla, U+00B8 ISOdia -->
1134 <xsl:template match="ch.sup1"><xsl:text>^1</xsl:text></xsl:template><!-- superscript one = superscript digit one, U+00B9 ISOnum -->
1135 <xsl:template match="ch.ordm"><xsl:text>\textordmasculine</xsl:text></xsl:template><!-- masculine ordinal indicator, U+00BA ISOnum -->
1136 <xsl:template match="ch.raquo"><xsl:text>{\guillemotright}</xsl:text></xsl:template><!-- right-pointing double angle quotation mark = right pointing guillemet, U+00BB ISOnum -->
1137 <xsl:template match="ch.frac14"><xsl:text>\frac{1}{4}</xsl:text></xsl:template><!-- vulgar fraction one quarter = fraction one quarter, U+00BC ISOnum -->
1138 <xsl:template match="ch.frac12"><xsl:text>\frac{1}{2}</xsl:text></xsl:template><!-- vulgar fraction one half = fraction one half, U+00BD ISOnum -->
1139 <xsl:template match="ch.frac34"><xsl:text>\frac{3}{4}</xsl:text></xsl:template><!-- vulgar fraction three quarters = fraction three quarters, U+00BE ISOnum -->
1140 <xsl:template match="ch.iquest"><xsl:text>{\textquestiondown}</xsl:text></xsl:template><!-- inverted question mark = turned question mark, U+00BF ISOnum -->
1141 <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 -->
1142 <xsl:template match="ch.Aacute"><xsl:text>&#193;</xsl:text></xsl:template><!-- latin capital letter A with acute, U+00C1 ISOlat1 -->
1143 <xsl:template match="ch.Acirc"><xsl:text>&#194;</xsl:text></xsl:template><!-- latin capital letter A with circumflex, U+00C2 ISOlat1 -->
1144 <xsl:template match="ch.Atilde"><xsl:text>&#195;</xsl:text></xsl:template><!-- latin capital letter A with tilde, U+00C3 ISOlat1 -->
1145 <xsl:template match="ch.Auml"><xsl:text>&#196;</xsl:text></xsl:template><!-- latin capital letter A with diaeresis, U+00C4 ISOlat1 -->
1146 <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 -->
1147 <xsl:template match="ch.AElig"><xsl:text>&#198;</xsl:text></xsl:template><!-- latin capital letter AE = latin capital ligature AE, U+00C6 ISOlat1 -->
1148 <xsl:template match="ch.Ccedil"><xsl:text>&#199;</xsl:text></xsl:template><!-- latin capital letter C with cedilla, U+00C7 ISOlat1 -->
1149 <xsl:template match="ch.Egrave"><xsl:text>&#200;</xsl:text></xsl:template><!-- latin capital letter E with grave, U+00C8 ISOlat1 -->
1150 <xsl:template match="ch.Eacute"><xsl:text>&#201;</xsl:text></xsl:template><!-- latin capital letter E with acute, U+00C9 ISOlat1 -->
1151 <xsl:template match="ch.Ecirc"><xsl:text>&#202;</xsl:text></xsl:template><!-- latin capital letter E with circumflex, U+00CA ISOlat1 -->
1152 <xsl:template match="ch.Euml"><xsl:text>&#203;</xsl:text></xsl:template><!-- latin capital letter E with diaeresis, U+00CB ISOlat1 -->
1153 <xsl:template match="ch.Igrave"><xsl:text>&#204;</xsl:text></xsl:template><!-- latin capital letter I with grave, U+00CC ISOlat1 -->
1154 <xsl:template match="ch.Iacute"><xsl:text>&#205;</xsl:text></xsl:template><!-- latin capital letter I with acute, U+00CD ISOlat1 -->
1155 <xsl:template match="ch.Icirc"><xsl:text>&#206;</xsl:text></xsl:template><!-- latin capital letter I with circumflex, U+00CE ISOlat1 -->
1156 <xsl:template match="ch.Iuml"><xsl:text>&#207;</xsl:text></xsl:template><!-- latin capital letter I with diaeresis, U+00CF ISOlat1 -->
1157 <xsl:template match="ch.ETH"><xsl:text>&#208;</xsl:text></xsl:template><!-- latin capital letter ETH, U+00D0 ISOlat1 -->
1158 <xsl:template match="ch.Ntilde"><xsl:text>&#209;</xsl:text></xsl:template><!-- latin capital letter N with tilde, U+00D1 ISOlat1 -->
1159 <xsl:template match="ch.Ograve"><xsl:text>&#210;</xsl:text></xsl:template><!-- latin capital letter O with grave, U+00D2 ISOlat1 -->
1160 <xsl:template match="ch.Oacute"><xsl:text>&#211;</xsl:text></xsl:template><!-- latin capital letter O with acute, U+00D3 ISOlat1 -->
1161 <xsl:template match="ch.Ocirc"><xsl:text>&#212;</xsl:text></xsl:template><!-- latin capital letter O with circumflex, U+00D4 ISOlat1 -->
1162 <xsl:template match="ch.Otilde"><xsl:text>&#213;</xsl:text></xsl:template><!-- latin capital letter O with tilde, U+00D5 ISOlat1 -->
1163 <xsl:template match="ch.Ouml"><xsl:text>&#214;</xsl:text></xsl:template><!-- latin capital letter O with diaeresis, U+00D6 ISOlat1 -->
1164 <xsl:template match="ch.times"><xsl:text>&#215;</xsl:text></xsl:template><!-- multiplication sign, U+00D7 ISOnum -->
1165 <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 -->
1166 <xsl:template match="ch.Ugrave"><xsl:text>&#217;</xsl:text></xsl:template><!-- latin capital letter U with grave, U+00D9 ISOlat1 -->
1167 <xsl:template match="ch.Uacute"><xsl:text>&#218;</xsl:text></xsl:template><!-- latin capital letter U with acute, U+00DA ISOlat1 -->
1168 <xsl:template match="ch.Ucirc"><xsl:text>&#219;</xsl:text></xsl:template><!-- latin capital letter U with circumflex, U+00DB ISOlat1 -->
1169 <xsl:template match="ch.Uuml"><xsl:text>&#220;</xsl:text></xsl:template><!-- latin capital letter U with diaeresis, U+00DC ISOlat1 -->
1170 <xsl:template match="ch.Yacute"><xsl:text>&#221;</xsl:text></xsl:template><!-- latin capital letter Y with acute, U+00DD ISOlat1 -->
1171 <xsl:template match="ch.THORN"><xsl:text>&#222;</xsl:text></xsl:template><!-- latin capital letter THORN, U+00DE ISOlat1 -->
1172 <xsl:template match="ch.szlig"><xsl:text>&#223;</xsl:text></xsl:template><!-- latin small letter sharp s = ess-zed, U+00DF ISOlat1 -->
1173 <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 -->
1174 <xsl:template match="ch.aacute"><xsl:text>&#225;</xsl:text></xsl:template><!-- latin small letter a with acute, U+00E1 ISOlat1 -->
1175 <xsl:template match="ch.acirc"><xsl:text>&#226;</xsl:text></xsl:template><!-- latin small letter a with circumflex, U+00E2 ISOlat1 -->
1176 <xsl:template match="ch.atilde"><xsl:text>&#227;</xsl:text></xsl:template><!-- latin small letter a with tilde, U+00E3 ISOlat1 -->
1177 <xsl:template match="ch.auml"><xsl:text>&#228;</xsl:text></xsl:template><!-- latin small letter a with diaeresis, U+00E4 ISOlat1 -->
1178 <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 -->
1179 <xsl:template match="ch.aelig"><xsl:text>&#230;</xsl:text></xsl:template><!-- latin small letter ae = latin small ligature ae, U+00E6 ISOlat1 -->
1180 <xsl:template match="ch.ccedil"><xsl:text>&#231;</xsl:text></xsl:template><!-- latin small letter c with cedilla, U+00E7 ISOlat1 -->
1181 <xsl:template match="ch.egrave"><xsl:text>&#232;</xsl:text></xsl:template><!-- latin small letter e with grave, U+00E8 ISOlat1 -->
1182 <xsl:template match="ch.eacute"><xsl:text>&#233;</xsl:text></xsl:template><!-- latin small letter e with acute, U+00E9 ISOlat1 -->
1183 <xsl:template match="ch.ecirc"><xsl:text>&#234;</xsl:text></xsl:template><!-- latin small letter e with circumflex, U+00EA ISOlat1 -->
1184 <xsl:template match="ch.euml"><xsl:text>&#235;</xsl:text></xsl:template><!-- latin small letter e with diaeresis, U+00EB ISOlat1 -->
1185 <xsl:template match="ch.igrave"><xsl:text>&#236;</xsl:text></xsl:template><!-- latin small letter i with grave, U+00EC ISOlat1 -->
1186 <xsl:template match="ch.iacute"><xsl:text>&#237;</xsl:text></xsl:template><!-- latin small letter i with acute, U+00ED ISOlat1 -->
1187 <xsl:template match="ch.icirc"><xsl:text>&#238;</xsl:text></xsl:template><!-- latin small letter i with circumflex, U+00EE ISOlat1 -->
1188 <xsl:template match="ch.iuml"><xsl:text>&#239;</xsl:text></xsl:template><!-- latin small letter i with diaeresis, U+00EF ISOlat1 -->
1189 <xsl:template match="ch.eth"><xsl:text>&#240;</xsl:text></xsl:template><!-- latin small letter eth, U+00F0 ISOlat1 -->
1190 <xsl:template match="ch.ntilde"><xsl:text>&#241;</xsl:text></xsl:template><!-- latin small letter n with tilde, U+00F1 ISOlat1 -->
1191 <xsl:template match="ch.ograve"><xsl:text>&#242;</xsl:text></xsl:template><!-- latin small letter o with grave, U+00F2 ISOlat1 -->
1192 <xsl:template match="ch.oacute"><xsl:text>&#243;</xsl:text></xsl:template><!-- latin small letter o with acute, U+00F3 ISOlat1 -->
1193 <xsl:template match="ch.ocirc"><xsl:text>&#244;</xsl:text></xsl:template><!-- latin small letter o with circumflex, U+00F4 ISOlat1 -->
1194 <xsl:template match="ch.otilde"><xsl:text>&#245;</xsl:text></xsl:template><!-- latin small letter o with tilde, U+00F5 ISOlat1 -->
1195 <xsl:template match="ch.ouml"><xsl:text>&#246;</xsl:text></xsl:template><!-- latin small letter o with diaeresis, U+00F6 ISOlat1 -->
1196 <xsl:template match="ch.divide"><xsl:text>&#247;</xsl:text></xsl:template><!-- division sign, U+00F7 ISOnum -->
1197 <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 -->
1198 <xsl:template match="ch.ugrave"><xsl:text>&#249;</xsl:text></xsl:template><!-- latin small letter u with grave, U+00F9 ISOlat1 -->
1199 <xsl:template match="ch.uacute"><xsl:text>&#250;</xsl:text></xsl:template><!-- latin small letter u with acute, U+00FA ISOlat1 -->
1200 <xsl:template match="ch.ucirc"><xsl:text>&#251;</xsl:text></xsl:template><!-- latin small letter u with circumflex, U+00FB ISOlat1 -->
1201 <xsl:template match="ch.uuml"><xsl:text>&#252;</xsl:text></xsl:template><!-- latin small letter u with diaeresis, U+00FC ISOlat1 -->
1202 <xsl:template match="ch.yacute"><xsl:text>&#253;</xsl:text></xsl:template><!-- latin small letter y with acute, U+00FD ISOlat1 -->
1203 <xsl:template match="ch.thorn"><xsl:text>&#254;</xsl:text></xsl:template><!-- latin small letter thorn, U+00FE ISOlat1 -->
1204 <xsl:template match="ch.yuml"><xsl:text>&#255;</xsl:text></xsl:template><!-- latin small letter y with diaeresis, U+00FF ISOlat1 -->
1205
1206 <!-- ~~~~~~~~~~~~~~~~~~~~~ Special Characters ~~~~~~~~~~~~~~~~~~~~ -->
1207
1208 <xsl:template match="ch.ampersand">\&amp;</xsl:template><!-- ampersand -->
1209 <xsl:template match="ch.lsquot">\textquoteleft</xsl:template><!-- opening left quotation mark -->
1210 <xsl:template match="ch.rsquot">\textquoteright</xsl:template><!-- closing right quotation mark -->
1211 <xsl:template match="ch.ldquot">``</xsl:template><!-- opening left double quotation mark -->
1212 <xsl:template match="ch.rdquot">''</xsl:template><!-- closing right double quotation mark -->
1213 <xsl:template match="ch.minus">\-</xsl:template><!-- mathematical minus -->
1214 <xsl:template match="ch.emdash">\-</xsl:template><!-- emdash -->
1215 <xsl:template match="ch.ellips">&nbsp;\ldots </xsl:template><!-- ellipsis -->
1216 <xsl:template match="ch.lellips">\ldots&nbsp; </xsl:template><!-- left ellipsis, used at the beginning of edited material -->
1217 <xsl:template match="ch.blankline">\_\_\_\_\_\_\_</xsl:template><!-- blank line to be filled in -->
1218 <xsl:template match="ch.percent"><xsl:text>\%</xsl:text></xsl:template><!-- percent sign -->
1219 <xsl:template match="ch.thinspace"><xsl:text>\ </xsl:text></xsl:template><!-- small horizontal space for use between adjacent quotation marks - added mainly for LaTeX's sake -->
1220 <xsl:template match="ch.frac116"><xsl:text>1/16</xsl:text></xsl:template><!-- vulgar fraction one sixteenth = fraction on sixteenth -->
1221 <xsl:template match="ch.plus"><xsl:text>+</xsl:text></xsl:template><!-- mathematical plus -->
1222
1223 <!-- ==================== named templates ======================= -->
1224
1225 <!--
1226  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.
1227 -->
1228 <xsl:template name="section-title-link">
1229  <!-- will the list always contain the closest ancestor first? -->
1230  <xsl:variable name="section-title">
1231   <!-- numbered or not? -->
1232   <xsl:if test="ancestor::section[position()=1]/@class='numbered'">
1233    <xsl:choose>
1234     <xsl:when test="$language='es'">
1235      <xsl:text>Secci&oacute;n </xsl:text>
1236     </xsl:when>
1237     <xsl:otherwise>
1238      <xsl:text>Section </xsl:text>
1239     </xsl:otherwise>
1240    </xsl:choose>
1241   </xsl:if>
1242   <xsl:apply-templates select="ancestor::section[position()=1]/meta/title[1]" />
1243  </xsl:variable>
1244  
1245  <a>
1246   <xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="ancestor::section[position()=1]/@id" /></xsl:attribute>
1247   <xsl:value-of select="$section-title" />
1248  </a>
1249 </xsl:template>
1250
1251 </xsl:transform>