[projectaon] Update to the Latex.xsl file (PDF generation of the books)

  • From: Javier Fernández-Sanguino Peña <jfs@xxxxxxxxxxxx>
  • To: projectaon@xxxxxxxxxxxxx
  • Date: Sun, 26 Nov 2006 23:47:19 +0100

Hi all,

Attached is an update to the latex.xsl file including the new entities being
used in the XML file as well as the changes necessary to provide translations
for different languages (english and spanish currently being supported).

It took me a while to review the different characters and have them changed
into the LaTeX equivalents. Thankfully I found
http://www.bitjungle.com/isoent/ which made it easier to me to find the
equivalances.

I've also made some changes to the gbtolatex.pl file (attached)

Finally, I have also automated (through some scripts and Makefiles) the
generation process of PDF files which now works flawlessly (there is no need
to tweak the .TeX files if using this XLS) at least for what I've tried for
the Spanish edition of books LW  #1, #2, #3 and #4 and the English edition of
LW #1. I can provide a working building environment (as well as the steps
that need to be taken care of the regeneration of a new book) for those
interested.

Could I get access to the CVS server to make these changes directly there? I
would also like to review the version log of the XLS files to see if I've
missed some items that need to be added to the LaTeX XLS file for
compatibility with new editions.

Thanks

Javiers
--- latex.xsl.orig      2006-11-26 20:22:58.000000000 +0100
+++ latex.xsl   2006-11-26 23:31:45.000000000 +0100
@@ -40,6 +40,7 @@
 
 <xsl:param name="title-color"><xsl:text>0.0,0.0,0.0</xsl:text></xsl:param>
 <xsl:param name="use-illustrators" />
+<xsl:param name="language"><xsl:text>en</xsl:text></xsl:param>
 
 <!-- ======================= variables ========================== -->
 
@@ -63,18 +64,42 @@
 
 <xsl:template match="/gamebook/section[@id='title']">
 
+<xsl:choose>
+<xsl:when test="$language='es'">
+    <xsl:text>
+%% Two-sided %%
+%\documentclass[letterpaper,12pt,twoside]{book}
+% For european books:
+\documentclass[a4paper,12pt,twoside]{book}
+    </xsl:text>
+</xsl:when>
+<xsl:otherwise>
 <xsl:text>
 %% Two-sided %%
 \documentclass[letterpaper,12pt,twoside]{book}
+% For european books:
 %\documentclass[a4paper,12pt,twoside]{book}
+</xsl:text>
+</xsl:otherwise>
+</xsl:choose>
 
+<xsl:text>
 %% One-sided %%
 %\documentclass[letterpaper,12pt,oneside]{book}
 %\documentclass[a4paper,12pt,oneside]{book}
 
  \usepackage[pdftex]{graphicx}
  \usepackage{ifthen}
-
+</xsl:text>
+<xsl:choose>
+<xsl:when test="$language='es'">
+    <xsl:text>
+% Use this if you are compiling spanish PDFs:
+\usepackage[spanish]{babel}
+    </xsl:text>
+</xsl:when>
+</xsl:choose>
+<xsl:text>
  %% color info %%
  \usepackage{color}
  \definecolor{titlecolor}{rgb}{</xsl:text><xsl:value-of select="$title-color" 
/><xsl:text>}
@@ -91,10 +116,10 @@
  {%% Two-sided %%
   \fancyhead[CO]{\iffloatpage{}{</xsl:text><xsl:value-of 
select="/gamebook/meta/creator[@class='short']" /><xsl:text>}}
   \fancyhead[CE]{\iffloatpage{}{\bfseries </xsl:text><xsl:value-of 
select="/gamebook/meta/title[1]" /><xsl:text>}}
-  \fancyhead[LO,RE]{\iffloatpage{}{\thepage}}}%
+  \fancyhead[LO,RE]{\iffloatpage{}{\thepage}}}
  {%% One-sided %%
-  %\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>}}}
-  %\fancyhead[R]{\iffloatpage{}{\thepage}}}
+  \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>}}}
+  \fancyhead[R]{\iffloatpage{}{\thepage}}}
  \renewcommand{\headrulewidth}{\iffloatpage{0pt}{0.4pt}}
 
  \fancypagestyle{plain}{
@@ -125,7 +150,9 @@
 
  %% TrueType font %%
  \usepackage[T1]{fontenc}
- \usepackage{souvenir}
+ % NOTE: This font might not ve available. Uncomment if you have it configured
+ % for your LaTeX fonts:
+ %\usepackage{souvenir}
  %\renewcommand{\rmdefault}{souvnrttf}
 
  \raggedbottom
@@ -159,52 +186,94 @@
 
  </xsl:text>
  <xsl:apply-templates 
select="/gamebook/meta/rights[@class='license-notification']" />
- <xsl:text>
 
- Publication Date: </xsl:text>
- <xsl:value-of select="/gamebook/meta/date[@class='publication']/day" />
- <xsl:text> </xsl:text>
- <xsl:choose>
-  <xsl:when test="/gamebook/meta/date[@class='publication']/month = 1">
-   <xsl:text>January</xsl:text>
-  </xsl:when>
-  <xsl:when test="/gamebook/meta/date[@class='publication']/month = 2">
-   <xsl:text>February</xsl:text>
-  </xsl:when>
-  <xsl:when test="/gamebook/meta/date[@class='publication']/month = 3">
-   <xsl:text>March</xsl:text>
-  </xsl:when>
-  <xsl:when test="/gamebook/meta/date[@class='publication']/month = 4">
-   <xsl:text>April</xsl:text>
-  </xsl:when>
-  <xsl:when test="/gamebook/meta/date[@class='publication']/month = 5">
-   <xsl:text>May</xsl:text>
-  </xsl:when>
-  <xsl:when test="/gamebook/meta/date[@class='publication']/month = 6">
-   <xsl:text>June</xsl:text>
-  </xsl:when>
-  <xsl:when test="/gamebook/meta/date[@class='publication']/month = 7">
-   <xsl:text>July</xsl:text>
-  </xsl:when>
-  <xsl:when test="/gamebook/meta/date[@class='publication']/month = 8">
-   <xsl:text>August</xsl:text>
-  </xsl:when>
-  <xsl:when test="/gamebook/meta/date[@class='publication']/month = 9">
-   <xsl:text>September</xsl:text>
-  </xsl:when>
-  <xsl:when test="/gamebook/meta/date[@class='publication']/month = 10">
-   <xsl:text>October</xsl:text>
-  </xsl:when>
-  <xsl:when test="/gamebook/meta/date[@class='publication']/month = 11">
-   <xsl:text>November</xsl:text>
-  </xsl:when>
-  <xsl:when test="/gamebook/meta/date[@class='publication']/month = 12">
-   <xsl:text>December</xsl:text>
-  </xsl:when>
-  <xsl:otherwise>
-   <xsl:text>Invalid Month</xsl:text>
-  </xsl:otherwise>
- </xsl:choose>
+   <xsl:choose>
+    <xsl:when test="$language='es'">
+     <xsl:text>Fecha de Publicaci&oacute;n: </xsl:text>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:text>Publication Date: </xsl:text>
+    </xsl:otherwise>
+   </xsl:choose>
+   <xsl:value-of select="/gamebook/meta/date[@class='publication']/day" />
+   <xsl:text> </xsl:text>
+   <xsl:choose>
+    <xsl:when test="/gamebook/meta/date[@class='publication']/month = 1">
+     <xsl:choose>
+      <xsl:when test="$language='es'"><xsl:text>de enero 
de</xsl:text></xsl:when>
+      <xsl:otherwise><xsl:text>January</xsl:text></xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:when test="/gamebook/meta/date[@class='publication']/month = 2">
+     <xsl:choose>
+      <xsl:when test="$language='es'"><xsl:text>de febrero 
de</xsl:text></xsl:when>
+      <xsl:otherwise><xsl:text>February</xsl:text></xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:when test="/gamebook/meta/date[@class='publication']/month = 3">
+     <xsl:choose>
+      <xsl:when test="$language='es'"><xsl:text>de marzo 
de</xsl:text></xsl:when>
+      <xsl:otherwise><xsl:text>March</xsl:text></xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:when test="/gamebook/meta/date[@class='publication']/month = 4">
+     <xsl:choose>
+      <xsl:when test="$language='es'"><xsl:text>de abril 
de</xsl:text></xsl:when>
+      <xsl:otherwise><xsl:text>April</xsl:text></xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:when test="/gamebook/meta/date[@class='publication']/month = 5">
+     <xsl:choose>
+      <xsl:when test="$language='es'"><xsl:text>de mayo 
de</xsl:text></xsl:when>
+      <xsl:otherwise><xsl:text>May</xsl:text></xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:when test="/gamebook/meta/date[@class='publication']/month = 6">
+     <xsl:choose>
+      <xsl:when test="$language='es'"><xsl:text>de junio 
de</xsl:text></xsl:when>
+      <xsl:otherwise><xsl:text>June</xsl:text></xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:when test="/gamebook/meta/date[@class='publication']/month = 7">
+     <xsl:choose>
+      <xsl:when test="$language='es'"><xsl:text>de julio 
de</xsl:text></xsl:when>
+      <xsl:otherwise><xsl:text>July</xsl:text></xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:when test="/gamebook/meta/date[@class='publication']/month = 8">
+     <xsl:choose>
+      <xsl:when test="$language='es'"><xsl:text>de agosto 
de</xsl:text></xsl:when>
+      <xsl:otherwise><xsl:text>August</xsl:text></xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:when test="/gamebook/meta/date[@class='publication']/month = 9">
+     <xsl:choose>
+      <xsl:when test="$language='es'"><xsl:text>de septiembre 
de</xsl:text></xsl:when>
+      <xsl:otherwise><xsl:text>September</xsl:text></xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:when test="/gamebook/meta/date[@class='publication']/month = 10">
+     <xsl:choose>
+      <xsl:when test="$language='es'"><xsl:text>de octubre 
de</xsl:text></xsl:when>
+      <xsl:otherwise><xsl:text>October</xsl:text></xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:when test="/gamebook/meta/date[@class='publication']/month = 11">
+     <xsl:choose>
+      <xsl:when test="$language='es'"><xsl:text>de noviembre 
de</xsl:text></xsl:when>
+      <xsl:otherwise><xsl:text>November</xsl:text></xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:when test="/gamebook/meta/date[@class='publication']/month = 12">
+     <xsl:choose>
+      <xsl:when test="$language='es'"><xsl:text>de diciembre 
de</xsl:text></xsl:when>
+      <xsl:otherwise><xsl:text>December</xsl:text></xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:text>Invalid Month</xsl:text>
+    </xsl:otherwise>
+   </xsl:choose>
  <xsl:text> </xsl:text>
  <xsl:value-of select="/gamebook/meta/date[@class='publication']/year" />
  <xsl:text>
@@ -458,14 +527,15 @@
   <xsl:text>\newcommand{\aonmarks}{
     \ifthenelse{\equal{\leftmark}{\rightmark}}
       {\rightmark}
-      {\rightmark{} - \leftmark}}
+      {\rightmark{} - \leftmark}
   \ifthenelse{\boolean{@twoside}}%
    {%% Two-sided %%
     \fancyhead[RO,LE]{\iffloatpage{}{\large{\bfseries \aonmarks}}}
     \fancyhead[LO,RE]{\iffloatpage{}{\thepage}}}
    {%% One-sided %%
-    %\fancyhead[R]{\iffloatpage{}{\large{\bfseries \aonmarks}}}
-    %\fancyhead[L]{\iffloatpage{}{\thepage}}}</xsl:text> <xsl:value-of 
select="$newparagraph" />
+    \fancyhead[R]{\iffloatpage{}{\large{\bfseries \aonmarks}}}
+    \fancyhead[L]{\iffloatpage{}{\thepage}}}
+    }</xsl:text> <xsl:value-of select="$newparagraph" />
  </xsl:if>
 
  <xsl:if test="not( self::node()[@id='numbered'] )">
@@ -505,7 +575,14 @@
 <xsl:for-each select="data/illustration[@class='float' and contains( 
$use-illustrators, concat( ':', meta/creator, ':' ) )]">
  <xsl:text>\hspace*{\fill} \mbox{\itshape \hyperlink{ill</xsl:text>
  <xsl:number count="illustration[@class='float' and contains( 
$use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" 
format="1" />
+       <xsl:choose>
+        <xsl:when test="$language='es'">
+ <xsl:text>}{Ilustraci&oacute;n </xsl:text>
+        </xsl:when>
+        <xsl:otherwise>
  <xsl:text>}{Illustration </xsl:text>
+        </xsl:otherwise>
+       </xsl:choose>
  <xsl:number count="illustration[@class='float' and contains( 
$use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" 
format="I" />
  <xsl:text>}}\hspace*{\fill}\\*[\parskip]</xsl:text>
 </xsl:for-each>
@@ -602,7 +679,7 @@
   <xsl:for-each select="data/illustration[contains( $use-illustrators, concat( 
':', meta/creator, ':' ) ) ]">
    <xsl:variable name="illustration-src" select="instance[@class='pdf']/@src" 
/>
 
-   <xsl:text>\hypertarget{map}{~}</xsl:text>
+   <xsl:text>\hypertarget{map}{map}</xsl:text>
    <xsl:value-of select="$newline" />
    <xsl:text>\addcontentsline{toc}{section}{\protect\numberline{}{</xsl:text>
     <xsl:value-of select="$map-title" />
@@ -720,22 +797,57 @@
   <xsl:apply-templates select="enemy" />
   <xsl:choose>
    <xsl:when test="enemy-attribute[@class='combatskill']">
-    <xsl:text>: {\small COMBAT~SKILL}~</xsl:text>
+     <xsl:choose>
+      <xsl:when test="$language='es'">
+       <xsl:text>: {\small DESTREZA~EN~EL~COMBATE}~</xsl:text>
+      </xsl:when>
+      <xsl:otherwise>
+       <xsl:text>: {\small COMBAT~SKILL}~</xsl:text>
+      </xsl:otherwise>
+     </xsl:choose>
     <xsl:value-of select="enemy-attribute[@class='combatskill']" />
    </xsl:when>
    <xsl:when test="enemy-attribute[@class='closecombatskill']">
-    <xsl:text>: {\small CLOSE~COMBAT~SKILL}~</xsl:text>
+     <xsl:choose>
+      <xsl:when test="$language='es'">
+       <xsl:text>: {\small DESTREZA~EN~EL~COMBATE~DE~PROXIMIDAD}~</xsl:text>
+      </xsl:when>
+      <xsl:otherwise>
+       <xsl:text>: {\small CLOSE~COMBAT~SKILL}~</xsl:text>
+      </xsl:otherwise>
+     </xsl:choose>
     <xsl:value-of select="enemy-attribute[@class='closecombatskill']" />
    </xsl:when>
   </xsl:choose>
-  <xsl:text> ~~{\small ENDURANCE}~</xsl:text>
+    <xsl:choose>
+     <xsl:when test="$language='es'">
+      <xsl:text> ~~{\small RESISTENCIA}~</xsl:text>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:text> ~~{\small ENDURANCE}~</xsl:text>
+    </xsl:otherwise>
+   </xsl:choose>
   <xsl:choose>
    <xsl:when test="enemy-attribute[@class='target']">
-    <xsl:text>~({\small TARGET}~points)~</xsl:text>
+    <xsl:choose>
+     <xsl:when test="$language='es'">
+      <xsl:text>~(puntos~de~{\small OBJETIVO})~</xsl:text>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:text>~({\small TARGET}~points)~</xsl:text>
+    </xsl:otherwise>
+   </xsl:choose>
     <xsl:value-of select="enemy-attribute[@class='target']" />
    </xsl:when>
    <xsl:when test="enemy-attribute[@class='resistance']">
-    <xsl:text>~({\small RESISTANCE}~points)~</xsl:text>
+    <xsl:choose>
+     <xsl:when test="$language='es'">
+      <xsl:text>~(puntos~de~{\small RESISTENCIA})~</xsl:text>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:text>~({\small RESISTANCE}~points)~</xsl:text>
+    </xsl:otherwise>
+   </xsl:choose>
     <xsl:value-of select="enemy-attribute[@class='resistance']" />
    </xsl:when>
    <xsl:otherwise>
@@ -808,7 +920,14 @@
     <xsl:value-of select="$newline" />
     <xsl:text>\\ \mbox{ \hypertarget{ill</xsl:text>
      <xsl:number count="illustration[@class='float' and contains( 
$use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" 
format="1" />
-    <xsl:text>}{Illustration </xsl:text>
+       <xsl:choose>
+        <xsl:when test="$language='es'">
+            <xsl:text>}{Ilustraci&oacute;n </xsl:text>
+        </xsl:when>
+        <xsl:otherwise>
+           <xsl:text>}{Illustration </xsl:text>
+        </xsl:otherwise>
+       </xsl:choose>
      <xsl:number count="illustration[@class='float' and contains( 
$use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" 
format="I" />
     <xsl:text>}}\\[1em]{\itshape </xsl:text>
     <xsl:apply-templates select="meta/description" />
@@ -960,4 +1079,162 @@
  <xsl:text>{\scriptsize </xsl:text><xsl:apply-templates 
/><xsl:text>}</xsl:text>
 </xsl:template>
 
+
+<!-- ==================== character elements ==================== -->
+<!--
+
+These templates define the mapping between the character elements used in
+the Project Aon instances of Gamebook XML and the ISO-8859-1
+characters.
+
+Portions Copyright International Organization for Standardization 1986 
+Permission to copy in any form is granted for use with conforming SGML 
+systems and applications as defined in ISO 8879, provided this notice 
+is included in all copies.
+
+-->
+
+<xsl:template match="ch.apos"><xsl:text>&#39;</xsl:text></xsl:template><!-- 
apostrophe = single quotation mark -->
+<xsl:template match="ch.nbsp"><xsl:text>&#160;</xsl:text></xsl:template><!-- 
no-break space = non-breaking space, U+00A0 ISOnum -->
+<xsl:template match="ch.iexcl"><xsl:text>&#161;</xsl:text></xsl:template><!-- 
inverted exclamation mark, U+00A1 ISOnum -->
+<xsl:template match="ch.cent"><xsl:text>&#162;</xsl:text></xsl:template><!-- 
cent sign, U+00A2 ISOnum -->
+<xsl:template match="ch.pound"><xsl:text>&#163;</xsl:text></xsl:template><!-- 
pound sign, U+00A3 ISOnum -->
+<xsl:template match="ch.curren"><xsl:text>&#164;</xsl:text></xsl:template><!-- 
currency sign, U+00A4 ISOnum -->
+<xsl:template match="ch.yen"><xsl:text>&#165;</xsl:text></xsl:template><!-- 
yen sign = yuan sign, U+00A5 ISOnum -->
+<xsl:template match="ch.brvbar"><xsl:text>&#166;</xsl:text></xsl:template><!-- 
broken bar = broken vertical bar, U+00A6 ISOnum -->
+<xsl:template match="ch.sect"><xsl:text>&#167;</xsl:text></xsl:template><!-- 
section sign, U+00A7 ISOnum -->
+<xsl:template match="ch.uml"><xsl:text>&#168;</xsl:text></xsl:template><!-- 
diaeresis = spacing diaeresis, U+00A8 ISOdia -->
+<xsl:template 
match="ch.copy"><xsl:text>\copyright</xsl:text></xsl:template><!-- copyright 
sign, U+00A9 ISOnum -->
+<xsl:template match="ch.ordf"><xsl:text>&#170;</xsl:text></xsl:template><!-- 
feminine ordinal indicator, U+00AA ISOnum -->
+<xsl:template match="ch.laquo"><xsl:text>&#171;</xsl:text></xsl:template><!-- 
left-pointing double angle quotation mark = left pointing guillemet, U+00AB 
ISOnum -->
+<xsl:template match="ch.not"><xsl:text>&#172;</xsl:text></xsl:template><!-- 
not sign, U+00AC ISOnum -->
+<xsl:template match="ch.shy"><xsl:text>&#173;</xsl:text></xsl:template><!-- 
soft hyphen = discretionary hyphen, U+00AD ISOnum -->
+<xsl:template match="ch.reg"><xsl:text>&#174;</xsl:text></xsl:template><!-- 
registered sign = registered trade mark sign, U+00AE ISOnum -->
+<xsl:template match="ch.macr"><xsl:text>&#175;</xsl:text></xsl:template><!-- 
macron = spacing macron = overline = APL overbar, U+00AF ISOdia -->
+<xsl:template match="ch.deg"><xsl:text>&#176;</xsl:text></xsl:template><!-- 
degree sign, U+00B0 ISOnum -->
+<xsl:template match="ch.plusmn"><xsl:text>&#177;</xsl:text></xsl:template><!-- 
plus-minus sign = plus-or-minus sign, U+00B1 ISOnum -->
+<xsl:template match="ch.sup2"><xsl:text>&#178;</xsl:text></xsl:template><!-- 
superscript two = superscript digit two = squared, U+00B2 ISOnum -->
+<xsl:template match="ch.sup3"><xsl:text>&#179;</xsl:text></xsl:template><!-- 
superscript three = superscript digit three = cubed, U+00B3 ISOnum -->
+<xsl:template match="ch.acute"><xsl:text>&#180;</xsl:text></xsl:template><!-- 
acute accent = spacing acute, U+00B4 ISOdia -->
+<xsl:template match="ch.micro"><xsl:text>&#181;</xsl:text></xsl:template><!-- 
micro sign, U+00B5 ISOnum -->
+<xsl:template match="ch.para"><xsl:text>&#182;</xsl:text></xsl:template><!-- 
pilcrow sign  = paragraph sign, U+00B6 ISOnum -->
+<xsl:template match="ch.middot"><xsl:text>&#183;</xsl:text></xsl:template><!-- 
middle dot = Georgian comma = Greek middle dot, U+00B7 ISOnum -->
+<xsl:template match="ch.cedil"><xsl:text>&#184;</xsl:text></xsl:template><!-- 
cedilla = spacing cedilla, U+00B8 ISOdia -->
+<xsl:template match="ch.sup1"><xsl:text>&#185;</xsl:text></xsl:template><!-- 
superscript one = superscript digit one, U+00B9 ISOnum -->
+<xsl:template match="ch.ordm"><xsl:text>&#186;</xsl:text></xsl:template><!-- 
masculine ordinal indicator, U+00BA ISOnum -->
+<xsl:template match="ch.raquo"><xsl:text>&#187;</xsl:text></xsl:template><!-- 
right-pointing double angle quotation mark = right pointing guillemet, U+00BB 
ISOnum -->
+<xsl:template match="ch.frac14"><xsl:text>&#188;</xsl:text></xsl:template><!-- 
vulgar fraction one quarter = fraction one quarter, U+00BC ISOnum -->
+<xsl:template match="ch.frac12"><xsl:text>&#189;</xsl:text></xsl:template><!-- 
vulgar fraction one half = fraction one half, U+00BD ISOnum -->
+<xsl:template match="ch.frac34"><xsl:text>&#190;</xsl:text></xsl:template><!-- 
vulgar fraction three quarters = fraction three quarters, U+00BE ISOnum -->
+<xsl:template match="ch.iquest"><xsl:text>&#191;</xsl:text></xsl:template><!-- 
inverted question mark = turned question mark, U+00BF ISOnum -->
+<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 -->
+<xsl:template match="ch.Aacute"><xsl:text>&#193;</xsl:text></xsl:template><!-- 
latin capital letter A with acute, U+00C1 ISOlat1 -->
+<xsl:template match="ch.Acirc"><xsl:text>&#194;</xsl:text></xsl:template><!-- 
latin capital letter A with circumflex, U+00C2 ISOlat1 -->
+<xsl:template match="ch.Atilde"><xsl:text>&#195;</xsl:text></xsl:template><!-- 
latin capital letter A with tilde, U+00C3 ISOlat1 -->
+<xsl:template match="ch.Auml"><xsl:text>&#196;</xsl:text></xsl:template><!-- 
latin capital letter A with diaeresis, U+00C4 ISOlat1 -->
+<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 -->
+<xsl:template match="ch.AElig"><xsl:text>&#198;</xsl:text></xsl:template><!-- 
latin capital letter AE = latin capital ligature AE, U+00C6 ISOlat1 -->
+<xsl:template match="ch.Ccedil"><xsl:text>&#199;</xsl:text></xsl:template><!-- 
latin capital letter C with cedilla, U+00C7 ISOlat1 -->
+<xsl:template match="ch.Egrave"><xsl:text>&#200;</xsl:text></xsl:template><!-- 
latin capital letter E with grave, U+00C8 ISOlat1 -->
+<xsl:template match="ch.Eacute"><xsl:text>&#201;</xsl:text></xsl:template><!-- 
latin capital letter E with acute, U+00C9 ISOlat1 -->
+<xsl:template match="ch.Ecirc"><xsl:text>&#202;</xsl:text></xsl:template><!-- 
latin capital letter E with circumflex, U+00CA ISOlat1 -->
+<xsl:template match="ch.Euml"><xsl:text>&#203;</xsl:text></xsl:template><!-- 
latin capital letter E with diaeresis, U+00CB ISOlat1 -->
+<xsl:template match="ch.Igrave"><xsl:text>&#204;</xsl:text></xsl:template><!-- 
latin capital letter I with grave, U+00CC ISOlat1 -->
+<xsl:template match="ch.Iacute"><xsl:text>&#205;</xsl:text></xsl:template><!-- 
latin capital letter I with acute, U+00CD ISOlat1 -->
+<xsl:template match="ch.Icirc"><xsl:text>&#206;</xsl:text></xsl:template><!-- 
latin capital letter I with circumflex, U+00CE ISOlat1 -->
+<xsl:template match="ch.Iuml"><xsl:text>&#207;</xsl:text></xsl:template><!-- 
latin capital letter I with diaeresis, U+00CF ISOlat1 -->
+<xsl:template match="ch.ETH"><xsl:text>&#208;</xsl:text></xsl:template><!-- 
latin capital letter ETH, U+00D0 ISOlat1 -->
+<xsl:template match="ch.Ntilde"><xsl:text>&#209;</xsl:text></xsl:template><!-- 
latin capital letter N with tilde, U+00D1 ISOlat1 -->
+<xsl:template match="ch.Ograve"><xsl:text>&#210;</xsl:text></xsl:template><!-- 
latin capital letter O with grave, U+00D2 ISOlat1 -->
+<xsl:template match="ch.Oacute"><xsl:text>&#211;</xsl:text></xsl:template><!-- 
latin capital letter O with acute, U+00D3 ISOlat1 -->
+<xsl:template match="ch.Ocirc"><xsl:text>&#212;</xsl:text></xsl:template><!-- 
latin capital letter O with circumflex, U+00D4 ISOlat1 -->
+<xsl:template match="ch.Otilde"><xsl:text>&#213;</xsl:text></xsl:template><!-- 
latin capital letter O with tilde, U+00D5 ISOlat1 -->
+<xsl:template match="ch.Ouml"><xsl:text>&#214;</xsl:text></xsl:template><!-- 
latin capital letter O with diaeresis, U+00D6 ISOlat1 -->
+<xsl:template match="ch.times"><xsl:text>&#215;</xsl:text></xsl:template><!-- 
multiplication sign, U+00D7 ISOnum -->
+<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 -->
+<xsl:template match="ch.Ugrave"><xsl:text>&#217;</xsl:text></xsl:template><!-- 
latin capital letter U with grave, U+00D9 ISOlat1 -->
+<xsl:template match="ch.Uacute"><xsl:text>&#218;</xsl:text></xsl:template><!-- 
latin capital letter U with acute, U+00DA ISOlat1 -->
+<xsl:template match="ch.Ucirc"><xsl:text>&#219;</xsl:text></xsl:template><!-- 
latin capital letter U with circumflex, U+00DB ISOlat1 -->
+<xsl:template match="ch.Uuml"><xsl:text>&#220;</xsl:text></xsl:template><!-- 
latin capital letter U with diaeresis, U+00DC ISOlat1 -->
+<xsl:template match="ch.Yacute"><xsl:text>&#221;</xsl:text></xsl:template><!-- 
latin capital letter Y with acute, U+00DD ISOlat1 -->
+<xsl:template match="ch.THORN"><xsl:text>&#222;</xsl:text></xsl:template><!-- 
latin capital letter THORN, U+00DE ISOlat1 -->
+<xsl:template match="ch.szlig"><xsl:text>&#223;</xsl:text></xsl:template><!-- 
latin small letter sharp s = ess-zed, U+00DF ISOlat1 -->
+<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 -->
+<xsl:template match="ch.aacute"><xsl:text>&#225;</xsl:text></xsl:template><!-- 
latin small letter a with acute, U+00E1 ISOlat1 -->
+<xsl:template match="ch.acirc"><xsl:text>&#226;</xsl:text></xsl:template><!-- 
latin small letter a with circumflex, U+00E2 ISOlat1 -->
+<xsl:template match="ch.atilde"><xsl:text>&#227;</xsl:text></xsl:template><!-- 
latin small letter a with tilde, U+00E3 ISOlat1 -->
+<xsl:template match="ch.auml"><xsl:text>&#228;</xsl:text></xsl:template><!-- 
latin small letter a with diaeresis, U+00E4 ISOlat1 -->
+<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 -->
+<xsl:template match="ch.aelig"><xsl:text>&#230;</xsl:text></xsl:template><!-- 
latin small letter ae = latin small ligature ae, U+00E6 ISOlat1 -->
+<xsl:template match="ch.ccedil"><xsl:text>&#231;</xsl:text></xsl:template><!-- 
latin small letter c with cedilla, U+00E7 ISOlat1 -->
+<xsl:template match="ch.egrave"><xsl:text>&#232;</xsl:text></xsl:template><!-- 
latin small letter e with grave, U+00E8 ISOlat1 -->
+<xsl:template match="ch.eacute"><xsl:text>&#233;</xsl:text></xsl:template><!-- 
latin small letter e with acute, U+00E9 ISOlat1 -->
+<xsl:template match="ch.ecirc"><xsl:text>&#234;</xsl:text></xsl:template><!-- 
latin small letter e with circumflex, U+00EA ISOlat1 -->
+<xsl:template match="ch.euml"><xsl:text>&#235;</xsl:text></xsl:template><!-- 
latin small letter e with diaeresis, U+00EB ISOlat1 -->
+<xsl:template match="ch.igrave"><xsl:text>&#236;</xsl:text></xsl:template><!-- 
latin small letter i with grave, U+00EC ISOlat1 -->
+<xsl:template match="ch.iacute"><xsl:text>&#237;</xsl:text></xsl:template><!-- 
latin small letter i with acute, U+00ED ISOlat1 -->
+<xsl:template match="ch.icirc"><xsl:text>&#238;</xsl:text></xsl:template><!-- 
latin small letter i with circumflex, U+00EE ISOlat1 -->
+<xsl:template match="ch.iuml"><xsl:text>&#239;</xsl:text></xsl:template><!-- 
latin small letter i with diaeresis, U+00EF ISOlat1 -->
+<xsl:template match="ch.eth"><xsl:text>&#240;</xsl:text></xsl:template><!-- 
latin small letter eth, U+00F0 ISOlat1 -->
+<xsl:template match="ch.ntilde"><xsl:text>&#241;</xsl:text></xsl:template><!-- 
latin small letter n with tilde, U+00F1 ISOlat1 -->
+<xsl:template match="ch.ograve"><xsl:text>&#242;</xsl:text></xsl:template><!-- 
latin small letter o with grave, U+00F2 ISOlat1 -->
+<xsl:template match="ch.oacute"><xsl:text>&#243;</xsl:text></xsl:template><!-- 
latin small letter o with acute, U+00F3 ISOlat1 -->
+<xsl:template match="ch.ocirc"><xsl:text>&#244;</xsl:text></xsl:template><!-- 
latin small letter o with circumflex, U+00F4 ISOlat1 -->
+<xsl:template match="ch.otilde"><xsl:text>&#245;</xsl:text></xsl:template><!-- 
latin small letter o with tilde, U+00F5 ISOlat1 -->
+<xsl:template match="ch.ouml"><xsl:text>&#246;</xsl:text></xsl:template><!-- 
latin small letter o with diaeresis, U+00F6 ISOlat1 -->
+<xsl:template match="ch.divide"><xsl:text>&#247;</xsl:text></xsl:template><!-- 
division sign, U+00F7 ISOnum -->
+<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 
-->
+<xsl:template match="ch.ugrave"><xsl:text>&#249;</xsl:text></xsl:template><!-- 
latin small letter u with grave, U+00F9 ISOlat1 -->
+<xsl:template match="ch.uacute"><xsl:text>&#250;</xsl:text></xsl:template><!-- 
latin small letter u with acute, U+00FA ISOlat1 -->
+<xsl:template match="ch.ucirc"><xsl:text>&#251;</xsl:text></xsl:template><!-- 
latin small letter u with circumflex, U+00FB ISOlat1 -->
+<xsl:template match="ch.uuml"><xsl:text>&#252;</xsl:text></xsl:template><!-- 
latin small letter u with diaeresis, U+00FC ISOlat1 -->
+<xsl:template match="ch.yacute"><xsl:text>&#253;</xsl:text></xsl:template><!-- 
latin small letter y with acute, U+00FD ISOlat1 -->
+<xsl:template match="ch.thorn"><xsl:text>&#254;</xsl:text></xsl:template><!-- 
latin small letter thorn, U+00FE ISOlat1 -->
+<xsl:template match="ch.yuml"><xsl:text>&#255;</xsl:text></xsl:template><!-- 
latin small letter y with diaeresis, U+00FF ISOlat1 -->
+
+<!-- ~~~~~~~~~~~~~~~~~~~~~ Special Characters ~~~~~~~~~~~~~~~~~~~~ -->
+
+<xsl:template match="ch.ampersand">\&amp;</xsl:template><!-- ampersand -->
+<xsl:template match="ch.lsquot">\textquoteleft</xsl:template><!-- opening left 
quotation mark -->
+<xsl:template match="ch.rsquot">\textquoteright</xsl:template><!-- closing 
right quotation mark -->
+<xsl:template match="ch.ldquot">``</xsl:template><!-- opening left double 
quotation mark -->
+<xsl:template match="ch.rdquot">''</xsl:template><!-- closing right double 
quotation mark -->
+<xsl:template match="ch.minus">\-</xsl:template><!-- mathematical minus -->
+<xsl:template match="ch.emdash">\-</xsl:template><!-- emdash -->
+<xsl:template match="ch.ellips">&nbsp;\ldots </xsl:template><!-- ellipsis -->
+<xsl:template match="ch.lellips">\ldots&nbsp; </xsl:template><!-- left 
ellipsis, used at the beginning of edited material -->
+<xsl:template match="ch.blankline">\_\_\_\_\_\_\_</xsl:template><!-- blank 
line to be filled in -->
+<xsl:template match="ch.percent"><xsl:text>\%</xsl:text></xsl:template><!-- 
percent sign -->
+<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 -->
+<xsl:template match="ch.frac116"><xsl:text>1/16</xsl:text></xsl:template><!-- 
vulgar fraction one sixteenth = fraction on sixteenth -->
+<xsl:template match="ch.plus"><xsl:text>+</xsl:text></xsl:template><!-- 
mathematical plus -->
+
+<!-- ==================== named templates ======================= -->
+
+<!--
+ 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.
+-->
+<xsl:template name="section-title-link">
+ <!-- will the list always contain the closest ancestor first? -->
+ <xsl:variable name="section-title">
+  <!-- numbered or not? -->
+  <xsl:if test="ancestor::section[position()=1]/@class='numbered'">
+   <xsl:choose>
+    <xsl:when test="$language='es'">
+     <xsl:text>Secci&oacute;n </xsl:text>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:text>Section </xsl:text>
+    </xsl:otherwise>
+   </xsl:choose>
+  </xsl:if>
+  <xsl:apply-templates select="ancestor::section[position()=1]/meta/title[1]" 
/>
+ </xsl:variable>
+ 
+ <a>
+  <xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of 
select="ancestor::section[position()=1]/@id" /></xsl:attribute>
+  <xsl:value-of select="$section-title" />
+ </a>
+</xsl:template>
+
 </xsl:transform>
#!/bin/perl -w
#
# gbtolatex.pl
# 10 April 2002
#
# Creates LaTeX gamebook from XML source. This should subsequently be
# used to create a PDF or PostScript version.
#####

use strict;

my $PROGRAM_NAME      = "gbtolatex";
my $XML_PATH          = "xml";
my $XML_SOURCE        = "";
my $PWD               = `pwd`;
chomp($PWD);
my $BOOK_PATH         = $PWD."/latex";
my $TITLE_COLOR       = "";
my $USE_ILLUSTRATORS  = "";

# Programs
#
my $XMLPROC = "xalan";
# my $XMLPROC = "/usr/local/bin/xmlto";
my $JAVA = "/cygdrive/c/WINDOWS/java.exe";
my $EXTRAPARMS =""; 
$EXTRAPARMS=$ENV{'XMLPARMS'} if defined($ENV{'XMLPARMS'});

# Check AONPATH
if ( ! defined($ENV{'AONPATH'}) && ! defined ($ENV{'AONDATA'}) ) {
        print STDERR "AONPATH environment variable not set, it should be 
defined to\n";
        print STDERR "wherever the AON files are.\n";
        exit 1;
}
my $DATADIR = "";
if (  defined ($ENV{'AONDATA'}) ) {
        $DATADIR=$ENV{'AONDATA'} ; 
} else { 
        $DATADIR= $ENV{'AONPATH'}."/data";
}
if ( ! -d "$DATADIR" ) {
        print STDERR "Cannot find $DATADIR !\n";
        exit 1;
}
##

unless( $ARGV[ 0 ] ) { die "Usage:\n\t${PROGRAM_NAME} book-code [LANGUAGE]\n"; }

print "Reminder:\n\tDid you uncomment the LaTeX special 
character\n\tdeclarations in the book's XML file?\n";

my $bookCode = $ARGV[ 0 ];
my $language = $ARGV[ 1 ] || "";

# TODO:
# - convert the bookcode's if then else to a hash array
# - allow usage of unknown book codes

if( $bookCode eq "01fftd" ) {
    $XML_SOURCE        = "01fftd.xml";
    $BOOK_PATH         .= "/lw/01fftd";
    $TITLE_COLOR       = "0.0,0.4,0.2";
    $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "01hdlo" ) {
    $XML_SOURCE        = "01hdlo.xml";
    $BOOK_PATH         .= "/lw/01hdlo";
    $TITLE_COLOR       = "0.0,0.4,0.2";
    $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "02fotw" ) {
    $XML_SOURCE        = "02fotw.xml";
    $BOOK_PATH         .= "/lw/02fotw";
    $TITLE_COLOR       = "0.0,0.6,0.6";
    $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "02fsea" ) {
    $XML_SOURCE        = "02fsea.xml";
    $BOOK_PATH         .= "/lw/02fsea";
    $TITLE_COLOR       = "0.0,0.6,0.6";
    $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "03tcok" ) {
    $XML_SOURCE        = "03tcok.xml";
    $BOOK_PATH         .= "/lw/03tcok";
    $TITLE_COLOR       = "0.0,0.6,0.8";
    $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "03lcdk" ) {
    $XML_SOURCE        = "03lcdk.xml";
    $BOOK_PATH         .= "/lw/03lcdk";
    $TITLE_COLOR       = "0.0,0.6,0.8";
    $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "04tcod" ) {
    $XML_SOURCE        = "04tcod.xml";
    $BOOK_PATH         .= "/lw/04tcod";
    $TITLE_COLOR       = "0.0,0.0,0.6";
    $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "04eam" ) {
    $XML_SOURCE        = "04eam.xml";
    $BOOK_PATH         .= "/lw/04eam";
    $TITLE_COLOR       = "0.0,0.0,0.6";
    $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "05sots" ) {
    $XML_SOURCE        = "05sots.xml";
    $BOOK_PATH         .= "/lw/05sots";
    $TITLE_COLOR       = "0.8,0.6,0.0";
    $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "06tkot" ) {
    $XML_SOURCE        = "06tkot.xml";
    $BOOK_PATH         .= "/lw/06tkot";
    $TITLE_COLOR       = "0.6,0.6,0.0";
    $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "07cd" ) {
    $XML_SOURCE        = "07cd.xml";
    $BOOK_PATH         .= "/lw/07cd";
    $TITLE_COLOR       = "0.0,0.8,0.4";
    $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "08tjoh" ) {
    $XML_SOURCE        = "08tjoh.xml";
    $BOOK_PATH         .= "/lw/08tjoh";
    $TITLE_COLOR       = "0.4,0.6,0.4";
    $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "09tcof" ) {
    $XML_SOURCE        = "09tcof.xml";
    $BOOK_PATH         .= "/lw/09tcof";
    $TITLE_COLOR       = "1.0,0.6,0.0";
    $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "10tdot" ) {
    $XML_SOURCE        = "10tdot.xml";
    $BOOK_PATH         .= "/lw/10tdot";
    $TITLE_COLOR       = "1.0,0.0,0.0";
    $USE_ILLUSTRATORS  = ":Brian Williams:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "11tpot" ) {
    $XML_SOURCE        = "11tpot.xml";
    $BOOK_PATH         .= "/lw/11tpot";
    $TITLE_COLOR       = "0.5,0.5,0.4";
    $USE_ILLUSTRATORS  = ":Brian Williams:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "12tmod" ) {
    $XML_SOURCE        = "12tmod.xml";
    $BOOK_PATH         .= "/lw/12tmod";
    $TITLE_COLOR       = "0.6,0.0,0.0";
    $USE_ILLUSTRATORS  = ":Brian Williams:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "13tplor" ) {
    $XML_SOURCE        = "13tplor.xml";
    $BOOK_PATH         .= "/lw/13tplor";
    # TODO - review
    $TITLE_COLOR       = "0.6,0.0,0.0"; 
    $USE_ILLUSTRATORS  = ":Brian Williams:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "14tcok" ) {
    $XML_SOURCE        = "14tcok.xml";
    $BOOK_PATH         .= "/lw/14tcok";
    # TODO - review
    $TITLE_COLOR       = "0.6,0.0,0.0"; 
    $USE_ILLUSTRATORS  = ":Brian Williams:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "15tdc" ) {
    $XML_SOURCE        = "15tdc.xml";
    $BOOK_PATH         .= "/lw/15tdc";
    # TODO - review
    $TITLE_COLOR       = "0.6,0.0,0.0"; 
    $USE_ILLUSTRATORS  = ":Brian Williams:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "16tlov" ) {
    $XML_SOURCE        = "16tlov.xml";
    $BOOK_PATH         .= "/lw/16tlov";
    # TODO - review
    $TITLE_COLOR       = "0.6,0.0,0.0"; 
    $USE_ILLUSTRATORS  = ":Brian Williams:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "17tdoi" ) {
    $XML_SOURCE        = "17tdoi.xml";
    $BOOK_PATH         .= "/lw/17tdoi";
    # TODO - review
    $TITLE_COLOR       = "0.6,0.0,0.0"; 
    $USE_ILLUSTRATORS  = ":Brian Williams:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "18dotd" ) {
    $XML_SOURCE        = "18dotd.xml";
    $BOOK_PATH         .= "/lw/18dotd";
    # TODO - review
    $TITLE_COLOR       = "0.6,0.0,0.0"; 
    $USE_ILLUSTRATORS  = ":Brian Williams:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
elsif( $bookCode eq "19wb" ) {
    $XML_SOURCE        = "19wb.xml";
    $BOOK_PATH         .= "/lw/19wb";
    # TODO - review
    $TITLE_COLOR       = "0.6,0.0,0.0"; 
    $USE_ILLUSTRATORS  = ":Brian Williams:JC Alvarez & Jonathan Blake:Jonathan 
Blake:";
}
else{ die "Error:\n\tUknown book code.\n"; }

chdir( "$DATADIR" ) or die( "Cannot open Project Aon data directory 
\"$DATADIR\": $!" );

# If there is a LANGUAGE set use it
# TODO - this is no longer true, languages use their own codes
# (but they could be located in a subdir...)
if ( $language ne "" ) {
# Languages are prefixes to the booknames in the files
        $XML_SOURCE =~ s/\.xml$/\.${language}.xml/;
}

# Check that the XML file is there
if ( ! -r $DATADIR."/".$XML_SOURCE ) {
        die "Could not find source file $XML_SOURCE in $DATADIR!";
}
if ( ! -r $DATADIR."/latex.xsl" ) {
        die "Could not find LaTeX stylesheet (latex.xsl) in $DATADIR!";
}


# Create the output directory if it does not exist already
print "Checking directory $BOOK_PATH...";
if ( ! -d "$BOOK_PATH" ) {
        print "...creating";
        `mkdir -p "$BOOK_PATH"` || die "Could not create output directory 
$BOOK_PATH: $!";
}
print "..done.\n";

my $OUTPUTFILE="$BOOK_PATH/$bookCode.tex";
if ( $language ne "" ) {
# Languages are prefixes to the booknames in the files
        $OUTPUTFILE =~ s/\.tex$/\.${language}.tex/;
}

# Run the XML preprocessor
# TODO: use system() properly here and check return value
print "Processing book $bookCode and storing result in $OUTPUTFILE...";
# For Xmlto, which uses xsltproc:
# (Does not work)
# `$XMLPROC -v -o $BOOK_PATH -x ${DATADIR}/latex.xsl dvi 
${DATADIR}/${XML_SOURCE}`;
# Apache's Xalan:
my $command="$XMLPROC  -in  ${DATADIR}/${XML_SOURCE} -xsl ${DATADIR}/latex.xsl 
-out $OUTPUTFILE -param title-color \"\'$TITLE_COLOR\'\" -param 
use-illustrators \"\'$USE_ILLUSTRATORS\'\" $EXTRAPARMS";
#print "Executing $command";
print qx{$command};
# Apache Xalan, Java version:
# print qx{$JAVA org.apache.xalan.xslt.Process -IN $XML_PATH/$XML_SOURCE -XSL 
$XML_PATH/latex.xsl -OUT $BOOK_PATH/$bookCode.tex -PARAM title-color 
\"$TITLE_COLOR\" -PARAM use-illustrators \"$USE_ILLUSTRATORS\"};
#
print "...done\n";


# End of script
exit 0;

Other related posts: