trying to get HEAD building again. If you want the code
[Samba/gbeck.git] / docs / docbook / xslt / db2latex / book-article.mod.xsl
blob042ec556aa0a024f6670acca832ee268735ec74b
1 <?xml version='1.0'?>
2 <!--#############################################################################
3 |- #############################################################################
4 |
5 | PURPOSE:
6 | This template matches a book / article
7 + ############################################################################## -->
9 <xsl:stylesheet
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="">
19 <referenceinfo>
20 <releaseinfo role="meta">
21 </releaseinfo>
22 <authorgroup>
23 <author> <firstname>Ramon</firstname> <surname>Casellas</surname> </author>
24 <author> <firstname>James</firstname> <surname>Devenish</surname> </author>
25 </authorgroup>
26 <copyright>
27 <year>2000</year> <year>2001</year> <year>2002</year> <year>2003</year>
28 <holder>Ramon Casellas</holder>
29 </copyright>
30 </referenceinfo>
32 <title>Books and Articles <filename>book-article.mod.xsl</filename></title>
33 <partintro>
34 <section><title>Introduction</title>
35 <para></para>
36 </section>
37 </partintro>
38 </doc:reference>
48 <!--############################################################################# -->
49 <!-- DOCUMENTATION -->
50 <doc:template match="book" xmlns="">
51 <refpurpose>Book XSL Template</refpurpose>
52 <refdescription>
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>
58 <itemizedlist>
59 <listitem><para></para></listitem>
60 </itemizedlist>
61 </formalpara>
63 <formalpara><title>Remarks and Bugs</title>
64 <itemizedlist>
65 </itemizedlist>
66 </formalpara>
67 </refdescription>
68 <refparameter>
69 <variablelist>
70 <varlistentry>
71 <term>colwidth</term>
72 <listitem>
73 <para>The CALS column width specification.</para>
74 </listitem>
75 </varlistentry>
76 </variablelist>
77 </refparameter>
78 <refreturn>
79 :<para>Outputs the LaTeX Code corresponding to a book.</para>
80 </refreturn>
81 </doc:template>
86 <!--############################################################################# -->
87 <!-- XSL TEMPLATE book -->
88 <!-- -->
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>
96 <xsl:choose>
97 <xsl:when test="./title">
98 <xsl:apply-templates select="title" mode="maketitle.mode"/>
99 <xsl:apply-templates select="subtitle" mode="maketitle.mode"/>
100 </xsl:when>
101 <xsl:otherwise>
102 <xsl:apply-templates select="bookinfo/title" mode="maketitle.mode"/>
103 <xsl:apply-templates select="bookinfo/subtitle" mode="maketitle.mode"/>
104 </xsl:otherwise>
105 </xsl:choose>
106 <xsl:text>}&#10;</xsl:text>
107 <!-- book:3: output author information -->
108 <xsl:text>\author{</xsl:text>
109 <xsl:choose>
110 <xsl:when test="bookinfo/authorgroup">
111 <xsl:apply-templates select="bookinfo/authorgroup"/>
112 </xsl:when>
113 <xsl:otherwise>
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>
118 </xsl:if>
119 </xsl:for-each>
120 </xsl:otherwise>
121 </xsl:choose>
122 <xsl:text>}&#10;</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>&#10;\setcounter{tocdepth}{</xsl:text><xsl:value-of select="$toc.section.depth"/><xsl:text>}&#10;</xsl:text>
127 <xsl:text>&#10;\setcounter{secnumdepth}{</xsl:text><xsl:value-of select="$section.depth"/><xsl:text>}&#10;</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>&#10;\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>
137 </xsl:if>
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"/>
145 </xsl:template>
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" />
169 </xsl:template>
173 <!--#############################################################################
174 | Template : article
175 + ############################################################################# -->
177 <!-- DOCUMENTATION -->
178 <doc:template match="article" xmlns="">
179 <refpurpose>Article XSL Template</refpurpose>
180 <refdescription>
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>
186 <itemizedlist>
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>
193 </itemizedlist>
194 </formalpara>
196 <formalpara><title>Remarks and Bugs</title>
197 <itemizedlist>
198 <listitem><para> EMPTY templates: article/title and article/subtitle</para></listitem>
199 </itemizedlist>
200 </formalpara>
201 </refdescription>
202 <refparameter>
203 <variablelist>
204 <varlistentry>
205 <term>colwidth</term>
206 <listitem>
207 <para>The CALS column width specification.</para>
208 </listitem>
209 </varlistentry>
210 </variablelist>
211 </refparameter>
212 <refreturn>
213 <para>Outputs the LaTeX Code corresponding to an article.</para>
214 </refreturn>
215 </doc:template>
216 <!--############################################################################# -->
219 <xsl:template match="book/article">
220 <xsl:text>&#10;\makeatletter\if@openright\cleardoublepage\else\clearpage\fi</xsl:text>
221 <xsl:call-template name="generate.latex.pagestyle"/>
222 <xsl:text>\makeatother&#10;</xsl:text>
223 <!-- Get and output article title -->
224 <xsl:variable name="article.title">
225 <xsl:choose>
226 <xsl:when test="./title">
227 <xsl:apply-templates select="./title"/>
228 </xsl:when>
229 <xsl:when test="./articleinfo/title">
230 <xsl:apply-templates select="./articleinfo/title"/>
231 </xsl:when>
232 <xsl:otherwise>
233 <xsl:apply-templates select="./artheader/title"/>
234 </xsl:otherwise>
235 </xsl:choose>
236 </xsl:variable>
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&#10;</xsl:text>
242 <!-- Display author information -->
243 <xsl:choose>
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>
250 </xsl:if>
251 </xsl:for-each>
252 <xsl:text>}\par&#10;</xsl:text>
253 </xsl:when>
254 <xsl:when test="artheader/authorgroup">
255 <xsl:text>\textsf{</xsl:text>
256 <xsl:apply-templates select="artheader/authorgroup"/>
257 <xsl:text>}\par&#10;</xsl:text>
258 </xsl:when>
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>
265 </xsl:if>
266 </xsl:for-each>
267 <xsl:text>}\par&#10;</xsl:text>
268 </xsl:when>
269 <xsl:when test="articleinfo/authorgroup">
270 <xsl:text>\textsf{</xsl:text>
271 <xsl:apply-templates select="articleinfo/authorgroup"/>
272 <xsl:text>}\par&#10;</xsl:text>
273 </xsl:when>
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>
280 </xsl:if>
281 </xsl:for-each>
282 <xsl:text>}\par&#10;</xsl:text>
283 </xsl:when>
284 </xsl:choose>
285 <xsl:apply-templates select="artheader|articleinfo" mode="article.within.book"/>
286 <xsl:text>\end{center}&#10;</xsl:text>
287 <xsl:apply-templates select="*[not(self::title)]"/>
288 </xsl:template>
290 <xsl:template match="artheader|articleinfo" mode="article.within.book">
291 <xsl:value-of select="."/>
292 </xsl:template>
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">
302 <xsl:choose>
303 <xsl:when test="./title">
304 <xsl:apply-templates select="./title"/>
305 </xsl:when>
306 <xsl:when test="./articleinfo/title">
307 <xsl:apply-templates select="./articleinfo/title"/>
308 </xsl:when>
309 <xsl:otherwise>
310 <xsl:apply-templates select="./artheader/title"/>
311 </xsl:otherwise>
312 </xsl:choose>
313 </xsl:variable>
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>}}&#10;</xsl:text>
319 <!-- Display date and author information -->
320 <xsl:variable name="article.date">
321 <xsl:apply-templates select="./artheader/date|./articleinfo/date"/>
322 </xsl:variable>
323 <xsl:if test="$article.date!=''">
324 <xsl:text>\date{</xsl:text>
325 <xsl:value-of select="$article.date"/>
326 <xsl:text>}&#10;</xsl:text>
327 </xsl:if>
328 <xsl:text>\author{</xsl:text>
329 <xsl:choose>
330 <xsl:when test="artheader/authorgroup">
331 <xsl:apply-templates select="artheader/authorgroup"/>
332 </xsl:when>
333 <xsl:when test="articleinfo/authorgroup">
334 <xsl:apply-templates select="articleinfo/authorgroup"/>
335 </xsl:when>
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>
341 </xsl:if>
342 </xsl:for-each>
343 </xsl:when>
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>
349 </xsl:if>
350 </xsl:for-each>
351 </xsl:when>
352 <xsl:otherwise>
353 <xsl:for-each select="author">
354 <xsl:apply-templates select="."/>
355 <xsl:if test="not(position()=last())">
356 <xsl:text> \and </xsl:text>
357 </xsl:if>
358 </xsl:for-each>
359 </xsl:otherwise>
360 </xsl:choose>
361 <xsl:text>}&#10;</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"/>
367 </xsl:template>
370 <xsl:template match="article/title|articleinfo/title|articleinfo/date|artheader/date">
371 <xsl:apply-templates/>
372 </xsl:template>
374 <xsl:template match="article/artheader|article/articleinfo">
375 <xsl:apply-templates select="legalnotice" />
376 <xsl:apply-templates select="abstract"/>
377 </xsl:template>
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>
393 </xsl:call-template>
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"/>
398 </xsl:template>
400 <xsl:template match="copyright/holder">
401 <xsl:apply-templates />
402 </xsl:template>
403 <xsl:template match="copyright/year[position()&lt;last()-1]">
404 <xsl:apply-templates />
405 <xsl:text>, </xsl:text>
406 </xsl:template>
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>
412 </xsl:template>
414 <xsl:template match="copyright/year[position()=last()]">
415 <xsl:apply-templates />
416 </xsl:template>
421 <!--#############################################################################
422 | Template: name legalnotice.caption
423 |- ############################################################################# -->
424 <xsl:template name="legalnotice.caption">
425 <xsl:choose>
426 <xsl:when test="./title">
427 <xsl:apply-templates select="./title"/>
428 </xsl:when>
429 <xsl:otherwise>
430 <xsl:call-template name="gentext">
431 <xsl:with-param name="key">legalnotice</xsl:with-param>
432 </xsl:call-template>
433 </xsl:otherwise>
434 </xsl:choose>
435 </xsl:template>
439 <!--#############################################################################
440 | Template: legalnotice
441 |- ############################################################################# -->
442 <xsl:template match="legalnotice">
443 <!-- Support for legalnotice. -->
444 <xsl:text>\vspace{-.3em}&#10;</xsl:text>
445 <xsl:text>\if@twocolumn&#10;</xsl:text>
446 <xsl:text>\noindent\small{\itshape &#10;</xsl:text>
447 <xsl:call-template name="legalnotice.caption"/>
448 <xsl:text>}\/\bfseries---$\!$%&#10;</xsl:text>
449 <xsl:text>\else&#10;</xsl:text>
450 <xsl:text>\noindent\begin{center}\small\bfseries &#10;</xsl:text>
451 <xsl:call-template name="legalnotice.caption"/>
452 <xsl:text>\end{center}\quotation\small&#10;</xsl:text>
453 <xsl:text>\fi&#10;</xsl:text>
454 <xsl:apply-templates select="*[not(self::title)]"/>
455 <xsl:text>\vspace{0.6em}\par\if@twocolumn\else\endquotation\fi&#10;</xsl:text>
456 <xsl:text>\normalsize\rmfamily&#10;</xsl:text>
457 </xsl:template>
460 <xsl:template match="legalnotice/title">
461 <xsl:apply-templates/>
462 </xsl:template>
466 <!--#############################################################################
467 |- #############################################################################
469 | PURPOSE: Table of Contents, Figures, ...
470 + ############################################################################## -->
472 <xsl:template match="toc">
473 <xsl:text>&#10;</xsl:text>
474 <xsl:text>\tableofcontents&#10;</xsl:text>
475 </xsl:template>
477 <xsl:template match="lot">
478 <xsl:choose>
479 <xsl:when test="@label">
480 <xsl:choose>
481 <xsl:when test="@label='figures'">
482 <xsl:text>\listoffigures&#10;</xsl:text>
483 </xsl:when>
484 <xsl:when test="@label='tables'">
485 <xsl:text>\listoftables&#10;</xsl:text>
486 </xsl:when>
487 <xsl:otherwise>
488 <xsl:text>\listoffigures&#10;</xsl:text>
489 <xsl:text>\listoftables&#10;</xsl:text>
490 </xsl:otherwise>
491 </xsl:choose>
492 </xsl:when>
493 <xsl:otherwise>
494 <xsl:text>\listoffigures&#10;</xsl:text>
495 <xsl:text>\listoftables&#10;</xsl:text>
496 </xsl:otherwise>
497 </xsl:choose>
498 </xsl:template>
501 <xsl:template match="lotentry">
502 </xsl:template>
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>
510 <refdescription>
511 <para>
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).
515 </para>
516 <formalpara><title>Pertinent Variables</title>
517 <itemizedlist>
518 <listitem><simpara><xref linkend="param.pagestyle"/></simpara></listitem>
519 <listitem><simpara><xref linkend="param.use.fancyhdr"/></simpara></listitem>
520 </itemizedlist>
521 </formalpara>
522 </refdescription>
523 </doc:template>
524 <xsl:template name="generate.latex.pagestyle">
525 <xsl:text>\pagestyle{</xsl:text>
526 <xsl:choose>
527 <xsl:when test="$latex.pagestyle!=''"><xsl:value-of select="$latex.pagestyle"/></xsl:when>
528 <xsl:when test="count(//book)&gt;0">
529 <xsl:choose>
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>
532 </xsl:choose>
533 </xsl:when>
534 <xsl:otherwise><xsl:text>empty</xsl:text></xsl:otherwise>
535 </xsl:choose>
536 <xsl:text>}</xsl:text>
537 </xsl:template>
539 </xsl:stylesheet>