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 $
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">
17 <doc:reference id=
"qandaset" xmlns=
"">
19 <releaseinfo role=
"meta">
20 $Id: qandaset.mod.xsl,v
1.13 2004/
01/
04 13:
22:
27 j-devenish Exp $
27 <year>2000</year><year>2001</year><year>2002</year><year>2003</year><year>2004</year>
28 <holder>Ramon Casellas
</holder>
31 <doc:revision rcasver=
"1.11">&rev_2003_05;</doc:revision>
34 <title>QandaSet
<filename>qandaset.mod.xsl
</filename></title>
38 Portions (c) Norman Walsh, official DocBook XSL stylesheets. See docbook.sf.net
44 <doc:template xmlns=
"">
45 <refpurpose>Process
<doc:db>qandadiv
</doc:db> elements
</refpurpose>
47 <para><doc:todo>Undocumented.
</doc:todo></para>
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"/>
66 <xsl:text>% -------------------------------------------------------------
</xsl:text>
67 <xsl:text>% QandASet
</xsl:text>
68 <xsl:text>% -------------------------------------------------------------
</xsl:text>
70 <xsl:when test=
"ancestor::sect2">
71 <xsl:text>\subsubsection*{
</xsl:text>
73 <xsl:when test=
"ancestor::sect1">
74 <xsl:text>\subsection*{
</xsl:text>
76 <xsl:when test=
"ancestor::article | ancestor::appendix">
77 <xsl:text>\section*{
</xsl:text>
79 <xsl:when test=
"ancestor::book">
80 <xsl:text>\chapter*{
</xsl:text>
84 <xsl:when test=
"title">
85 <xsl:apply-templates select=
"title"/>
88 <xsl:text>F.A.Q.
</xsl:text>
91 <xsl:text>}
</xsl:text>
92 <xsl:call-template name=
"label.id"/>
93 <xsl:text> </xsl:text>
96 <xsl:if test=
"contains($toc.params, 'toc') and $toc != '0'">
97 <xsl:call-template name=
"process.qanda.toc"/>
99 <!-- process preamble -->
100 <xsl:apply-templates select=
"$preamble"/>
101 <!-- process divs and entries -->
102 <xsl:apply-templates select=
"qandaentry|qandadiv"/>
105 <doc:template basename=
"qandaentry" xmlns=
"">
106 <refpurpose>Process
<doc:db>qandadiv
</doc:db> elements
</refpurpose>
108 <para><doc:todo>Undocumented.
</doc:todo></para>
111 <xsl:template match=
"qandaset/qandaentry">
112 <xsl:text>\vspace{
1em}
</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
</xsl:text>
118 <xsl:apply-templates select=
"answer"/>
119 <xsl:text>\vspace{
1em}
</xsl:text>
122 <doc:template xmlns=
"">
123 <refpurpose>Process
<doc:db>qandadiv
</doc:db> elements
</refpurpose>
125 <para><doc:todo>Undocumented.
</doc:todo></para>
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"/>
137 <!-- process the title if it exists -->
138 <xsl:text>% -----------
</xsl:text>
139 <xsl:text>% QandADiv
</xsl:text>
140 <xsl:text>% -----------
</xsl:text>
141 <xsl:text>\noindent\begin{minipage}{\linewidth}
</xsl:text>
142 <xsl:text>\vspace{
0.25em}\hrule\vspace{
0.25em}
</xsl:text>
144 <xsl:when test=
"ancestor::sect2">
145 <xsl:text>\paragraph*{
</xsl:text>
147 <xsl:when test=
"ancestor::sect1">
148 <xsl:text>\subsubsection*{
</xsl:text>
150 <xsl:when test=
"ancestor::article | ancestor::appendix">
151 <xsl:text>\subsection*{
</xsl:text>
153 <xsl:when test=
"ancestor::book">
154 <xsl:text>\section*{
</xsl:text>
158 <xsl:when test=
"title">
159 <xsl:apply-templates select=
"title"/>
162 <xsl:text>F.A.Q. Part
</xsl:text>
165 <xsl:text>}
</xsl:text>
166 <xsl:call-template name=
"label.id"/>
167 <xsl:text> </xsl:text>
168 <xsl:text>\hrule\vspace{
0.25em}
</xsl:text>
169 <xsl:text>\end{minipage}
</xsl:text>
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:text>\vspace{
1em}
</xsl:text>
217 <doc:template xmlns=
"">
218 <refpurpose>Process
<doc:db>question
</doc:db> elements
</refpurpose>
221 Applies templates as a italicised block, preceded by a bold
222 letter
<quote>Q
</quote>.
229 <para>defaultlabel attributes are not honoured.
</para>
232 <xsl:template match=
"question">
233 <!-- get the default label
234 <xsl:variable name="deflabel">
236 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
237 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]/@defaultlabel"/>
240 <xsl:value-of select="latex.qanda.defaultlabel"/>
245 <!-- process the question itself
246 <xsl:apply-templates select="." mode="label.markup"/>
248 <xsl:when test="$deflabel = 'none' and not(label)">
249 <xsl:apply-templates select="*[name(.) != 'label']"/>
252 <xsl:apply-templates select="*[name(.) != 'label']"/>
256 <xsl:text>\textbf{Q:}~\textit{
</xsl:text>
257 <xsl:apply-templates/>
258 <xsl:text>}
</xsl:text>
261 <doc:template xmlns=
"">
262 <refpurpose>Process
<doc:db>answer
</doc:db> elements
</refpurpose>
265 Applies templates as a block, preceded by a bold
266 letter
<quote>A
</quote>.
273 <xsl:template match=
"answer">
274 <xsl:text>\noindent\textbf{A:}~
</xsl:text>
275 <xsl:apply-templates/>
276 <xsl:text> </xsl:text>
279 <doc:template xmlns=
"">
280 <refpurpose>Process
<doc:db>label
</doc:db> elements
</refpurpose>
290 <xsl:template match=
"label">
291 <xsl:apply-templates/>
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"/>
299 <doc:template basename=
"qandadiv" xmlns=
"">
300 <refpurpose>Process
<doc:db>qandadiv
</doc:db> elements
</refpurpose>
302 <para><doc:todo>Undocumented.
</doc:todo></para>
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"/>
310 <doc:template basename=
"title" xmlns=
"">
311 <refpurpose>Process a
<doc:db>qandadiv
</doc:db>'s
<doc:db>title
</doc:db> elements
</refpurpose>
313 <para><doc:todo>Undocumented.
</doc:todo></para>
316 <xsl:template match=
"qandadiv/title" mode=
"qandatoc.mode">
317 <xsl:variable name=
"qalevel">
318 <xsl:call-template name=
"qandadiv.section.level"/>
320 <xsl:call-template name=
"label.id">
321 <xsl:with-param name=
"object" select=
"parent::*"/>
323 <xsl:apply-templates select=
"parent::qandadiv" mode=
"label.markup"/>
324 <xsl:value-of select=
"$autotoc.label.separator"/>
325 <xsl:apply-templates/>
328 <doc:template xmlns=
"" basename=
"qandaentry">
329 <refpurpose>Process
<doc:db>qandaentry
</doc:db> elements
</refpurpose>
331 <para><doc:todo>Undocumented.
</doc:todo></para>
334 <xsl:template match=
"qandaentry" mode=
"qandatoc.mode">
335 <xsl:apply-templates mode=
"qandatoc.mode"/>
338 <doc:template basename=
"question" xmlns=
"">
339 <refpurpose>Process
<doc:db>question
</doc:db> elements
</refpurpose>
341 <para><doc:todo>Undocumented.
</doc:todo></para>
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>
350 <doc:template xmlns=
"" basename=
"answer">
351 <refpurpose>Process
<doc:db>answer
</doc:db> elements
</refpurpose>
353 <para><doc:todo>Undocumented.
</doc:todo></para>
356 <xsl:template match=
"answer" mode=
"qandatoc.mode"/>
358 <doc:template xmlns=
"" basename=
"revhistory">
359 <refpurpose>Process
<doc:db>revhistory
</doc:db> elements
</refpurpose>
361 <para><doc:todo>Undocumented.
</doc:todo></para>
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 -->
371 <xsl:when test=
"ancestor-or-self::*[@defaultlabel]">
372 <xsl:value-of select=
"(ancestor-or-self::*[@defaultlabel])[last()]/@defaultlabel"/>
375 <xsl:value-of select=
"latex.qanda.defaultlabel"/>
380 <xsl:variable name=
"label" select=
"@label"/>
382 <xsl:when test=
"$deflabel = 'qanda'">
383 <xsl:call-template name=
"gentext">
384 <xsl:with-param name=
"key">
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>
394 <xsl:when test=
"$deflabel = 'label'">
395 <xsl:value-of select=
"$label"/>
397 <xsl:when test=
"$deflabel = 'number' and local-name(.) = 'question'">
398 <xsl:apply-templates select=
"ancestor::qandaset[1]" mode=
"number"/>
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"/>
405 <xsl:apply-templates select=
"ancestor::qandaentry" mode=
"number"/>