Next update of VFS modules development guide
[Samba.git] / docs / xslt / db2latex-xsl / xsl / qandaset.mod.xsl
blob3cf6fb9de4c5c95b8857cd9ddf07dfbfda192a5d
1 <?xml version="1.0"?>
2 <!DOCTYPE xsl:stylesheet [ <!ENTITY % xsldoc.ent SYSTEM "./xsldoc.ent"> %xsldoc.ent; ]>
3 <!--#############################################################################
4 | $Id: qandaset.mod.xsl,v 1.13 2004/01/04 13:22:27 j-devenish Exp $
5 |- #############################################################################
6 | $Author: j-devenish $
7 | PURPOSE:
8 | Portions (c) Norman Walsh, official DocBook XSL stylesheets.
9 | See docbook.sf.net
10 + ############################################################################## -->
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">
17 <doc:reference id="qandaset" xmlns="">
18 <referenceinfo>
19 <releaseinfo role="meta">
20 $Id: qandaset.mod.xsl,v 1.13 2004/01/04 13:22:27 j-devenish Exp $
21 </releaseinfo>
22 <authorgroup>
23 &ramon;
24 &james;
25 </authorgroup>
26 <copyright>
27 <year>2000</year><year>2001</year><year>2002</year><year>2003</year><year>2004</year>
28 <holder>Ramon Casellas</holder>
29 </copyright>
30 <revhistory>
31 <doc:revision rcasver="1.11">&rev_2003_05;</doc:revision>
32 </revhistory>
33 </referenceinfo>
34 <title>QandaSet <filename>qandaset.mod.xsl</filename></title>
35 <partintro>
36 <para>
38 Portions (c) Norman Walsh, official DocBook XSL stylesheets. See docbook.sf.net
40 </para>
41 </partintro>
42 </doc:reference>
44 <doc:template xmlns="">
45 <refpurpose>Process <doc:db>qandadiv</doc:db> elements</refpurpose>
46 <doc:description>
47 <para><doc:todo>Undocumented.</doc:todo></para>
48 </doc:description>
49 </doc:template>
50 <xsl:template match="qandaset">
51 <!-- get all children that are not the following -->
52 <xsl:variable name="preamble" select="*[name(.) != 'title'
53 and name(.) != 'titleabbrev'
54 and name(.) != 'blockinfo'
55 and name(.) != 'qandadiv'
56 and name(.) != 'qandaentry']"/>
57 <xsl:variable name="label-width"/>
58 <xsl:variable name="table-summary"/>
59 <xsl:variable name="cellpadding"/>
60 <xsl:variable name="cellspacing"/>
61 <xsl:variable name="toc"/>
62 <xsl:variable name="toc.params"/>
63 <xsl:variable name="qalevel">
64 <xsl:call-template name="qanda.section.level"/>
65 </xsl:variable>
66 <xsl:text>% -------------------------------------------------------------&#10;</xsl:text>
67 <xsl:text>% QandASet &#10;</xsl:text>
68 <xsl:text>% -------------------------------------------------------------&#10;</xsl:text>
69 <xsl:choose>
70 <xsl:when test="ancestor::sect2">
71 <xsl:text>\subsubsection*{</xsl:text>
72 </xsl:when>
73 <xsl:when test="ancestor::sect1">
74 <xsl:text>\subsection*{</xsl:text>
75 </xsl:when>
76 <xsl:when test="ancestor::article | ancestor::appendix">
77 <xsl:text>\section*{</xsl:text>
78 </xsl:when>
79 <xsl:when test="ancestor::book">
80 <xsl:text>\chapter*{</xsl:text>
81 </xsl:when>
82 </xsl:choose>
83 <xsl:choose>
84 <xsl:when test="title">
85 <xsl:apply-templates select="title"/>
86 </xsl:when>
87 <xsl:otherwise>
88 <xsl:text>F.A.Q.</xsl:text>
89 </xsl:otherwise>
90 </xsl:choose>
91 <xsl:text>}&#10;</xsl:text>
92 <xsl:call-template name="label.id"/>
93 <xsl:text>&#10;</xsl:text>
95 <!-- process toc -->
96 <xsl:if test="contains($toc.params, 'toc') and $toc != '0'">
97 <xsl:call-template name="process.qanda.toc"/>
98 </xsl:if>
99 <!-- process preamble -->
100 <xsl:apply-templates select="$preamble"/>
101 <!-- process divs and entries -->
102 <xsl:apply-templates select="qandaentry|qandadiv"/>
103 </xsl:template>
105 <doc:template basename="qandaentry" xmlns="">
106 <refpurpose>Process <doc:db>qandadiv</doc:db> elements</refpurpose>
107 <doc:description>
108 <para><doc:todo>Undocumented.</doc:todo></para>
109 </doc:description>
110 </doc:template>
111 <xsl:template match="qandaset/qandaentry">
112 <xsl:text>\vspace{1em}&#10;</xsl:text>
113 <xsl:text>\noindent{}</xsl:text>
114 <xsl:value-of select="position()"/>
115 <xsl:text>.~</xsl:text>
116 <xsl:apply-templates select="question"/>
117 <xsl:text>\newline&#10;</xsl:text>
118 <xsl:apply-templates select="answer"/>
119 <xsl:text>\vspace{1em}&#10;</xsl:text>
120 </xsl:template>
122 <doc:template xmlns="">
123 <refpurpose>Process <doc:db>qandadiv</doc:db> elements</refpurpose>
124 <doc:description>
125 <para><doc:todo>Undocumented.</doc:todo></para>
126 </doc:description>
127 </doc:template>
128 <xsl:template match="qandadiv">
129 <!-- get the preamble -->
130 <xsl:variable name="preamble" select="*[name(.) != 'title'
131 and name(.) != 'titleabbrev'
132 and name(.) != 'qandadiv'
133 and name(.) != 'qandaentry']"/>
134 <xsl:variable name="qalevel">
135 <xsl:call-template name="qandadiv.section.level"/>
136 </xsl:variable>
137 <!-- process the title if it exists -->
138 <xsl:text>% -----------&#10;</xsl:text>
139 <xsl:text>% QandADiv &#10;</xsl:text>
140 <xsl:text>% -----------&#10;</xsl:text>
141 <xsl:text>\noindent\begin{minipage}{\linewidth}&#10;</xsl:text>
142 <xsl:text>\vspace{0.25em}\hrule\vspace{0.25em}&#10;</xsl:text>
143 <xsl:choose>
144 <xsl:when test="ancestor::sect2">
145 <xsl:text>\paragraph*{</xsl:text>
146 </xsl:when>
147 <xsl:when test="ancestor::sect1">
148 <xsl:text>\subsubsection*{</xsl:text>
149 </xsl:when>
150 <xsl:when test="ancestor::article | ancestor::appendix">
151 <xsl:text>\subsection*{</xsl:text>
152 </xsl:when>
153 <xsl:when test="ancestor::book">
154 <xsl:text>\section*{</xsl:text>
155 </xsl:when>
156 </xsl:choose>
157 <xsl:choose>
158 <xsl:when test="title">
159 <xsl:apply-templates select="title"/>
160 </xsl:when>
161 <xsl:otherwise>
162 <xsl:text>F.A.Q. Part</xsl:text>
163 </xsl:otherwise>
164 </xsl:choose>
165 <xsl:text>}</xsl:text>
166 <xsl:call-template name="label.id"/>
167 <xsl:text>&#10;</xsl:text>
168 <xsl:text>\hrule\vspace{0.25em}&#10;</xsl:text>
169 <xsl:text>\end{minipage}&#10;</xsl:text>
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>
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>
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>
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:text>\vspace{1em}&#10;</xsl:text>
215 </xsl:template>
217 <doc:template xmlns="">
218 <refpurpose>Process <doc:db>question</doc:db> elements</refpurpose>
219 <doc:description>
220 <para>
221 Applies templates as a italicised block, preceded by a bold
222 letter <quote>Q</quote>.
223 </para>
224 </doc:description>
225 <doc:variables>
226 &no_var;
227 </doc:variables>
228 <doc:notes>
229 <para>defaultlabel attributes are not honoured.</para>
230 </doc:notes>
231 </doc:template>
232 <xsl:template match="question">
233 <!-- get the default label
234 <xsl:variable name="deflabel">
235 <xsl:choose>
236 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
237 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]/@defaultlabel"/>
238 </xsl:when>
239 <xsl:otherwise>
240 <xsl:value-of select="latex.qanda.defaultlabel"/>
241 </xsl:otherwise>
242 </xsl:choose>
243 </xsl:variable>
245 <!-- process the question itself
246 <xsl:apply-templates select="." mode="label.markup"/>
247 <xsl:choose>
248 <xsl:when test="$deflabel = 'none' and not(label)">
249 <xsl:apply-templates select="*[name(.) != 'label']"/>
250 </xsl:when>
251 <xsl:otherwise>
252 <xsl:apply-templates select="*[name(.) != 'label']"/>
253 </xsl:otherwise>
254 </xsl:choose>
256 <xsl:text>\textbf{Q:}~\textit{</xsl:text>
257 <xsl:apply-templates/>
258 <xsl:text>}&#10;</xsl:text>
259 </xsl:template>
261 <doc:template xmlns="">
262 <refpurpose>Process <doc:db>answer</doc:db> elements</refpurpose>
263 <doc:description>
264 <para>
265 Applies templates as a block, preceded by a bold
266 letter <quote>A</quote>.
267 </para>
268 </doc:description>
269 <doc:variables>
270 &no_var;
271 </doc:variables>
272 </doc:template>
273 <xsl:template match="answer">
274 <xsl:text>\noindent\textbf{A:}~</xsl:text>
275 <xsl:apply-templates/>
276 <xsl:text>&#10;&#10;</xsl:text>
277 </xsl:template>
279 <doc:template xmlns="">
280 <refpurpose>Process <doc:db>label</doc:db> elements</refpurpose>
281 <doc:description>
282 <para>
283 Applies templates.
284 </para>
285 </doc:description>
286 <doc:variables>
287 &no_var;
288 </doc:variables>
289 </doc:template>
290 <xsl:template match="label">
291 <xsl:apply-templates/>
292 </xsl:template>
294 <xsl:template name="process.qanda.toc">
295 <xsl:apply-templates select="qandadiv" mode="qandatoc.mode"/>
296 <xsl:apply-templates select="qandaentry" mode="qandatoc.mode"/>
297 </xsl:template>
299 <doc:template basename="qandadiv" xmlns="">
300 <refpurpose>Process <doc:db>qandadiv</doc:db> elements</refpurpose>
301 <doc:description>
302 <para><doc:todo>Undocumented.</doc:todo></para>
303 </doc:description>
304 </doc:template>
305 <xsl:template match="qandadiv" mode="qandatoc.mode">
306 <xsl:apply-templates select="title" mode="qandatoc.mode"/>
307 <xsl:call-template name="process.qanda.toc"/>
308 </xsl:template>
310 <doc:template basename="title" xmlns="">
311 <refpurpose>Process a <doc:db>qandadiv</doc:db>'s <doc:db>title</doc:db> elements</refpurpose>
312 <doc:description>
313 <para><doc:todo>Undocumented.</doc:todo></para>
314 </doc:description>
315 </doc:template>
316 <xsl:template match="qandadiv/title" mode="qandatoc.mode">
317 <xsl:variable name="qalevel">
318 <xsl:call-template name="qandadiv.section.level"/>
319 </xsl:variable>
320 <xsl:call-template name="label.id">
321 <xsl:with-param name="object" select="parent::*"/>
322 </xsl:call-template>
323 <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
324 <xsl:value-of select="$autotoc.label.separator"/>
325 <xsl:apply-templates/>
326 </xsl:template>
328 <doc:template xmlns="" basename="qandaentry">
329 <refpurpose>Process <doc:db>qandaentry</doc:db> elements</refpurpose>
330 <doc:description>
331 <para><doc:todo>Undocumented.</doc:todo></para>
332 </doc:description>
333 </doc:template>
334 <xsl:template match="qandaentry" mode="qandatoc.mode">
335 <xsl:apply-templates mode="qandatoc.mode"/>
336 </xsl:template>
338 <doc:template basename="question" xmlns="">
339 <refpurpose>Process <doc:db>question</doc:db> elements</refpurpose>
340 <doc:description>
341 <para><doc:todo>Undocumented.</doc:todo></para>
342 </doc:description>
343 </doc:template>
344 <xsl:template match="question" mode="qandatoc.mode">
345 <xsl:variable name="firstch" select="(*[name(.)!='label'])[1]"/>
346 <xsl:apply-templates select="." mode="label.markup"/>
347 <xsl:text> </xsl:text>
348 </xsl:template>
350 <doc:template xmlns="" basename="answer">
351 <refpurpose>Process <doc:db>answer</doc:db> elements</refpurpose>
352 <doc:description>
353 <para><doc:todo>Undocumented.</doc:todo></para>
354 </doc:description>
355 </doc:template>
356 <xsl:template match="answer" mode="qandatoc.mode"/>
358 <doc:template xmlns="" basename="revhistory">
359 <refpurpose>Process <doc:db>revhistory</doc:db> elements</refpurpose>
360 <doc:description>
361 <para><doc:todo>Undocumented.</doc:todo></para>
362 </doc:description>
363 </doc:template>
364 <xsl:template match="revhistory" mode="qandatoc.mode"/>
366 <xsl:template name="question.answer.label">
367 <!-- variable: deflabel -->
368 <xsl:variable name="deflabel">
369 <!-- chck whether someone has a defaultlabel attribute -->
370 <xsl:choose>
371 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
372 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]/@defaultlabel"/>
373 </xsl:when>
374 <xsl:otherwise>
375 <xsl:value-of select="latex.qanda.defaultlabel"/>
376 </xsl:otherwise>
377 </xsl:choose>
378 </xsl:variable>
380 <xsl:variable name="label" select="@label"/>
381 <xsl:choose>
382 <xsl:when test="$deflabel = 'qanda'">
383 <xsl:call-template name="gentext">
384 <xsl:with-param name="key">
385 <xsl:choose>
386 <xsl:when test="local-name(.) = 'question'">question</xsl:when>
387 <xsl:when test="local-name(.) = 'answer'">answer</xsl:when>
388 <xsl:when test="local-name(.) = 'qandadiv'">qandadiv</xsl:when>
389 <xsl:otherwise>qandaset</xsl:otherwise>
390 </xsl:choose>
391 </xsl:with-param>
392 </xsl:call-template>
393 </xsl:when>
394 <xsl:when test="$deflabel = 'label'">
395 <xsl:value-of select="$label"/>
396 </xsl:when>
397 <xsl:when test="$deflabel = 'number' and local-name(.) = 'question'">
398 <xsl:apply-templates select="ancestor::qandaset[1]" mode="number"/>
399 <xsl:choose>
400 <xsl:when test="ancestor::qandadiv">
401 <xsl:apply-templates select="ancestor::qandadiv[1]" mode="number"/>
402 <xsl:apply-templates select="ancestor::qandaentry" mode="number"/>
403 </xsl:when>
404 <xsl:otherwise>
405 <xsl:apply-templates select="ancestor::qandaentry" mode="number"/>
406 </xsl:otherwise>
407 </xsl:choose>
408 </xsl:when>
409 <xsl:otherwise>
410 <!-- nothing -->
411 </xsl:otherwise>
412 </xsl:choose>
413 </xsl:template>
415 </xsl:stylesheet>