This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[kai/samba.git] / docs / docbook / xslt / db2latex / qandaset.mod.xsl
1 <?xml version="1.0"?>
2 <!--############################################################################# 
3 |       $Id: qandaset.mod.xsl,v 1.1.2.1 2003/05/01 14:06:15 jelmer Exp $
4 |- #############################################################################
5 |       $Author: jelmer $
6 |                                                                                                               
7 |   PURPOSE:
8 |   Portions (c) Norman Walsh, official DocBook XSL stylesheets.
9 |                See docbook.sf.net
10 + ############################################################################## -->
11
12 <xsl:stylesheet 
13         xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
14         xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" 
15         exclude-result-prefixes="doc" version="1.0">
16
17
18 <!--############################################################################# -->
19 <!-- DOCUMENTATION                                                                -->
20   <doc:reference xmlns="" id="qandaset">
21     <referenceinfo>
22       <releaseinfo role="meta"> $Id: qandaset.mod.xsl,v 1.1.2.1 2003/05/01 14:06:15 jelmer Exp $ </releaseinfo>
23         <authorgroup>
24         <author> <firstname>Ramon</firstname> <surname>Casellas</surname> </author>
25         <author> <firstname>James</firstname> <surname>Devenish</surname> </author>
26         </authorgroup>
27       <copyright>
28         <year>2000</year> <year>2001</year> <year>2002</year> <year>2003</year>
29         <holder>Ramon Casellas</holder>
30       </copyright>
31     </referenceinfo>
32     <title>QandaSet <filename>qandaset.mod.xsl</filename></title>
33     <partintro>
34       <section>
35         <title>Introduction</title>
36       </section>
37     </partintro>
38   </doc:reference>
39
40
41
42
43 <!--############################################################################# 
44 |   qandaset
45 |-  #############################################################################
46 |                                                                                                               
47 +   ############################################################################# -->
48
49 <xsl:template match="qandaset">
50                 <!-- get all children that are not the following -->
51                 <xsl:variable name="preamble" select="*[name(.) != 'title'
52                                                                           and name(.) != 'titleabbrev'
53                                                                           and name(.) != 'qandadiv'
54                                                                           and name(.) != 'qandaentry']"/>
55                 <xsl:variable name="label-width"/>
56                 <xsl:variable name="table-summary"/>
57                 <xsl:variable name="cellpadding"/>
58                 <xsl:variable name="cellspacing"/>
59                 <xsl:variable name="toc"/>
60                 <xsl:variable name="toc.params"/>
61                 <xsl:variable name="qalevel">
62                 <xsl:call-template name="qanda.section.level"/>
63                 </xsl:variable>
64                 <xsl:text>% -------------------------------------------------------------&#10;</xsl:text>
65                 <xsl:text>% QandASet                                                     &#10;</xsl:text>
66                 <xsl:text>% -------------------------------------------------------------&#10;</xsl:text>
67                 <xsl:choose>
68                 <xsl:when test="ancestor::sect2">
69                         <xsl:text>\subsubsection*{</xsl:text>
70                         </xsl:when>
71                 <xsl:when test="ancestor::sect1">
72                         <xsl:text>\subsection*{</xsl:text>
73                         </xsl:when>
74                 <xsl:when test="ancestor::article | ancestor::appendix">
75                         <xsl:text>\section*{</xsl:text>
76                         </xsl:when>
77                 <xsl:when test="ancestor::book">
78                         <xsl:text>\chapter*{</xsl:text>
79                         </xsl:when>
80                 </xsl:choose>
81                 <xsl:choose>
82                         <xsl:when test="title">
83                                 <xsl:apply-templates select="title"/>
84                         </xsl:when>
85                         <xsl:otherwise>
86                                 <xsl:text>F.A.Q.</xsl:text>
87                         </xsl:otherwise>
88                 </xsl:choose>
89                 <xsl:text>}&#10;</xsl:text>
90             <xsl:call-template name="label.id"/>
91                 <xsl:text>&#10;</xsl:text>
92
93                 <!-- process toc -->
94                 <xsl:if test="contains($toc.params, 'toc') and $toc != '0'">
95                         <xsl:call-template name="process.qanda.toc"/>
96                 </xsl:if>
97                 <!-- process preamble -->
98                 <xsl:apply-templates select="$preamble"/>
99                 <!-- process divs and entries -->
100                 <xsl:apply-templates select="qandaentry|qandadiv"/>
101 </xsl:template>
102
103
104 <xsl:template match="qandaset/title">
105 <xsl:apply-templates/>
106 </xsl:template>
107
108
109
110
111 <!--############################################################################# 
112 |   qandadiv
113 |-  #############################################################################
114 |                                                                                                               
115 +   ############################################################################# -->
116
117
118 <xsl:template match="qandadiv">
119         <!-- get the preamble -->
120   <xsl:variable name="preamble" select="*[name(.) != 'title'
121                                           and name(.) != 'titleabbrev'
122                                           and name(.) != 'qandadiv'
123                                           and name(.) != 'qandaentry']"/>
124   <xsl:variable name="qalevel">
125     <xsl:call-template name="qandadiv.section.level"/>
126   </xsl:variable>
127         <!-- process the title if it exists -->
128                 <xsl:text>% -----------&#10;</xsl:text>
129                 <xsl:text>% QandADiv   &#10;</xsl:text>
130                 <xsl:text>% -----------&#10;</xsl:text>
131                 <xsl:text>\noindent\begin{minipage}{\linewidth}&#10;</xsl:text>
132                 <xsl:text>\vspace{0.25em}\hrule\vspace{0.25em}&#10;</xsl:text>
133                 <xsl:choose>
134                 <xsl:when test="ancestor::sect2">
135                         <xsl:text>\paragraph*{</xsl:text>
136                         </xsl:when>
137                 <xsl:when test="ancestor::sect1">
138                         <xsl:text>\subsubsection*{</xsl:text>
139                         </xsl:when>
140                 <xsl:when test="ancestor::article | ancestor::appendix">
141                         <xsl:text>\subsection*{</xsl:text>
142                         </xsl:when>
143                 <xsl:when test="ancestor::book">
144                         <xsl:text>\section*{</xsl:text>
145                         </xsl:when>
146                 </xsl:choose>
147                 <xsl:choose>
148                         <xsl:when test="title">
149                                 <xsl:apply-templates select="title"/>
150                         </xsl:when>
151                         <xsl:otherwise>
152                                 <xsl:text>F.A.Q. Part</xsl:text>
153                         </xsl:otherwise>
154                 </xsl:choose>
155                 <xsl:text>}</xsl:text>
156                 <xsl:call-template name="label.id"/>
157                 <xsl:text>&#10;</xsl:text>
158                 <xsl:text>\hrule\vspace{0.25em}&#10;</xsl:text>
159                 <xsl:text>\end{minipage}&#10;</xsl:text>
160
161 <!--
162   <xsl:variable name="toc.params">
163   </xsl:variable>
164   <xsl:if test="contains($toc.params, 'toc')">
165         <xsl:call-template name="process.qanda.toc"/>
166   </xsl:if>
167   <xsl:if test="$preamble">
168         <xsl:apply-templates select="$preamble"/>
169   </xsl:if>
170 -->
171 <!--
172         <xsl:text>\begin{toc}&#10;</xsl:text>
173         <xsl:for-each select="qandaentry">
174                 <xsl:text>\tocref{</xsl:text>
175                 <xsl:value-of select="@id"/>
176                 <xsl:text>}&#10;</xsl:text>
177         </xsl:for-each>
178         <xsl:text>\end{toc}&#10;</xsl:text>
179 -->
180
181 <!-- pseudo table of contents -->
182         <!--
183         <xsl:choose>
184                 <xsl:when test="title">
185                         <xsl:text>\caption{</xsl:text>
186                         <xsl:apply-templates select="title"/>
187                         <xsl:text>}&#10;</xsl:text>
188                 </xsl:when>
189                 <xsl:otherwise>
190                         <xsl:text>\caption{</xsl:text>
191                         <xsl:text>F.A.Q. Part</xsl:text>
192                         <xsl:text>}&#10;</xsl:text>
193                 </xsl:otherwise>
194         </xsl:choose>
195         -->
196         <xsl:for-each select="qandaentry">
197         <xsl:text>\noindent{}</xsl:text>
198         <xsl:value-of select="position()"/>
199         <xsl:text>.~</xsl:text>
200         <xsl:apply-templates select="question"/>
201         <xsl:if test="position()!=last()"><xsl:text>\newline&#10;</xsl:text></xsl:if>
202         </xsl:for-each>
203         <xsl:text>\vspace{0.25em}\hrule&#10;</xsl:text>
204
205         <xsl:for-each select="qandaentry">
206         <xsl:text>\vspace{1em}&#10;</xsl:text>
207         <xsl:text>\noindent{}</xsl:text>
208         <xsl:value-of select="position()"/>
209         <xsl:text>.~</xsl:text>
210         <xsl:apply-templates select="question"/>
211         <xsl:text>\newline&#10;</xsl:text>
212         <xsl:apply-templates select="answer"/>
213         </xsl:for-each>
214 <!--  <xsl:apply-templates select="qandadiv|qandaentry"/> -->
215 <!--  <xsl:apply-templates/> -->
216         <xsl:text>\vspace{1em}&#10;</xsl:text>
217 </xsl:template>
218
219
220
221
222
223
224
225
226 <!--############################################################################# 
227 |   qandadiv/title
228 |-  #############################################################################
229 |                                                                                                               
230 +   ############################################################################# -->
231
232 <xsl:template match="qandadiv/title">
233     <!-- <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/> -->
234     <xsl:apply-templates/>
235 </xsl:template>
236
237
238
239
240 <!--############################################################################# 
241 |   question
242 |-  #############################################################################
243 |                                                                                                               
244 +   ############################################################################# -->
245
246 <xsl:template match="question">
247 <!-- get the default label -->
248 <xsl:variable name="deflabel">
249                 <xsl:choose>
250                         <xsl:when test="ancestor-or-self::*[@defaultlabel]">
251                                 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]/@defaultlabel"/>
252                         </xsl:when>
253                         <xsl:otherwise>
254                                 <xsl:value-of select="latex.qanda.defaultlabel"/>
255                         </xsl:otherwise>
256                 </xsl:choose>
257 </xsl:variable>
258 <!-- process the question itself 
259 <xsl:apply-templates select="." mode="label.markup"/>
260 <xsl:choose>
261         <xsl:when test="$deflabel = 'none' and not(label)">
262                 <xsl:apply-templates select="*[name(.) != 'label']"/>
263         </xsl:when>
264         <xsl:otherwise>
265                 <xsl:apply-templates select="*[name(.) != 'label']"/>
266         </xsl:otherwise>
267 </xsl:choose>
268 -->
269 <xsl:text>\textbf{Q:}~\textit{</xsl:text>
270 <xsl:apply-templates/>
271 <xsl:text>}&#10;</xsl:text>
272 </xsl:template>
273
274
275
276
277
278
279
280
281 <!--############################################################################# 
282 |   answer 
283 |-  #############################################################################
284 |                                                                                                               
285 +   ############################################################################# -->
286
287 <xsl:template match="answer">
288 <xsl:text>\noindent\textbf{A:}~</xsl:text>
289 <xsl:apply-templates/>
290 <xsl:text>&#10;&#10;</xsl:text>
291 </xsl:template>
292
293
294
295
296
297
298
299 <!--############################################################################# 
300 |   label 
301 |-  #############################################################################
302 |                                                                                                               
303 +   ############################################################################# -->
304
305 <xsl:template match="label">
306   <xsl:apply-templates/>
307 </xsl:template>
308
309
310 <xsl:template name="process.qanda.toc">
311     <xsl:apply-templates select="qandadiv" mode="qandatoc.mode"/>
312     <xsl:apply-templates select="qandaentry" mode="qandatoc.mode"/>
313 </xsl:template>
314
315 <xsl:template match="qandadiv" mode="qandatoc.mode">
316   <xsl:apply-templates select="title" mode="qandatoc.mode"/>
317   <xsl:call-template name="process.qanda.toc"/>
318 </xsl:template>
319
320
321
322
323
324
325 <xsl:template match="qandadiv/title" mode="qandatoc.mode">
326 <xsl:variable name="qalevel">
327     <xsl:call-template name="qandadiv.section.level"/>
328 </xsl:variable>
329 <xsl:call-template name="label.id">
330         <xsl:with-param name="object" select="parent::*"/>
331 </xsl:call-template>
332 <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
333 <xsl:value-of select="$autotoc.label.separator"/>
334 <xsl:apply-templates/>
335 </xsl:template>
336
337
338
339 <xsl:template match="qandaentry" mode="qandatoc.mode">
340   <xsl:apply-templates mode="qandatoc.mode"/>
341 </xsl:template>
342
343
344
345 <xsl:template match="question" mode="qandatoc.mode">
346   <xsl:variable name="firstch" select="(*[name(.)!='label'])[1]"/>
347     <xsl:apply-templates select="." mode="label.markup"/>
348     <xsl:text> </xsl:text>
349 </xsl:template>
350
351
352 <xsl:template match="answer|revhistory" mode="qandatoc.mode">
353   <!-- nop -->
354 </xsl:template>
355
356
357
358
359 <xsl:template name="question.answer.label">
360         <!-- variable: deflabel -->
361   <xsl:variable name="deflabel">
362         <!-- chck whether someone has a defaultlabel attribute -->
363     <xsl:choose>
364                 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
365                 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]/@defaultlabel"/>
366               </xsl:when>
367       <xsl:otherwise>
368         <xsl:value-of select="latex.qanda.defaultlabel"/>
369       </xsl:otherwise>
370     </xsl:choose>
371   </xsl:variable>
372
373
374   <xsl:variable name="label" select="@label"/>
375   <xsl:choose>
376     <xsl:when test="$deflabel = 'qanda'">
377       <xsl:call-template name="gentext">
378         <xsl:with-param name="key">
379           <xsl:choose>
380             <xsl:when test="local-name(.) = 'question'">question</xsl:when>
381             <xsl:when test="local-name(.) = 'answer'">answer</xsl:when>
382             <xsl:when test="local-name(.) = 'qandadiv'">qandadiv</xsl:when>
383             <xsl:otherwise>qandaset</xsl:otherwise>
384           </xsl:choose>
385         </xsl:with-param>
386       </xsl:call-template>
387     </xsl:when>
388     <xsl:when test="$deflabel = 'label'">
389       <xsl:value-of select="$label"/>
390     </xsl:when>
391     <xsl:when test="$deflabel = 'number' and local-name(.) = 'question'">
392       <xsl:apply-templates select="ancestor::qandaset[1]" mode="number"/>
393       <xsl:choose>
394         <xsl:when test="ancestor::qandadiv">
395           <xsl:apply-templates select="ancestor::qandadiv[1]" mode="number"/>
396           <xsl:apply-templates select="ancestor::qandaentry" mode="number"/>
397         </xsl:when>
398         <xsl:otherwise>
399           <xsl:apply-templates select="ancestor::qandaentry" mode="number"/>
400         </xsl:otherwise>
401       </xsl:choose>
402     </xsl:when>
403     <xsl:otherwise>
404       <!-- nothing -->
405     </xsl:otherwise>
406   </xsl:choose>
407 </xsl:template>
408
409 </xsl:stylesheet>