2 <!--#############################################################################
3 |- #############################################################################
6 | This template matches a book / article
7 + ############################################################################## -->
10 xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
11 xmlns:
doc=
"http://nwalsh.com/xsl/documentation/1.0"
12 exclude-result-prefixes=
"doc" version='
1.0'
>
16 <!--############################################################################# -->
17 <!-- DOCUMENTATION -->
18 <doc:reference id=
"book-article" xmlns=
"">
20 <releaseinfo role=
"meta">
23 <author> <firstname>Ramon
</firstname> <surname>Casellas
</surname> </author>
24 <author> <firstname>James
</firstname> <surname>Devenish
</surname> </author>
27 <year>2000</year> <year>2001</year> <year>2002</year> <year>2003</year>
28 <holder>Ramon Casellas
</holder>
32 <title>Books and Articles
<filename>book-article.mod.xsl
</filename></title>
34 <section><title>Introduction
</title>
48 <!--############################################################################# -->
49 <!-- DOCUMENTATION -->
50 <doc:template match=
"book" xmlns=
"">
51 <refpurpose>Book XSL Template
</refpurpose>
53 <para> Most DocBook documents are either articles or books, so the book
54 XSL template
<xref linkend=
"template.book"/> is one classical entry point
55 when processign docbook documents.
</para>
57 <formalpara><title>Tasks
</title>
59 <listitem><para></para></listitem>
63 <formalpara><title>Remarks and Bugs
</title>
73 <para>The CALS column width specification.
</para>
79 :
<para>Outputs the LaTeX Code corresponding to a book.
</para>
86 <!--############################################################################# -->
87 <!-- XSL TEMPLATE book -->
89 <!-- Main entry point for a DocBook "book" -->
90 <!--############################################################################# -->
91 <xsl:template match=
"book">
92 <!-- book:1: generate.latex.book.preamble -->
93 <xsl:call-template name=
"generate.latex.book.preamble"/>
94 <!-- book:2: output title information -->
95 <xsl:text>\title{
</xsl:text>
97 <xsl:when test=
"./title">
98 <xsl:apply-templates select=
"title" mode=
"maketitle.mode"/>
99 <xsl:apply-templates select=
"subtitle" mode=
"maketitle.mode"/>
102 <xsl:apply-templates select=
"bookinfo/title" mode=
"maketitle.mode"/>
103 <xsl:apply-templates select=
"bookinfo/subtitle" mode=
"maketitle.mode"/>
106 <xsl:text>}
</xsl:text>
107 <!-- book:3: output author information -->
108 <xsl:text>\author{
</xsl:text>
110 <xsl:when test=
"bookinfo/authorgroup">
111 <xsl:apply-templates select=
"bookinfo/authorgroup"/>
114 <xsl:for-each select=
"bookinfo/author">
115 <xsl:apply-templates select=
"."/>
116 <xsl:if test=
"not(position()=last())">
117 <xsl:text> \and
</xsl:text>
122 <xsl:text>}
</xsl:text>
123 <!-- book:4: dump any preamble after author -->
124 <xsl:value-of select=
"$latex.book.afterauthor"/>
125 <!-- book:5: set some counters -->
126 <xsl:text> \setcounter{tocdepth}{
</xsl:text><xsl:value-of select=
"$toc.section.depth"/><xsl:text>}
</xsl:text>
127 <xsl:text> \setcounter{secnumdepth}{
</xsl:text><xsl:value-of select=
"$section.depth"/><xsl:text>}
</xsl:text>
128 <!-- book:6: dump the begin document command -->
129 <xsl:value-of select=
"$latex.book.begindocument"/>
131 <!-- book:7: include external Cover page if specified -->
132 <xsl:if test=
"$latex.titlepage.file != ''">
133 <xsl:text> \InputIfFileExists{
</xsl:text><xsl:value-of select=
"$latex.titlepage.file"/>
134 <xsl:text>}{\typeout{WARNING: Using cover page
</xsl:text>
135 <xsl:value-of select=
"$latex.titlepage.file"/>
136 <xsl:text>}}
</xsl:text>
139 <!-- book:7b: maketitle and set up pagestyle -->
140 <xsl:value-of select=
"$latex.maketitle"/>
141 <!-- book:8: - APPLY TEMPLATES -->
142 <xsl:apply-templates/>
143 <!-- book:9: call map.end -->
144 <xsl:call-template name=
"map.end"/>
148 <!-- Titles/subtitles -->
149 <!-- Empty templates -->
151 <xsl:template match=
"book/title"/>
152 <xsl:template match=
"book/subtitle"/>
153 <xsl:template match=
"book/titleabbrev"/>
154 <xsl:template match=
"book/bookinfo/title"/>
155 <xsl:template match=
"book/bookinfo/subtitle"/>
156 <xsl:template match=
"book/bookinfo/titleabbrev"/>
158 <xsl:template match=
"book/title" mode=
"maketitle.mode">\bfseries
<xsl:apply-templates /></xsl:template>
159 <xsl:template match=
"book/subtitle" mode=
"maketitle.mode">\\[
12pt]\normalsize
<xsl:apply-templates /></xsl:template>
160 <xsl:template match=
"book/bookinfo/title" mode=
"maketitle.mode">\bfseries
<xsl:apply-templates /></xsl:template>
161 <xsl:template match=
"book/bookinfo/subtitle" mode=
"maketitle.mode">\\[
12pt]\normalsize
<xsl:apply-templates /></xsl:template>
163 <xsl:template match=
"book/bookinfo">
164 <xsl:apply-templates select=
"revhistory" />
165 <xsl:apply-templates select=
"abstract" />
166 <xsl:apply-templates select=
"keywordset" />
167 <xsl:apply-templates select=
"copyright" />
168 <xsl:apply-templates select=
"legalnotice" />
173 <!--#############################################################################
175 + ############################################################################# -->
177 <!-- DOCUMENTATION -->
178 <doc:template match=
"article" xmlns=
"">
179 <refpurpose>Article XSL Template
</refpurpose>
181 <para> Most DocBook documents are either articles or books, so the article
182 XSL template
<xref linkend=
"template.article"/> is one classical entry point
183 when processign docbook documents.
</para>
185 <formalpara><title>Tasks
</title>
187 <listitem><para>Calls
<literal>generate.latex.article.preamble
</literal>.
</para></listitem>
188 <listitem><para>Outputs \title, \author, \date, getting the information from its children.
</para></listitem>
189 <listitem><para>Calls
<literal>latex.article.begindocument
</literal>.
</para></listitem>
190 <listitem><para>Calls
<literal>latex.article.maketitle.
</literal></para></listitem>
191 <listitem><para>Applies templates.
</para></listitem>
192 <listitem><para>Calls
<literal>latex.article.end
</literal> template.
</para></listitem>
196 <formalpara><title>Remarks and Bugs
</title>
198 <listitem><para> EMPTY templates: article/title and article/subtitle
</para></listitem>
205 <term>colwidth
</term>
207 <para>The CALS column width specification.
</para>
213 <para>Outputs the LaTeX Code corresponding to an article.
</para>
216 <!--############################################################################# -->
219 <xsl:template match=
"book/article">
220 <xsl:text> \makeatletter\if@openright\cleardoublepage\else\clearpage\fi
</xsl:text>
221 <xsl:call-template name=
"generate.latex.pagestyle"/>
222 <xsl:text>\makeatother
</xsl:text>
223 <!-- Get and output article title -->
224 <xsl:variable name=
"article.title">
226 <xsl:when test=
"./title">
227 <xsl:apply-templates select=
"./title"/>
229 <xsl:when test=
"./articleinfo/title">
230 <xsl:apply-templates select=
"./articleinfo/title"/>
233 <xsl:apply-templates select=
"./artheader/title"/>
237 <xsl:text>\begin{center}{
</xsl:text>
238 <xsl:value-of select=
"$latex.book.article.title.style"/>
239 <xsl:text>{
</xsl:text>
240 <xsl:value-of select=
"$article.title"/>
241 <xsl:text>}}\par
</xsl:text>
242 <!-- Display author information -->
244 <xsl:when test=
"artheader/author">
245 <xsl:text>\textsf{
</xsl:text>
246 <xsl:for-each select=
"artheader/author">
247 <xsl:apply-templates select=
"."/>
248 <xsl:if test=
"not(position()=last())">
249 <xsl:text> \and
</xsl:text>
252 <xsl:text>}\par
</xsl:text>
254 <xsl:when test=
"artheader/authorgroup">
255 <xsl:text>\textsf{
</xsl:text>
256 <xsl:apply-templates select=
"artheader/authorgroup"/>
257 <xsl:text>}\par
</xsl:text>
259 <xsl:when test=
"articleinfo/author">
260 <xsl:text>\textsf{
</xsl:text>
261 <xsl:for-each select=
"articleinfo/author">
262 <xsl:apply-templates select=
"."/>
263 <xsl:if test=
"not(position()=last())">
264 <xsl:text> \and
</xsl:text>
267 <xsl:text>}\par
</xsl:text>
269 <xsl:when test=
"articleinfo/authorgroup">
270 <xsl:text>\textsf{
</xsl:text>
271 <xsl:apply-templates select=
"articleinfo/authorgroup"/>
272 <xsl:text>}\par
</xsl:text>
274 <xsl:when test=
"author">
275 <xsl:text>\textsf{
</xsl:text>
276 <xsl:for-each select=
"author">
277 <xsl:apply-templates select=
"."/>
278 <xsl:if test=
"not(position()=last())">
279 <xsl:text> \and
</xsl:text>
282 <xsl:text>}\par
</xsl:text>
285 <xsl:apply-templates select=
"artheader|articleinfo" mode=
"article.within.book"/>
286 <xsl:text>\end{center}
</xsl:text>
287 <xsl:apply-templates select=
"*[not(self::title)]"/>
290 <xsl:template match=
"artheader|articleinfo" mode=
"article.within.book">
291 <xsl:value-of select=
"."/>
296 <!-- ARTICLE TEMPLATE -->
297 <xsl:template match=
"article">
298 <!-- Output LaTeX preamble -->
299 <xsl:call-template name=
"generate.latex.article.preamble"/>
300 <!-- Get and output article title -->
301 <xsl:variable name=
"article.title">
303 <xsl:when test=
"./title">
304 <xsl:apply-templates select=
"./title"/>
306 <xsl:when test=
"./articleinfo/title">
307 <xsl:apply-templates select=
"./articleinfo/title"/>
310 <xsl:apply-templates select=
"./artheader/title"/>
314 <xsl:text>\title{
</xsl:text>
315 <xsl:value-of select=
"$latex.article.title.style"/>
316 <xsl:text>{
</xsl:text>
317 <xsl:value-of select=
"$article.title"/>
318 <xsl:text>}}
</xsl:text>
319 <!-- Display date and author information -->
320 <xsl:variable name=
"article.date">
321 <xsl:apply-templates select=
"./artheader/date|./articleinfo/date"/>
323 <xsl:if test=
"$article.date!=''">
324 <xsl:text>\date{
</xsl:text>
325 <xsl:value-of select=
"$article.date"/>
326 <xsl:text>}
</xsl:text>
328 <xsl:text>\author{
</xsl:text>
330 <xsl:when test=
"artheader/authorgroup">
331 <xsl:apply-templates select=
"artheader/authorgroup"/>
333 <xsl:when test=
"articleinfo/authorgroup">
334 <xsl:apply-templates select=
"articleinfo/authorgroup"/>
336 <xsl:when test=
"artheader/author">
337 <xsl:for-each select=
"artheader/author">
338 <xsl:apply-templates select=
"."/>
339 <xsl:if test=
"not(position()=last())">
340 <xsl:text> \and
</xsl:text>
344 <xsl:when test=
"articleinfo/author">
345 <xsl:for-each select=
"articleinfo/author">
346 <xsl:apply-templates select=
"."/>
347 <xsl:if test=
"not(position()=last())">
348 <xsl:text> \and
</xsl:text>
353 <xsl:for-each select=
"author">
354 <xsl:apply-templates select=
"."/>
355 <xsl:if test=
"not(position()=last())">
356 <xsl:text> \and
</xsl:text>
361 <xsl:text>}
</xsl:text>
362 <!-- Display begindocument command -->
363 <xsl:value-of select=
"$latex.article.begindocument"/>
364 <xsl:value-of select=
"$latex.maketitle"/>
365 <xsl:apply-templates select=
"*[not(self::title)]"/>
366 <xsl:value-of select=
"$latex.article.end"/>
370 <xsl:template match=
"article/title|articleinfo/title|articleinfo/date|artheader/date">
371 <xsl:apply-templates/>
374 <xsl:template match=
"article/artheader|article/articleinfo">
375 <xsl:apply-templates select=
"legalnotice" />
376 <xsl:apply-templates select=
"abstract"/>
379 <!-- EMPTY TEMPLATES -->
380 <xsl:template match=
"article/subtitle"/>
385 <!--#############################################################################
386 | Template: copyright
387 |- ############################################################################# -->
388 <xsl:template match=
"copyright">
389 <xsl:call-template name=
"gentext.element.name"/>
390 <xsl:call-template name='gentext.space'
/>
391 <xsl:call-template name=
"dingbat">
392 <xsl:with-param name=
"dingbat">copyright
</xsl:with-param>
394 <xsl:call-template name='gentext.space'
/>
395 <xsl:apply-templates select=
"year"/>
396 <xsl:call-template name='gentext.space'
/>
397 <xsl:apply-templates select=
"holder"/>
400 <xsl:template match=
"copyright/holder">
401 <xsl:apply-templates />
403 <xsl:template match=
"copyright/year[position()<last()-1]">
404 <xsl:apply-templates />
405 <xsl:text>,
</xsl:text>
408 <!-- RCAS 2003/03/11 FIXME : "and" -->
409 <xsl:template match=
"copyright/year[position()=last()-1]">
410 <xsl:apply-templates />
411 <xsl:text>,
</xsl:text>
414 <xsl:template match=
"copyright/year[position()=last()]">
415 <xsl:apply-templates />
421 <!--#############################################################################
422 | Template: name legalnotice.caption
423 |- ############################################################################# -->
424 <xsl:template name=
"legalnotice.caption">
426 <xsl:when test=
"./title">
427 <xsl:apply-templates select=
"./title"/>
430 <xsl:call-template name=
"gentext">
431 <xsl:with-param name=
"key">legalnotice
</xsl:with-param>
439 <!--#############################################################################
440 | Template: legalnotice
441 |- ############################################################################# -->
442 <xsl:template match=
"legalnotice">
443 <!-- Support for legalnotice. -->
444 <xsl:text>\vspace{-
.3em}
</xsl:text>
445 <xsl:text>\if@twocolumn
</xsl:text>
446 <xsl:text>\noindent\small{\itshape
</xsl:text>
447 <xsl:call-template name=
"legalnotice.caption"/>
448 <xsl:text>}\/\bfseries---$\!$%
</xsl:text>
449 <xsl:text>\else
</xsl:text>
450 <xsl:text>\noindent\begin{center}\small\bfseries
</xsl:text>
451 <xsl:call-template name=
"legalnotice.caption"/>
452 <xsl:text>\end{center}\quotation\small
</xsl:text>
453 <xsl:text>\fi
</xsl:text>
454 <xsl:apply-templates select=
"*[not(self::title)]"/>
455 <xsl:text>\vspace{
0.6em}\par\if@twocolumn\else\endquotation\fi
</xsl:text>
456 <xsl:text>\normalsize\rmfamily
</xsl:text>
460 <xsl:template match=
"legalnotice/title">
461 <xsl:apply-templates/>
466 <!--#############################################################################
467 |- #############################################################################
469 | PURPOSE: Table of Contents, Figures, ...
470 + ############################################################################## -->
472 <xsl:template match=
"toc">
473 <xsl:text> </xsl:text>
474 <xsl:text>\tableofcontents
</xsl:text>
477 <xsl:template match=
"lot">
479 <xsl:when test=
"@label">
481 <xsl:when test=
"@label='figures'">
482 <xsl:text>\listoffigures
</xsl:text>
484 <xsl:when test=
"@label='tables'">
485 <xsl:text>\listoftables
</xsl:text>
488 <xsl:text>\listoffigures
</xsl:text>
489 <xsl:text>\listoftables
</xsl:text>
494 <xsl:text>\listoffigures
</xsl:text>
495 <xsl:text>\listoftables
</xsl:text>
501 <xsl:template match=
"lotentry">
504 <xsl:template match=
"lotentry"/>
505 <xsl:template match=
"tocpart|tocchap|tocfront|tocback|tocentry"/>
506 <xsl:template match=
"toclevel1|toclevel2|toclevel3|toclevel4|toclevel5"/>
508 <doc:template name=
"generate.latex.pagestyle" xmlns=
"">
509 <refpurpose> Choose the preferred page style for document body
</refpurpose>
512 If no page style is preferred by the user, the defaults will be
513 "empty" for articles,
"plain" for books, or
"fancy" (if the
514 fancyhdr packages is permitted).
516 <formalpara><title>Pertinent Variables
</title>
518 <listitem><simpara><xref linkend=
"param.pagestyle"/></simpara></listitem>
519 <listitem><simpara><xref linkend=
"param.use.fancyhdr"/></simpara></listitem>
524 <xsl:template name=
"generate.latex.pagestyle">
525 <xsl:text>\pagestyle{
</xsl:text>
527 <xsl:when test=
"$latex.pagestyle!=''"><xsl:value-of select=
"$latex.pagestyle"/></xsl:when>
528 <xsl:when test=
"count(//book)>0">
530 <xsl:when test=
"$latex.use.fancyhdr=1"><xsl:text>fancy
</xsl:text></xsl:when>
531 <xsl:otherwise><xsl:text>plain
</xsl:text></xsl:otherwise>
534 <xsl:otherwise><xsl:text>empty
</xsl:text></xsl:otherwise>
536 <xsl:text>}
</xsl:text>