2 <!--#############################################################################
3 | $Id: book-article.mod.xsl,v 1.1.2.1 2003/05/01 14:06:14 jelmer Exp $
4 |- #############################################################################
8 | This template matches a book / article
9 + ############################################################################## -->
12 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
13 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
14 exclude-result-prefixes="doc" version='1.0'>
18 <!--############################################################################# -->
19 <!-- DOCUMENTATION -->
20 <doc:reference id="book-article" xmlns="">
22 <releaseinfo role="meta">
23 $Id: book-article.mod.xsl,v 1.1.2.1 2003/05/01 14:06:14 jelmer Exp $
26 <author> <firstname>Ramon</firstname> <surname>Casellas</surname> </author>
27 <author> <firstname>James</firstname> <surname>Devenish</surname> </author>
30 <year>2000</year> <year>2001</year> <year>2002</year> <year>2003</year>
31 <holder>Ramon Casellas</holder>
35 <title>Books and Articles <filename>book-article.mod.xsl</filename></title>
37 <section><title>Introduction</title>
51 <!--############################################################################# -->
52 <!-- DOCUMENTATION -->
53 <doc:template match="book" xmlns="">
54 <refpurpose>Book XSL Template</refpurpose>
56 <para> Most DocBook documents are either articles or books, so the book
57 XSL template <xref linkend="template.book"/> is one classical entry point
58 when processign docbook documents.</para>
60 <formalpara><title>Tasks</title>
62 <listitem><para></para></listitem>
66 <formalpara><title>Remarks and Bugs</title>
76 <para>The CALS column width specification.</para>
82 :<para>Outputs the LaTeX Code corresponding to a book.</para>
89 <!--############################################################################# -->
90 <!-- XSL TEMPLATE book -->
92 <!-- Main entry point for a DocBook "book" -->
93 <!--############################################################################# -->
94 <xsl:template match="book">
95 <!-- book:1: generate.latex.book.preamble -->
96 <xsl:call-template name="generate.latex.book.preamble"/>
97 <!-- book:2: output title information -->
98 <xsl:text>\title{</xsl:text>
100 <xsl:when test="./title">
101 <xsl:apply-templates select="title" mode="maketitle.mode"/>
102 <xsl:apply-templates select="subtitle" mode="maketitle.mode"/>
105 <xsl:apply-templates select="bookinfo/title" mode="maketitle.mode"/>
106 <xsl:apply-templates select="bookinfo/subtitle" mode="maketitle.mode"/>
109 <xsl:text>} </xsl:text>
110 <!-- book:3: output author information -->
111 <xsl:text>\author{</xsl:text>
113 <xsl:when test="bookinfo/authorgroup">
114 <xsl:apply-templates select="bookinfo/authorgroup"/>
117 <xsl:for-each select="bookinfo/author">
118 <xsl:apply-templates select="."/>
119 <xsl:if test="not(position()=last())">
120 <xsl:text> \and </xsl:text>
125 <xsl:text>} </xsl:text>
126 <!-- book:4: dump any preamble after author -->
127 <xsl:value-of select="$latex.book.afterauthor"/>
128 <!-- book:5: set some counters -->
129 <xsl:text> \setcounter{tocdepth}{</xsl:text><xsl:value-of select="$toc.section.depth"/><xsl:text>} </xsl:text>
130 <xsl:text> \setcounter{secnumdepth}{</xsl:text><xsl:value-of select="$section.depth"/><xsl:text>} </xsl:text>
131 <!-- book:6: dump the begin document command -->
132 <xsl:value-of select="$latex.book.begindocument"/>
134 <!-- book:7: include external Cover page if specified -->
135 <xsl:if test="$latex.titlepage.file != ''">
136 <xsl:text> \InputIfFileExists{</xsl:text><xsl:value-of select="$latex.titlepage.file"/>
137 <xsl:text>}{\typeout{WARNING: Using cover page</xsl:text>
138 <xsl:value-of select="$latex.titlepage.file"/>
139 <xsl:text>}}</xsl:text>
142 <!-- book:7b: maketitle and set up pagestyle -->
143 <xsl:value-of select="$latex.maketitle"/>
144 <!-- book:8: - APPLY TEMPLATES -->
145 <xsl:apply-templates/>
146 <!-- book:9: call map.end -->
147 <xsl:call-template name="map.end"/>
151 <!-- Titles/subtitles -->
152 <!-- Empty templates -->
154 <xsl:template match="book/title"/>
155 <xsl:template match="book/subtitle"/>
156 <xsl:template match="book/titleabbrev"/>
157 <xsl:template match="book/bookinfo/title"/>
158 <xsl:template match="book/bookinfo/subtitle"/>
159 <xsl:template match="book/bookinfo/titleabbrev"/>
161 <xsl:template match="book/title" mode="maketitle.mode">\bfseries <xsl:apply-templates /></xsl:template>
162 <xsl:template match="book/subtitle" mode="maketitle.mode">\\[12pt]\normalsize <xsl:apply-templates /></xsl:template>
163 <xsl:template match="book/bookinfo/title" mode="maketitle.mode">\bfseries <xsl:apply-templates /></xsl:template>
164 <xsl:template match="book/bookinfo/subtitle" mode="maketitle.mode">\\[12pt]\normalsize <xsl:apply-templates /></xsl:template>
166 <xsl:template match="book/bookinfo">
167 <xsl:apply-templates select="revhistory" />
168 <xsl:apply-templates select="abstract" />
169 <xsl:apply-templates select="keywordset" />
170 <xsl:apply-templates select="copyright" />
171 <xsl:apply-templates select="legalnotice" />
176 <!--#############################################################################
178 + ############################################################################# -->
180 <!-- DOCUMENTATION -->
181 <doc:template match="article" xmlns="">
182 <refpurpose>Article XSL Template</refpurpose>
184 <para> Most DocBook documents are either articles or books, so the article
185 XSL template <xref linkend="template.article"/> is one classical entry point
186 when processign docbook documents.</para>
188 <formalpara><title>Tasks</title>
190 <listitem><para>Calls <literal>generate.latex.article.preamble</literal>.</para></listitem>
191 <listitem><para>Outputs \title, \author, \date, getting the information from its children.</para></listitem>
192 <listitem><para>Calls <literal>latex.article.begindocument</literal>.</para></listitem>
193 <listitem><para>Calls <literal>latex.article.maketitle.</literal></para></listitem>
194 <listitem><para>Applies templates.</para></listitem>
195 <listitem><para>Calls <literal>latex.article.end</literal> template.</para></listitem>
199 <formalpara><title>Remarks and Bugs</title>
201 <listitem><para> EMPTY templates: article/title and article/subtitle</para></listitem>
208 <term>colwidth</term>
210 <para>The CALS column width specification.</para>
216 <para>Outputs the LaTeX Code corresponding to an article.</para>
219 <!--############################################################################# -->
222 <xsl:template match="book/article">
223 <xsl:text> \makeatletter\if@openright\cleardoublepage\else\clearpage\fi</xsl:text>
224 <xsl:call-template name="generate.latex.pagestyle"/>
225 <xsl:text>\makeatother </xsl:text>
226 <!-- Get and output article title -->
227 <xsl:variable name="article.title">
229 <xsl:when test="./title">
230 <xsl:apply-templates select="./title"/>
232 <xsl:when test="./articleinfo/title">
233 <xsl:apply-templates select="./articleinfo/title"/>
236 <xsl:apply-templates select="./artheader/title"/>
240 <xsl:text>\begin{center}{</xsl:text>
241 <xsl:value-of select="$latex.book.article.title.style"/>
242 <xsl:text>{</xsl:text>
243 <xsl:value-of select="$article.title"/>
244 <xsl:text>}}\par </xsl:text>
245 <!-- Display author information -->
247 <xsl:when test="artheader/author">
248 <xsl:text>\textsf{</xsl:text>
249 <xsl:for-each select="artheader/author">
250 <xsl:apply-templates select="."/>
251 <xsl:if test="not(position()=last())">
252 <xsl:text> \and </xsl:text>
255 <xsl:text>}\par </xsl:text>
257 <xsl:when test="artheader/authorgroup">
258 <xsl:text>\textsf{</xsl:text>
259 <xsl:apply-templates select="artheader/authorgroup"/>
260 <xsl:text>}\par </xsl:text>
262 <xsl:when test="articleinfo/author">
263 <xsl:text>\textsf{</xsl:text>
264 <xsl:for-each select="articleinfo/author">
265 <xsl:apply-templates select="."/>
266 <xsl:if test="not(position()=last())">
267 <xsl:text> \and </xsl:text>
270 <xsl:text>}\par </xsl:text>
272 <xsl:when test="articleinfo/authorgroup">
273 <xsl:text>\textsf{</xsl:text>
274 <xsl:apply-templates select="articleinfo/authorgroup"/>
275 <xsl:text>}\par </xsl:text>
277 <xsl:when test="author">
278 <xsl:text>\textsf{</xsl:text>
279 <xsl:for-each select="author">
280 <xsl:apply-templates select="."/>
281 <xsl:if test="not(position()=last())">
282 <xsl:text> \and </xsl:text>
285 <xsl:text>}\par </xsl:text>
288 <xsl:apply-templates select="artheader|articleinfo" mode="article.within.book"/>
289 <xsl:text>\end{center} </xsl:text>
290 <xsl:apply-templates select="*[not(self::title)]"/>
293 <xsl:template match="artheader|articleinfo" mode="article.within.book">
294 <xsl:value-of select="."/>
299 <!-- ARTICLE TEMPLATE -->
300 <xsl:template match="article">
301 <!-- Output LaTeX preamble -->
302 <xsl:call-template name="generate.latex.article.preamble"/>
303 <!-- Get and output article title -->
304 <xsl:variable name="article.title">
306 <xsl:when test="./title">
307 <xsl:apply-templates select="./title"/>
309 <xsl:when test="./articleinfo/title">
310 <xsl:apply-templates select="./articleinfo/title"/>
313 <xsl:apply-templates select="./artheader/title"/>
317 <xsl:text>\title{</xsl:text>
318 <xsl:value-of select="$latex.article.title.style"/>
319 <xsl:text>{</xsl:text>
320 <xsl:value-of select="$article.title"/>
321 <xsl:text>}} </xsl:text>
322 <!-- Display date and author information -->
323 <xsl:variable name="article.date">
324 <xsl:apply-templates select="./artheader/date|./articleinfo/date"/>
326 <xsl:if test="$article.date!=''">
327 <xsl:text>\date{</xsl:text>
328 <xsl:value-of select="$article.date"/>
329 <xsl:text>} </xsl:text>
331 <xsl:text>\author{</xsl:text>
333 <xsl:when test="artheader/authorgroup">
334 <xsl:apply-templates select="artheader/authorgroup"/>
336 <xsl:when test="articleinfo/authorgroup">
337 <xsl:apply-templates select="articleinfo/authorgroup"/>
339 <xsl:when test="artheader/author">
340 <xsl:for-each select="artheader/author">
341 <xsl:apply-templates select="."/>
342 <xsl:if test="not(position()=last())">
343 <xsl:text> \and </xsl:text>
347 <xsl:when test="articleinfo/author">
348 <xsl:for-each select="articleinfo/author">
349 <xsl:apply-templates select="."/>
350 <xsl:if test="not(position()=last())">
351 <xsl:text> \and </xsl:text>
356 <xsl:for-each select="author">
357 <xsl:apply-templates select="."/>
358 <xsl:if test="not(position()=last())">
359 <xsl:text> \and </xsl:text>
364 <xsl:text>} </xsl:text>
365 <!-- Display begindocument command -->
366 <xsl:value-of select="$latex.article.begindocument"/>
367 <xsl:value-of select="$latex.maketitle"/>
368 <xsl:apply-templates select="*[not(self::title)]"/>
369 <xsl:value-of select="$latex.article.end"/>
373 <xsl:template match="article/title|articleinfo/title|articleinfo/date|artheader/date">
374 <xsl:apply-templates/>
377 <xsl:template match="article/artheader|article/articleinfo">
378 <xsl:apply-templates select="legalnotice" />
379 <xsl:apply-templates select="abstract"/>
382 <!-- EMPTY TEMPLATES -->
383 <xsl:template match="article/subtitle"/>
388 <!--#############################################################################
389 | Template: copyright
390 |- ############################################################################# -->
391 <xsl:template match="copyright">
392 <xsl:call-template name="gentext.element.name"/>
393 <xsl:call-template name='gentext.space'/>
394 <xsl:call-template name="dingbat">
395 <xsl:with-param name="dingbat">copyright</xsl:with-param>
397 <xsl:call-template name='gentext.space'/>
398 <xsl:apply-templates select="year"/>
399 <xsl:call-template name='gentext.space'/>
400 <xsl:apply-templates select="holder"/>
403 <xsl:template match="copyright/holder">
404 <xsl:apply-templates />
406 <xsl:template match="copyright/year[position()<last()-1]">
407 <xsl:apply-templates />
408 <xsl:text>, </xsl:text>
411 <!-- RCAS 2003/03/11 FIXME : "and" -->
412 <xsl:template match="copyright/year[position()=last()-1]">
413 <xsl:apply-templates />
414 <xsl:text>, </xsl:text>
417 <xsl:template match="copyright/year[position()=last()]">
418 <xsl:apply-templates />
424 <!--#############################################################################
425 | Template: name legalnotice.caption
426 |- ############################################################################# -->
427 <xsl:template name="legalnotice.caption">
429 <xsl:when test="./title">
430 <xsl:apply-templates select="./title"/>
433 <xsl:call-template name="gentext">
434 <xsl:with-param name="key">legalnotice</xsl:with-param>
442 <!--#############################################################################
443 | Template: legalnotice
444 |- ############################################################################# -->
445 <xsl:template match="legalnotice">
446 <!-- Support for legalnotice. -->
447 <xsl:text>\vspace{-.3em} </xsl:text>
448 <xsl:text>\if@twocolumn </xsl:text>
449 <xsl:text>\noindent\small{\itshape </xsl:text>
450 <xsl:call-template name="legalnotice.caption"/>
451 <xsl:text>}\/\bfseries---$\!$% </xsl:text>
452 <xsl:text>\else </xsl:text>
453 <xsl:text>\noindent\begin{center}\small\bfseries </xsl:text>
454 <xsl:call-template name="legalnotice.caption"/>
455 <xsl:text>\end{center}\quotation\small </xsl:text>
456 <xsl:text>\fi </xsl:text>
457 <xsl:apply-templates select="*[not(self::title)]"/>
458 <xsl:text>\vspace{0.6em}\par\if@twocolumn\else\endquotation\fi </xsl:text>
459 <xsl:text>\normalsize\rmfamily </xsl:text>
463 <xsl:template match="legalnotice/title">
464 <xsl:apply-templates/>
469 <!--#############################################################################
470 | $Id: book-article.mod.xsl,v 1.1.2.1 2003/05/01 14:06:14 jelmer Exp $
471 |- #############################################################################
474 | PURPOSE: Table of Contents, Figures, ...
475 + ############################################################################## -->
477 <xsl:template match="toc">
478 <xsl:text> </xsl:text>
479 <xsl:text>\tableofcontents </xsl:text>
482 <xsl:template match="lot">
484 <xsl:when test="@label">
486 <xsl:when test="@label='figures'">
487 <xsl:text>\listoffigures </xsl:text>
489 <xsl:when test="@label='tables'">
490 <xsl:text>\listoftables </xsl:text>
493 <xsl:text>\listoffigures </xsl:text>
494 <xsl:text>\listoftables </xsl:text>
499 <xsl:text>\listoffigures </xsl:text>
500 <xsl:text>\listoftables </xsl:text>
506 <xsl:template match="lotentry">
509 <xsl:template match="lotentry"/>
510 <xsl:template match="tocpart|tocchap|tocfront|tocback|tocentry"/>
511 <xsl:template match="toclevel1|toclevel2|toclevel3|toclevel4|toclevel5"/>
513 <doc:template name="generate.latex.pagestyle" xmlns="">
514 <refpurpose> Choose the preferred page style for document body </refpurpose>
517 If no page style is preferred by the user, the defaults will be
518 "empty" for articles, "plain" for books, or "fancy" (if the
519 fancyhdr packages is permitted).
521 <formalpara><title>Pertinent Variables</title>
523 <listitem><simpara><xref linkend="param.pagestyle"/></simpara></listitem>
524 <listitem><simpara><xref linkend="param.use.fancyhdr"/></simpara></listitem>
529 <xsl:template name="generate.latex.pagestyle">
530 <xsl:text>\pagestyle{</xsl:text>
532 <xsl:when test="$latex.pagestyle!=''"><xsl:value-of select="$latex.pagestyle"/></xsl:when>
533 <xsl:when test="count(//book)>0">
535 <xsl:when test="$latex.use.fancyhdr=1"><xsl:text>fancy</xsl:text></xsl:when>
536 <xsl:otherwise><xsl:text>plain</xsl:text></xsl:otherwise>
539 <xsl:otherwise><xsl:text>empty</xsl:text></xsl:otherwise>
541 <xsl:text>}</xsl:text>