2 <!--#############################################################################
3 |- #############################################################################
6 | Portions (c) Norman Walsh, official DocBook XSL stylesheets.
8 + ############################################################################## -->
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">
16 <!--############################################################################# -->
17 <!-- DOCUMENTATION -->
18 <doc:reference xmlns="" id="qandaset">
21 <author> <firstname>Ramon</firstname> <surname>Casellas</surname> </author>
22 <author> <firstname>James</firstname> <surname>Devenish</surname> </author>
25 <year>2000</year> <year>2001</year> <year>2002</year> <year>2003</year>
26 <holder>Ramon Casellas</holder>
29 <title>QandaSet <filename>qandaset.mod.xsl</filename></title>
32 <title>Introduction</title>
40 <!--#############################################################################
42 |- #############################################################################
44 + ############################################################################# -->
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"/>
61 <xsl:text>% ------------------------------------------------------------- </xsl:text>
62 <xsl:text>% QandASet </xsl:text>
63 <xsl:text>% ------------------------------------------------------------- </xsl:text>
65 <xsl:when test="ancestor::sect2">
66 <xsl:text>\subsubsection*{</xsl:text>
68 <xsl:when test="ancestor::sect1">
69 <xsl:text>\subsection*{</xsl:text>
71 <xsl:when test="ancestor::article | ancestor::appendix">
72 <xsl:text>\section*{</xsl:text>
74 <xsl:when test="ancestor::book">
75 <xsl:text>\chapter*{</xsl:text>
79 <xsl:when test="title">
80 <xsl:apply-templates select="title"/>
83 <xsl:text>F.A.Q.</xsl:text>
86 <xsl:text>} </xsl:text>
87 <xsl:call-template name="label.id"/>
88 <xsl:text> </xsl:text>
91 <xsl:if test="contains($toc.params, 'toc') and $toc != '0'">
92 <xsl:call-template name="process.qanda.toc"/>
94 <!-- process preamble -->
95 <xsl:apply-templates select="$preamble"/>
96 <!-- process divs and entries -->
97 <xsl:apply-templates select="qandaentry|qandadiv"/>
101 <xsl:template match="qandaset/title">
102 <xsl:apply-templates/>
108 <!--#############################################################################
110 |- #############################################################################
112 + ############################################################################# -->
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"/>
124 <!-- process the title if it exists -->
125 <xsl:text>% ----------- </xsl:text>
126 <xsl:text>% QandADiv </xsl:text>
127 <xsl:text>% ----------- </xsl:text>
128 <xsl:text>\noindent\begin{minipage}{\linewidth} </xsl:text>
129 <xsl:text>\vspace{0.25em}\hrule\vspace{0.25em} </xsl:text>
131 <xsl:when test="ancestor::sect2">
132 <xsl:text>\paragraph*{</xsl:text>
134 <xsl:when test="ancestor::sect1">
135 <xsl:text>\subsubsection*{</xsl:text>
137 <xsl:when test="ancestor::article | ancestor::appendix">
138 <xsl:text>\subsection*{</xsl:text>
140 <xsl:when test="ancestor::book">
141 <xsl:text>\section*{</xsl:text>
145 <xsl:when test="title">
146 <xsl:apply-templates select="title"/>
149 <xsl:text>F.A.Q. Part</xsl:text>
152 <xsl:text>}</xsl:text>
153 <xsl:call-template name="label.id"/>
154 <xsl:text> </xsl:text>
155 <xsl:text>\hrule\vspace{0.25em} </xsl:text>
156 <xsl:text>\end{minipage} </xsl:text>
159 <xsl:variable name="toc.params">
161 <xsl:if test="contains($toc.params, 'toc')">
162 <xsl:call-template name="process.qanda.toc"/>
164 <xsl:if test="$preamble">
165 <xsl:apply-templates select="$preamble"/>
169 <xsl:text>\begin{toc} </xsl:text>
170 <xsl:for-each select="qandaentry">
171 <xsl:text>\tocref{</xsl:text>
172 <xsl:value-of select="@id"/>
173 <xsl:text>} </xsl:text>
175 <xsl:text>\end{toc} </xsl:text>
178 <!-- pseudo table of contents -->
181 <xsl:when test="title">
182 <xsl:text>\caption{</xsl:text>
183 <xsl:apply-templates select="title"/>
184 <xsl:text>} </xsl:text>
187 <xsl:text>\caption{</xsl:text>
188 <xsl:text>F.A.Q. Part</xsl:text>
189 <xsl:text>} </xsl:text>
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 </xsl:text></xsl:if>
200 <xsl:text>\vspace{0.25em}\hrule </xsl:text>
202 <xsl:for-each select="qandaentry">
203 <xsl:text>\vspace{1em} </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 </xsl:text>
209 <xsl:apply-templates select="answer"/>
211 <!-- <xsl:apply-templates select="qandadiv|qandaentry"/> -->
212 <!-- <xsl:apply-templates/> -->
213 <xsl:text>\vspace{1em} </xsl:text>
223 <!--#############################################################################
225 |- #############################################################################
227 + ############################################################################# -->
229 <xsl:template match="qandadiv/title">
230 <!-- <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/> -->
231 <xsl:apply-templates/>
237 <!--#############################################################################
239 |- #############################################################################
241 + ############################################################################# -->
243 <xsl:template match="question">
244 <!-- get the default label -->
245 <xsl:variable name="deflabel">
247 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
248 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]/@defaultlabel"/>
251 <xsl:value-of select="latex.qanda.defaultlabel"/>
255 <!-- process the question itself
256 <xsl:apply-templates select="." mode="label.markup"/>
258 <xsl:when test="$deflabel = 'none' and not(label)">
259 <xsl:apply-templates select="*[name(.) != 'label']"/>
262 <xsl:apply-templates select="*[name(.) != 'label']"/>
266 <xsl:text>\textbf{Q:}~\textit{</xsl:text>
267 <xsl:apply-templates/>
268 <xsl:text>} </xsl:text>
278 <!--#############################################################################
280 |- #############################################################################
282 + ############################################################################# -->
284 <xsl:template match="answer">
285 <xsl:text>\noindent\textbf{A:}~</xsl:text>
286 <xsl:apply-templates/>
287 <xsl:text> </xsl:text>
296 <!--#############################################################################
298 |- #############################################################################
300 + ############################################################################# -->
302 <xsl:template match="label">
303 <xsl:apply-templates/>
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"/>
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"/>
322 <xsl:template match="qandadiv/title" mode="qandatoc.mode">
323 <xsl:variable name="qalevel">
324 <xsl:call-template name="qandadiv.section.level"/>
326 <xsl:call-template name="label.id">
327 <xsl:with-param name="object" select="parent::*"/>
329 <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
330 <xsl:value-of select="$autotoc.label.separator"/>
331 <xsl:apply-templates/>
336 <xsl:template match="qandaentry" mode="qandatoc.mode">
337 <xsl:apply-templates mode="qandatoc.mode"/>
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>
349 <xsl:template match="answer|revhistory" mode="qandatoc.mode">
356 <xsl:template name="question.answer.label">
357 <!-- variable: deflabel -->
358 <xsl:variable name="deflabel">
359 <!-- chck whether someone has a defaultlabel attribute -->
361 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
362 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]/@defaultlabel"/>
365 <xsl:value-of select="latex.qanda.defaultlabel"/>
371 <xsl:variable name="label" select="@label"/>
373 <xsl:when test="$deflabel = 'qanda'">
374 <xsl:call-template name="gentext">
375 <xsl:with-param name="key">
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>
385 <xsl:when test="$deflabel = 'label'">
386 <xsl:value-of select="$label"/>
388 <xsl:when test="$deflabel = 'number' and local-name(.) = 'question'">
389 <xsl:apply-templates select="ancestor::qandaset[1]" mode="number"/>
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"/>
396 <xsl:apply-templates select="ancestor::qandaentry" mode="number"/>