2 <!--#############################################################################
3 | $Id: qandaset.mod.xsl,v 1.1.2.1 2003/05/01 14:06:15 jelmer Exp $
4 |- #############################################################################
8 | Portions (c) Norman Walsh, official DocBook XSL stylesheets.
10 + ############################################################################## -->
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">
18 <!--############################################################################# -->
19 <!-- DOCUMENTATION -->
20 <doc:reference xmlns="" id="qandaset">
22 <releaseinfo role="meta"> $Id: qandaset.mod.xsl,v 1.1.2.1 2003/05/01 14:06:15 jelmer Exp $ </releaseinfo>
24 <author> <firstname>Ramon</firstname> <surname>Casellas</surname> </author>
25 <author> <firstname>James</firstname> <surname>Devenish</surname> </author>
28 <year>2000</year> <year>2001</year> <year>2002</year> <year>2003</year>
29 <holder>Ramon Casellas</holder>
32 <title>QandaSet <filename>qandaset.mod.xsl</filename></title>
35 <title>Introduction</title>
43 <!--#############################################################################
45 |- #############################################################################
47 + ############################################################################# -->
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"/>
64 <xsl:text>% ------------------------------------------------------------- </xsl:text>
65 <xsl:text>% QandASet </xsl:text>
66 <xsl:text>% ------------------------------------------------------------- </xsl:text>
68 <xsl:when test="ancestor::sect2">
69 <xsl:text>\subsubsection*{</xsl:text>
71 <xsl:when test="ancestor::sect1">
72 <xsl:text>\subsection*{</xsl:text>
74 <xsl:when test="ancestor::article | ancestor::appendix">
75 <xsl:text>\section*{</xsl:text>
77 <xsl:when test="ancestor::book">
78 <xsl:text>\chapter*{</xsl:text>
82 <xsl:when test="title">
83 <xsl:apply-templates select="title"/>
86 <xsl:text>F.A.Q.</xsl:text>
89 <xsl:text>} </xsl:text>
90 <xsl:call-template name="label.id"/>
91 <xsl:text> </xsl:text>
94 <xsl:if test="contains($toc.params, 'toc') and $toc != '0'">
95 <xsl:call-template name="process.qanda.toc"/>
97 <!-- process preamble -->
98 <xsl:apply-templates select="$preamble"/>
99 <!-- process divs and entries -->
100 <xsl:apply-templates select="qandaentry|qandadiv"/>
104 <xsl:template match="qandaset/title">
105 <xsl:apply-templates/>
111 <!--#############################################################################
113 |- #############################################################################
115 + ############################################################################# -->
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"/>
127 <!-- process the title if it exists -->
128 <xsl:text>% ----------- </xsl:text>
129 <xsl:text>% QandADiv </xsl:text>
130 <xsl:text>% ----------- </xsl:text>
131 <xsl:text>\noindent\begin{minipage}{\linewidth} </xsl:text>
132 <xsl:text>\vspace{0.25em}\hrule\vspace{0.25em} </xsl:text>
134 <xsl:when test="ancestor::sect2">
135 <xsl:text>\paragraph*{</xsl:text>
137 <xsl:when test="ancestor::sect1">
138 <xsl:text>\subsubsection*{</xsl:text>
140 <xsl:when test="ancestor::article | ancestor::appendix">
141 <xsl:text>\subsection*{</xsl:text>
143 <xsl:when test="ancestor::book">
144 <xsl:text>\section*{</xsl:text>
148 <xsl:when test="title">
149 <xsl:apply-templates select="title"/>
152 <xsl:text>F.A.Q. Part</xsl:text>
155 <xsl:text>}</xsl:text>
156 <xsl:call-template name="label.id"/>
157 <xsl:text> </xsl:text>
158 <xsl:text>\hrule\vspace{0.25em} </xsl:text>
159 <xsl:text>\end{minipage} </xsl:text>
162 <xsl:variable name="toc.params">
164 <xsl:if test="contains($toc.params, 'toc')">
165 <xsl:call-template name="process.qanda.toc"/>
167 <xsl:if test="$preamble">
168 <xsl:apply-templates select="$preamble"/>
172 <xsl:text>\begin{toc} </xsl:text>
173 <xsl:for-each select="qandaentry">
174 <xsl:text>\tocref{</xsl:text>
175 <xsl:value-of select="@id"/>
176 <xsl:text>} </xsl:text>
178 <xsl:text>\end{toc} </xsl:text>
181 <!-- pseudo table of contents -->
184 <xsl:when test="title">
185 <xsl:text>\caption{</xsl:text>
186 <xsl:apply-templates select="title"/>
187 <xsl:text>} </xsl:text>
190 <xsl:text>\caption{</xsl:text>
191 <xsl:text>F.A.Q. Part</xsl:text>
192 <xsl:text>} </xsl:text>
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 </xsl:text></xsl:if>
203 <xsl:text>\vspace{0.25em}\hrule </xsl:text>
205 <xsl:for-each select="qandaentry">
206 <xsl:text>\vspace{1em} </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 </xsl:text>
212 <xsl:apply-templates select="answer"/>
214 <!-- <xsl:apply-templates select="qandadiv|qandaentry"/> -->
215 <!-- <xsl:apply-templates/> -->
216 <xsl:text>\vspace{1em} </xsl:text>
226 <!--#############################################################################
228 |- #############################################################################
230 + ############################################################################# -->
232 <xsl:template match="qandadiv/title">
233 <!-- <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/> -->
234 <xsl:apply-templates/>
240 <!--#############################################################################
242 |- #############################################################################
244 + ############################################################################# -->
246 <xsl:template match="question">
247 <!-- get the default label -->
248 <xsl:variable name="deflabel">
250 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
251 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]/@defaultlabel"/>
254 <xsl:value-of select="latex.qanda.defaultlabel"/>
258 <!-- process the question itself
259 <xsl:apply-templates select="." mode="label.markup"/>
261 <xsl:when test="$deflabel = 'none' and not(label)">
262 <xsl:apply-templates select="*[name(.) != 'label']"/>
265 <xsl:apply-templates select="*[name(.) != 'label']"/>
269 <xsl:text>\textbf{Q:}~\textit{</xsl:text>
270 <xsl:apply-templates/>
271 <xsl:text>} </xsl:text>
281 <!--#############################################################################
283 |- #############################################################################
285 + ############################################################################# -->
287 <xsl:template match="answer">
288 <xsl:text>\noindent\textbf{A:}~</xsl:text>
289 <xsl:apply-templates/>
290 <xsl:text> </xsl:text>
299 <!--#############################################################################
301 |- #############################################################################
303 + ############################################################################# -->
305 <xsl:template match="label">
306 <xsl:apply-templates/>
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"/>
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"/>
325 <xsl:template match="qandadiv/title" mode="qandatoc.mode">
326 <xsl:variable name="qalevel">
327 <xsl:call-template name="qandadiv.section.level"/>
329 <xsl:call-template name="label.id">
330 <xsl:with-param name="object" select="parent::*"/>
332 <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
333 <xsl:value-of select="$autotoc.label.separator"/>
334 <xsl:apply-templates/>
339 <xsl:template match="qandaentry" mode="qandatoc.mode">
340 <xsl:apply-templates mode="qandatoc.mode"/>
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>
352 <xsl:template match="answer|revhistory" mode="qandatoc.mode">
359 <xsl:template name="question.answer.label">
360 <!-- variable: deflabel -->
361 <xsl:variable name="deflabel">
362 <!-- chck whether someone has a defaultlabel attribute -->
364 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
365 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]/@defaultlabel"/>
368 <xsl:value-of select="latex.qanda.defaultlabel"/>
374 <xsl:variable name="label" select="@label"/>
376 <xsl:when test="$deflabel = 'qanda'">
377 <xsl:call-template name="gentext">
378 <xsl:with-param name="key">
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>
388 <xsl:when test="$deflabel = 'label'">
389 <xsl:value-of select="$label"/>
391 <xsl:when test="$deflabel = 'number' and local-name(.) = 'question'">
392 <xsl:apply-templates select="ancestor::qandaset[1]" mode="number"/>
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"/>
399 <xsl:apply-templates select="ancestor::qandaentry" mode="number"/>