Bunch of smaller fixes.
[import/samba-docs-svnimport.git] / xslt / latex.xsl
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'
3         xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
4 <xsl:import href="http://db2latex.sourceforge.net/xsl/docbook.xsl"/>
5 <xsl:import href="strip-references.xsl"/>
6
7 <xsl:param name="latex.mapping.xml" select="document('latex.overrides.xml')"/>
8
9 <xsl:param name="generate.toc">
10         /appendix toc,title
11         article/appendix  nop
12         /article  toc,title
13         book      toc,title,figure,table,example,equation
14         /chapter  toc,title,lop
15         part      toc,title
16         /preface  toc,title
17         qandadiv  toc
18         qandaset  toc
19         procedure lop
20         reference toc,title
21         /sect1    toc
22         /sect2    toc
23         /sect3    toc
24         /sect4    toc
25         /sect5    toc
26         /section  toc
27         set       toc,title
28 </xsl:param>
29
30 <!-- Show real name of the link rather then user specified description -->
31 <xsl:template match="link">
32         <xsl:variable name="target" select="key('id',@linkend)[1]"/>
33         <xsl:variable name="refelem" select="local-name($target)"/>
34         <xsl:if test="$refelem=''">
35                 <xsl:message><xsl:text>XRef to nonexistent id: </xsl:text><xsl:value-of select="@linkend"/></xsl:message>
36                 <xsl:text>XrefId[?</xsl:text>
37                 <xsl:apply-templates/>
38                 <xsl:text>?]</xsl:text>
39         </xsl:if>
40
41         <xsl:call-template name="generate.hyperlink">
42                 <xsl:with-param name="target" select="$target"/>
43                 <xsl:with-param name="text">
44                         <xsl:call-template name="generate.xref.text">
45                                 <xsl:with-param name="target" select="$target"/>
46                         </xsl:call-template>
47                 </xsl:with-param>
48         </xsl:call-template>
49 </xsl:template>
50
51 <!-- LaTeX doesn't accept verbatim stuff in titles -->
52 <xsl:template match="//title/filename|//title/command|//title/parameter|//title/constant">
53   <xsl:variable name="content">
54     <xsl:apply-templates/>
55   </xsl:variable>
56   <xsl:if test="$content != ''">
57     <xsl:value-of select="$content" />
58   </xsl:if>
59 </xsl:template>
60
61 <xsl:output method="text" encoding="ISO-8859-1" indent="yes"/>
62 <xsl:variable name="l10n.gentext.default.language" select="'en'"/>
63 <xsl:variable name="latex.document.font">default</xsl:variable>
64 <xsl:variable name="latex.example.caption.style"></xsl:variable>
65 <xsl:variable name="latex.hyperref.param.pdftex">hyperfigures,hyperindex,citecolor=black,urlcolor=black,filecolor=black,linkcolor=black,menucolor=red,pagecolor=black</xsl:variable>
66 <xsl:variable name="admon.graphics.path">xslt/figures</xsl:variable>
67 <xsl:variable name="latex.use.tabularx">1</xsl:variable>
68 <xsl:variable name="latex.fancyhdr.lh"></xsl:variable>
69 <xsl:variable name="latex.use.fancyhdr"></xsl:variable>
70 <xsl:variable name="latex.use.parskip">1</xsl:variable>
71 <xsl:variable name="latex.book.varsets" select="''"/>
72 <xsl:variable name="latex.hyphenation.tttricks">1</xsl:variable>
73 <xsl:variable name="latex.titlepage.file"></xsl:variable>
74 <xsl:template name="latex.thead.row.entry">
75 <xsl:text>{\bfseries </xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text>
76 </xsl:template>
77 <xsl:variable name="latex.documentclass">sambadoc</xsl:variable>
78 <xsl:variable name="latex.babel.language">english</xsl:variable>
79 <xsl:variable name="ulink.footnotes" select="1"/>
80 <xsl:variable name="ulink.show" select="0"/>
81
82 <xsl:template match="smbconfblock/smbconfoption">
83         <xsl:text>      </xsl:text><xsl:value-of select="@name"/>
84         <xsl:if test="text() != ''">
85                 <xsl:text> = </xsl:text>
86                 <xsl:value-of select="text()"/>
87         </xsl:if>
88         <xsl:text>&#10;</xsl:text>
89 </xsl:template>
90
91 <xsl:template match="smbconfblock/smbconfcomment">
92         <xsl:text># </xsl:text>
93         <xsl:apply-templates/>
94         <xsl:text>&#10;</xsl:text>
95 </xsl:template>
96
97 <xsl:template match="smbconfblock/smbconfsection">
98         <xsl:value-of select="@name"/>
99         <xsl:text>&#10;</xsl:text>
100 </xsl:template>
101
102 <xsl:template match="smbconfoption">
103         <xsl:text>\smbconfoption{</xsl:text>
104         <xsl:call-template name="scape">
105                 <xsl:with-param name="string" select="@name"/>
106         </xsl:call-template>
107         <xsl:text>}</xsl:text>
108
109         <xsl:choose>
110                 <xsl:when test="text() != ''">
111                         <xsl:text> = </xsl:text>
112                         <xsl:call-template name="scape">
113                                 <xsl:with-param name="string" select="text()"/>
114                         </xsl:call-template>
115                 </xsl:when>
116         </xsl:choose>
117 </xsl:template>
118
119 <xsl:template match="smbconfblock">
120         <xsl:text>&#10;\begin{lstlisting}[language=smbconf,style=smbconfblock]&#10;</xsl:text>
121         <xsl:apply-templates/>
122         <xsl:text>\end{lstlisting}&#10;</xsl:text>
123 </xsl:template>
124
125 <xsl:template match="smbconfsection">
126         <xsl:text>\smbconfsection{</xsl:text>
127         <xsl:call-template name="scape">
128                 <xsl:with-param name="string" select="@name"/>
129         </xsl:call-template>
130         <xsl:text>}</xsl:text>
131 </xsl:template>
132
133 <xsl:template match="imagefile">
134         <xsl:text>\includegraphics[scale=</xsl:text>
135         <xsl:choose>
136                 <xsl:when test="@scale != ''"><xsl:value-of select="@scale div 100"/></xsl:when>
137
138                 <xsl:otherwise><xsl:text>.50</xsl:text></xsl:otherwise>
139         </xsl:choose>
140         <xsl:text>]{</xsl:text>
141         <xsl:value-of select="$latex.imagebasedir"/><xsl:text>images/</xsl:text>
142         <xsl:value-of select="text()"/>
143         <xsl:text>}&#10;</xsl:text>
144 </xsl:template>
145
146 <!-- smb.conf documentation -->
147
148 <xsl:template match="description"><xsl:apply-templates/></xsl:template>
149
150 <xsl:template match="value"><xsl:apply-templates/></xsl:template>
151
152 <xsl:template match="synonym"><xsl:apply-templates/></xsl:template>
153
154 <xsl:template match="related"><xsl:apply-templates/></xsl:template>
155
156 <xsl:template match="//samba:parameterlist">
157         <xsl:text>\begin{description}&#10;</xsl:text>
158         <xsl:apply-templates>
159                 <xsl:sort select="samba:parameter/@name"/>
160         </xsl:apply-templates>
161         <xsl:text>\end{description}&#10;</xsl:text>
162 </xsl:template>
163
164 <xsl:template match="value/comment">
165         <xsl:text>&#10;# </xsl:text>
166         <xsl:apply-templates/>
167 </xsl:template>
168
169 <xsl:template match="/">
170         <xsl:apply-templates/>
171 </xsl:template>
172
173 <xsl:template match="refentry">
174         <xsl:text>\section{</xsl:text><xsl:value-of select="refmeta/refentrytitle"/><xsl:text>}&#10;</xsl:text>
175         <xsl:apply-templates/>
176 </xsl:template>
177
178 <xsl:template match="//samba:parameter">
179         <xsl:text>\item[{</xsl:text><xsl:value-of select="@name"/><xsl:text>}]\null{}&#10;</xsl:text>
180         <xsl:text>\index{</xsl:text><xsl:value-of select="@name"/><xsl:text>|it}&#10;</xsl:text>
181
182         <xsl:for-each select="synonym">
183                 <xsl:text>\item[{</xsl:text><xsl:value-of select="."/><xsl:text>}]\null{}&#10;</xsl:text>
184         <xsl:text>\index{</xsl:text><xsl:value-of select="."/><xsl:text>|it}&#10;</xsl:text>
185         <xsl:text>This parameter is a synonym for \smbconfoption{</xsl:text><xsl:value-of select="../@name"/><xsl:text>}.</xsl:text>
186         </xsl:for-each>
187
188         <xsl:variable name="context">
189                 <xsl:text> (</xsl:text>
190                 <xsl:value-of select="@context"/>
191                 <xsl:text>)</xsl:text>
192         </xsl:variable>
193
194         <!-- Print default value-->
195         <xsl:text>&#10;</xsl:text>
196         <xsl:text>Default: </xsl:text>
197         <xsl:text>\emph{</xsl:text>
198         <xsl:choose>
199                 <xsl:when test="value[@type='default'] != ''">
200                         <xsl:value-of select="@name"/>
201                         <xsl:text> = </xsl:text>
202                         <xsl:apply-templates select="value"/>
203                 </xsl:when>
204                 <xsl:otherwise>
205                         <xsl:text>No default</xsl:text>
206                 </xsl:otherwise>
207         </xsl:choose>
208         <xsl:text>}</xsl:text>
209         <xsl:text>&#10;</xsl:text>
210
211         <!-- Generate list of examples -->
212         <xsl:text>&#10;</xsl:text>
213         <xsl:for-each select="value[@type='example']">
214                 <xsl:text>&#10;</xsl:text>
215                 <xsl:text>Example: </xsl:text>
216                 <xsl:text>\emph{</xsl:text><xsl:value-of select="../@name"/>
217                 <xsl:text> = </xsl:text>
218                 <xsl:apply-templates select="."/>
219                 <xsl:text>}</xsl:text>
220                 <xsl:text>&#10;</xsl:text>
221         </xsl:for-each>
222
223         <!-- Description -->
224         <xsl:apply-templates select="description"/>
225 </xsl:template>
226
227 </xsl:stylesheet>