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