This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[sfrench/samba-autobuild/.git] / docs / docbook / xslt / db2latex / book-article.mod.xsl
1 <?xml version='1.0'?>
2 <!--############################################################################# 
3 |       $Id: book-article.mod.xsl,v 1.1.2.1 2003/05/01 14:06:14 jelmer Exp $
4 |- #############################################################################
5 |       $Author: jelmer $                                                                                               
6 |                                                                                                               
7 |   PURPOSE:
8 |       This template matches a book / article
9 + ############################################################################## -->
10
11 <xsl:stylesheet 
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'>
15
16
17
18     <!--############################################################################# -->
19     <!-- DOCUMENTATION                                                                -->
20     <doc:reference id="book-article" xmlns="">
21         <referenceinfo>
22             <releaseinfo role="meta">
23                 $Id: book-article.mod.xsl,v 1.1.2.1 2003/05/01 14:06:14 jelmer Exp $
24             </releaseinfo>
25             <authorgroup>
26             <author> <firstname>Ramon</firstname> <surname>Casellas</surname> </author>
27             <author> <firstname>James</firstname> <surname>Devenish</surname> </author>
28             </authorgroup>
29             <copyright>
30                 <year>2000</year> <year>2001</year> <year>2002</year> <year>2003</year>
31                 <holder>Ramon Casellas</holder>
32             </copyright>
33         </referenceinfo>
34
35         <title>Books and Articles <filename>book-article.mod.xsl</filename></title>
36         <partintro>
37             <section><title>Introduction</title>
38                 <para></para>
39             </section>
40         </partintro>
41     </doc:reference>
42
43
44
45
46
47
48
49
50
51     <!--############################################################################# -->
52     <!-- DOCUMENTATION -->
53     <doc:template match="book" xmlns="">
54         <refpurpose>Book XSL Template</refpurpose>
55         <refdescription>
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>
59
60             <formalpara><title>Tasks</title>
61                 <itemizedlist>
62                     <listitem><para></para></listitem>
63                 </itemizedlist>
64             </formalpara>
65
66             <formalpara><title>Remarks and Bugs</title>
67                 <itemizedlist>
68                 </itemizedlist>
69             </formalpara>
70         </refdescription>
71         <refparameter>
72             <variablelist>
73                 <varlistentry>
74                     <term>colwidth</term>
75                     <listitem>
76                         <para>The CALS column width specification.</para>
77                     </listitem>
78                 </varlistentry>
79             </variablelist>
80         </refparameter>
81         <refreturn>
82             :<para>Outputs the LaTeX Code corresponding to a book.</para>
83         </refreturn>
84     </doc:template>
85
86
87
88
89     <!--############################################################################# -->
90     <!-- XSL TEMPLATE book                                                            -->
91     <!--                                                                              -->
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>
99         <xsl:choose>
100                 <xsl:when test="./title">
101                 <xsl:apply-templates select="title" mode="maketitle.mode"/>
102                 <xsl:apply-templates select="subtitle" mode="maketitle.mode"/>
103                 </xsl:when>
104                 <xsl:otherwise>
105                 <xsl:apply-templates select="bookinfo/title" mode="maketitle.mode"/>
106                 <xsl:apply-templates select="bookinfo/subtitle" mode="maketitle.mode"/>
107                 </xsl:otherwise>
108         </xsl:choose>
109         <xsl:text>}&#10;</xsl:text>
110         <!-- book:3: output author information     -->
111         <xsl:text>\author{</xsl:text>
112         <xsl:choose>
113             <xsl:when test="bookinfo/authorgroup">
114                         <xsl:apply-templates select="bookinfo/authorgroup"/>
115             </xsl:when>
116             <xsl:otherwise>
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>
121                                 </xsl:if>
122                         </xsl:for-each>
123             </xsl:otherwise>
124         </xsl:choose>
125         <xsl:text>}&#10;</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>&#10;\setcounter{tocdepth}{</xsl:text><xsl:value-of select="$toc.section.depth"/><xsl:text>}&#10;</xsl:text>
130         <xsl:text>&#10;\setcounter{secnumdepth}{</xsl:text><xsl:value-of select="$section.depth"/><xsl:text>}&#10;</xsl:text>
131         <!-- book:6: dump the begin document command  -->
132         <xsl:value-of select="$latex.book.begindocument"/>
133
134         <!-- book:7: include external Cover page if specified -->
135         <xsl:if test="$latex.titlepage.file != ''">
136                         <xsl:text>&#10;\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>
140         </xsl:if>
141
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"/>
148     </xsl:template>
149
150
151     <!-- Titles/subtitles -->
152         <!-- Empty templates  -->
153
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"/>
160
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>
165
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" />
172     </xsl:template>
173
174
175
176     <!--############################################################################# 
177     |   Template : article 
178     +   ############################################################################# -->
179
180     <!-- DOCUMENTATION -->
181     <doc:template match="article" xmlns="">
182         <refpurpose>Article XSL Template</refpurpose>
183         <refdescription>
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>
187
188             <formalpara><title>Tasks</title>
189                 <itemizedlist>
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>
196                 </itemizedlist>
197             </formalpara>
198
199             <formalpara><title>Remarks and Bugs</title>
200                 <itemizedlist>
201                     <listitem><para> EMPTY templates: article/title and article/subtitle</para></listitem>
202                 </itemizedlist>
203             </formalpara>
204         </refdescription>
205         <refparameter>
206             <variablelist>
207                 <varlistentry>
208                     <term>colwidth</term>
209                     <listitem>
210                         <para>The CALS column width specification.</para>
211                     </listitem>
212                 </varlistentry>
213             </variablelist>
214         </refparameter>
215         <refreturn>
216             <para>Outputs the LaTeX Code corresponding to an article.</para>
217         </refreturn>
218     </doc:template>
219     <!--############################################################################# -->
220
221
222     <xsl:template match="book/article">
223         <xsl:text>&#10;\makeatletter\if@openright\cleardoublepage\else\clearpage\fi</xsl:text>
224         <xsl:call-template name="generate.latex.pagestyle"/>
225         <xsl:text>\makeatother&#10;</xsl:text>  
226         <!-- Get and output article title -->
227         <xsl:variable name="article.title">
228             <xsl:choose>
229                         <xsl:when test="./title"> 
230                                 <xsl:apply-templates select="./title"/>
231                         </xsl:when>
232                         <xsl:when test="./articleinfo/title">
233                                 <xsl:apply-templates select="./articleinfo/title"/>
234                         </xsl:when>
235                         <xsl:otherwise>
236                                 <xsl:apply-templates select="./artheader/title"/>
237                         </xsl:otherwise>
238             </xsl:choose>
239         </xsl:variable>
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&#10;</xsl:text>
245         <!-- Display author information --> 
246         <xsl:choose>
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>
253                                 </xsl:if>
254                         </xsl:for-each>
255                         <xsl:text>}\par&#10;</xsl:text>
256                 </xsl:when>
257             <xsl:when test="artheader/authorgroup">
258                         <xsl:text>\textsf{</xsl:text>
259                         <xsl:apply-templates select="artheader/authorgroup"/>
260                         <xsl:text>}\par&#10;</xsl:text>
261                 </xsl:when>
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>
268                                 </xsl:if>
269                         </xsl:for-each>
270                         <xsl:text>}\par&#10;</xsl:text>
271                 </xsl:when>
272             <xsl:when test="articleinfo/authorgroup">
273                         <xsl:text>\textsf{</xsl:text>
274                         <xsl:apply-templates select="articleinfo/authorgroup"/>
275                         <xsl:text>}\par&#10;</xsl:text>
276                 </xsl:when>
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>
283                                 </xsl:if>
284                         </xsl:for-each>
285                         <xsl:text>}\par&#10;</xsl:text>
286                 </xsl:when>
287         </xsl:choose>
288         <xsl:apply-templates select="artheader|articleinfo" mode="article.within.book"/>
289         <xsl:text>\end{center}&#10;</xsl:text>
290         <xsl:apply-templates select="*[not(self::title)]"/>
291         </xsl:template>
292
293         <xsl:template match="artheader|articleinfo" mode="article.within.book">
294                 <xsl:value-of select="."/>
295         </xsl:template>
296
297
298
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">
305             <xsl:choose>
306                         <xsl:when test="./title"> 
307                                 <xsl:apply-templates select="./title"/>
308                         </xsl:when>
309                         <xsl:when test="./articleinfo/title">
310                                 <xsl:apply-templates select="./articleinfo/title"/>
311                         </xsl:when>
312                         <xsl:otherwise>
313                                 <xsl:apply-templates select="./artheader/title"/>
314                         </xsl:otherwise>
315             </xsl:choose>
316         </xsl:variable>
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>}}&#10;</xsl:text>
322         <!-- Display date and author information --> 
323         <xsl:variable name="article.date">
324                 <xsl:apply-templates select="./artheader/date|./articleinfo/date"/>
325         </xsl:variable>
326         <xsl:if test="$article.date!=''">
327                 <xsl:text>\date{</xsl:text>
328                 <xsl:value-of select="$article.date"/>
329                 <xsl:text>}&#10;</xsl:text>
330         </xsl:if>
331         <xsl:text>\author{</xsl:text>
332         <xsl:choose>
333             <xsl:when test="artheader/authorgroup">
334                         <xsl:apply-templates select="artheader/authorgroup"/>
335                 </xsl:when>
336             <xsl:when test="articleinfo/authorgroup">
337                         <xsl:apply-templates select="articleinfo/authorgroup"/>
338                 </xsl:when>
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>
344                         </xsl:if>
345                 </xsl:for-each>
346                 </xsl:when>
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>
352                         </xsl:if>
353                 </xsl:for-each>
354                 </xsl:when>
355             <xsl:otherwise>
356                 <xsl:for-each select="author">
357                         <xsl:apply-templates select="."/>
358                         <xsl:if test="not(position()=last())">
359                                 <xsl:text> \and </xsl:text>
360                         </xsl:if>
361                 </xsl:for-each>
362             </xsl:otherwise>
363         </xsl:choose>
364         <xsl:text>}&#10;</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"/>
370     </xsl:template>
371
372
373     <xsl:template match="article/title|articleinfo/title|articleinfo/date|artheader/date">
374         <xsl:apply-templates/>
375     </xsl:template>
376
377     <xsl:template match="article/artheader|article/articleinfo">
378         <xsl:apply-templates select="legalnotice" />
379         <xsl:apply-templates select="abstract"/>
380     </xsl:template>
381
382     <!-- EMPTY TEMPLATES -->
383     <xsl:template match="article/subtitle"/>
384
385
386
387         
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>
396                 </xsl:call-template>
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"/>
401         </xsl:template>
402
403         <xsl:template match="copyright/holder">
404                 <xsl:apply-templates />
405         </xsl:template>
406         <xsl:template match="copyright/year[position()&lt;last()-1]">
407                 <xsl:apply-templates />
408                 <xsl:text>, </xsl:text>
409         </xsl:template>
410
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>
415         </xsl:template>
416         
417         <xsl:template match="copyright/year[position()=last()]">
418                 <xsl:apply-templates />
419         </xsl:template>
420
421
422
423
424     <!--############################################################################# 
425     |   Template: name legalnotice.caption
426     |-  ############################################################################# -->
427         <xsl:template name="legalnotice.caption">
428         <xsl:choose>
429                 <xsl:when test="./title">
430                         <xsl:apply-templates select="./title"/>
431                 </xsl:when>
432                 <xsl:otherwise>
433                 <xsl:call-template name="gentext">
434                         <xsl:with-param name="key">legalnotice</xsl:with-param>
435                 </xsl:call-template>
436                 </xsl:otherwise>
437         </xsl:choose>
438         </xsl:template>
439
440
441
442     <!--############################################################################# 
443     |   Template: legalnotice 
444     |-  ############################################################################# -->
445 <xsl:template match="legalnotice">
446         <!-- Support for legalnotice. -->
447     <xsl:text>\vspace{-.3em}&#10;</xsl:text>
448     <xsl:text>\if@twocolumn&#10;</xsl:text>
449     <xsl:text>\noindent\small{\itshape &#10;</xsl:text>
450         <xsl:call-template name="legalnotice.caption"/>
451     <xsl:text>}\/\bfseries---$\!$%&#10;</xsl:text>
452     <xsl:text>\else&#10;</xsl:text>
453     <xsl:text>\noindent\begin{center}\small\bfseries &#10;</xsl:text>
454         <xsl:call-template name="legalnotice.caption"/>
455     <xsl:text>\end{center}\quotation\small&#10;</xsl:text>
456     <xsl:text>\fi&#10;</xsl:text>
457         <xsl:apply-templates select="*[not(self::title)]"/>
458     <xsl:text>\vspace{0.6em}\par\if@twocolumn\else\endquotation\fi&#10;</xsl:text>
459     <xsl:text>\normalsize\rmfamily&#10;</xsl:text>
460 </xsl:template>
461
462
463         <xsl:template match="legalnotice/title">
464                 <xsl:apply-templates/>
465         </xsl:template>
466
467
468
469     <!--############################################################################# 
470     |   $Id: book-article.mod.xsl,v 1.1.2.1 2003/05/01 14:06:14 jelmer Exp $
471     |- #############################################################################
472     |   $Author: jelmer $
473     |                                                                                                           
474     |   PURPOSE: Table of Contents, Figures, ...
475     + ############################################################################## -->
476
477     <xsl:template match="toc">
478         <xsl:text>&#10;</xsl:text>
479         <xsl:text>\tableofcontents&#10;</xsl:text>
480     </xsl:template>
481
482     <xsl:template match="lot">
483         <xsl:choose>
484                 <xsl:when test="@label">
485                         <xsl:choose>
486                                 <xsl:when test="@label='figures'">
487                                         <xsl:text>\listoffigures&#10;</xsl:text>
488                                 </xsl:when>
489                                 <xsl:when test="@label='tables'">
490                                         <xsl:text>\listoftables&#10;</xsl:text>
491                                 </xsl:when>
492                                 <xsl:otherwise>
493                                         <xsl:text>\listoffigures&#10;</xsl:text>
494                                         <xsl:text>\listoftables&#10;</xsl:text>
495                                 </xsl:otherwise>
496                         </xsl:choose>
497                 </xsl:when>
498                 <xsl:otherwise>
499                         <xsl:text>\listoffigures&#10;</xsl:text>
500                         <xsl:text>\listoftables&#10;</xsl:text>
501                 </xsl:otherwise>
502         </xsl:choose>
503     </xsl:template>
504
505
506     <xsl:template match="lotentry">
507     </xsl:template>
508
509     <xsl:template match="lotentry"/>
510     <xsl:template match="tocpart|tocchap|tocfront|tocback|tocentry"/>
511     <xsl:template match="toclevel1|toclevel2|toclevel3|toclevel4|toclevel5"/>
512
513     <doc:template name="generate.latex.pagestyle" xmlns="">
514         <refpurpose> Choose the preferred page style for document body </refpurpose>
515         <refdescription>
516                 <para>
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).
520                 </para>
521                 <formalpara><title>Pertinent Variables</title>
522                 <itemizedlist>
523                         <listitem><simpara><xref linkend="param.pagestyle"/></simpara></listitem>
524                         <listitem><simpara><xref linkend="param.use.fancyhdr"/></simpara></listitem>
525                 </itemizedlist>
526                 </formalpara>
527         </refdescription>
528     </doc:template>
529         <xsl:template name="generate.latex.pagestyle">
530                 <xsl:text>\pagestyle{</xsl:text>
531                 <xsl:choose>
532                         <xsl:when test="$latex.pagestyle!=''"><xsl:value-of select="$latex.pagestyle"/></xsl:when>
533                         <xsl:when test="count(//book)&gt;0">
534                                 <xsl:choose>
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>
537                                 </xsl:choose>
538                         </xsl:when>
539                         <xsl:otherwise><xsl:text>empty</xsl:text></xsl:otherwise>
540                 </xsl:choose>
541                 <xsl:text>}</xsl:text>
542         </xsl:template>
543         
544 </xsl:stylesheet>
545