1 | <?xml version='1.0'?>
|
---|
2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
3 | xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
|
---|
4 | exclude-result-prefixes="doc"
|
---|
5 | version='1.0'>
|
---|
6 |
|
---|
7 | <!-- ********************************************************************
|
---|
8 | $Id: qandaset.xsl,v 1.19 2003/09/27 22:01:59 nwalsh Exp $
|
---|
9 | ********************************************************************
|
---|
10 |
|
---|
11 | This file is part of the XSL DocBook Stylesheet distribution.
|
---|
12 | See ../README or http://nwalsh.com/docbook/xsl/ for copyright
|
---|
13 | and other information.
|
---|
14 |
|
---|
15 | ******************************************************************** -->
|
---|
16 |
|
---|
17 | <!-- ==================================================================== -->
|
---|
18 |
|
---|
19 | <xsl:template match="qandaset">
|
---|
20 | <xsl:variable name="title" select="(blockinfo/title|title)[1]"/>
|
---|
21 | <xsl:variable name="preamble" select="*[name(.) != 'title'
|
---|
22 | and name(.) != 'titleabbrev'
|
---|
23 | and name(.) != 'qandadiv'
|
---|
24 | and name(.) != 'qandaentry']"/>
|
---|
25 | <xsl:variable name="label-width">
|
---|
26 | <xsl:call-template name="dbhtml-attribute">
|
---|
27 | <xsl:with-param name="pis"
|
---|
28 | select="processing-instruction('dbhtml')"/>
|
---|
29 | <xsl:with-param name="attribute" select="'label-width'"/>
|
---|
30 | </xsl:call-template>
|
---|
31 | </xsl:variable>
|
---|
32 |
|
---|
33 | <xsl:variable name="table-summary">
|
---|
34 | <xsl:call-template name="dbhtml-attribute">
|
---|
35 | <xsl:with-param name="pis"
|
---|
36 | select="processing-instruction('dbhtml')"/>
|
---|
37 | <xsl:with-param name="attribute" select="'table-summary'"/>
|
---|
38 | </xsl:call-template>
|
---|
39 | </xsl:variable>
|
---|
40 |
|
---|
41 | <xsl:variable name="cellpadding">
|
---|
42 | <xsl:call-template name="dbhtml-attribute">
|
---|
43 | <xsl:with-param name="pis"
|
---|
44 | select="processing-instruction('dbhtml')"/>
|
---|
45 | <xsl:with-param name="attribute" select="'cellpadding'"/>
|
---|
46 | </xsl:call-template>
|
---|
47 | </xsl:variable>
|
---|
48 |
|
---|
49 | <xsl:variable name="cellspacing">
|
---|
50 | <xsl:call-template name="dbhtml-attribute">
|
---|
51 | <xsl:with-param name="pis"
|
---|
52 | select="processing-instruction('dbhtml')"/>
|
---|
53 | <xsl:with-param name="attribute" select="'cellspacing'"/>
|
---|
54 | </xsl:call-template>
|
---|
55 | </xsl:variable>
|
---|
56 |
|
---|
57 | <xsl:variable name="toc">
|
---|
58 | <xsl:call-template name="dbhtml-attribute">
|
---|
59 | <xsl:with-param name="pis"
|
---|
60 | select="processing-instruction('dbhtml')"/>
|
---|
61 | <xsl:with-param name="attribute" select="'toc'"/>
|
---|
62 | </xsl:call-template>
|
---|
63 | </xsl:variable>
|
---|
64 |
|
---|
65 | <xsl:variable name="toc.params">
|
---|
66 | <xsl:call-template name="find.path.params">
|
---|
67 | <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
|
---|
68 | </xsl:call-template>
|
---|
69 | </xsl:variable>
|
---|
70 |
|
---|
71 | <div class="{name(.)}">
|
---|
72 | <xsl:apply-templates select="$title"/>
|
---|
73 | <xsl:if test="(contains($toc.params, 'toc') and $toc != '0') or $toc = '1'">
|
---|
74 | <xsl:call-template name="process.qanda.toc"/>
|
---|
75 | </xsl:if>
|
---|
76 | <xsl:apply-templates select="$preamble"/>
|
---|
77 | <table border="0" summary="Q and A Set">
|
---|
78 | <xsl:if test="$table-summary != ''">
|
---|
79 | <xsl:attribute name="summary">
|
---|
80 | <xsl:value-of select="$table-summary"/>
|
---|
81 | </xsl:attribute>
|
---|
82 | </xsl:if>
|
---|
83 |
|
---|
84 | <xsl:if test="$cellpadding != ''">
|
---|
85 | <xsl:attribute name="cellpadding">
|
---|
86 | <xsl:value-of select="$cellpadding"/>
|
---|
87 | </xsl:attribute>
|
---|
88 | </xsl:if>
|
---|
89 |
|
---|
90 | <xsl:if test="$cellspacing != ''">
|
---|
91 | <xsl:attribute name="cellspacing">
|
---|
92 | <xsl:value-of select="$cellspacing"/>
|
---|
93 | </xsl:attribute>
|
---|
94 | </xsl:if>
|
---|
95 |
|
---|
96 | <col align="left">
|
---|
97 | <xsl:attribute name="width">
|
---|
98 | <xsl:choose>
|
---|
99 | <xsl:when test="$label-width != ''">
|
---|
100 | <xsl:value-of select="$label-width"/>
|
---|
101 | </xsl:when>
|
---|
102 | <xsl:otherwise>1%</xsl:otherwise>
|
---|
103 | </xsl:choose>
|
---|
104 | </xsl:attribute>
|
---|
105 | </col>
|
---|
106 | <tbody>
|
---|
107 | <xsl:apply-templates select="qandaentry|qandadiv"/>
|
---|
108 | </tbody>
|
---|
109 | </table>
|
---|
110 | </div>
|
---|
111 | </xsl:template>
|
---|
112 |
|
---|
113 | <xsl:template match="qandaset/blockinfo/title|qandaset/title">
|
---|
114 | <xsl:variable name="qalevel">
|
---|
115 | <xsl:call-template name="qanda.section.level"/>
|
---|
116 | </xsl:variable>
|
---|
117 | <xsl:element name="h{string(number($qalevel)+1)}">
|
---|
118 | <xsl:attribute name="class">
|
---|
119 | <xsl:value-of select="name(.)"/>
|
---|
120 | </xsl:attribute>
|
---|
121 | <xsl:apply-templates/>
|
---|
122 | </xsl:element>
|
---|
123 | </xsl:template>
|
---|
124 |
|
---|
125 | <xsl:template match="qandaset/blockinfo">
|
---|
126 | <!-- what should this template really do? -->
|
---|
127 | <xsl:apply-templates select="legalnotice" mode="titlepage.mode"/>
|
---|
128 | </xsl:template>
|
---|
129 |
|
---|
130 | <xsl:template match="qandadiv">
|
---|
131 | <xsl:variable name="preamble" select="*[name(.) != 'title'
|
---|
132 | and name(.) != 'titleabbrev'
|
---|
133 | and name(.) != 'qandadiv'
|
---|
134 | and name(.) != 'qandaentry']"/>
|
---|
135 |
|
---|
136 | <xsl:if test="blockinfo/title|title">
|
---|
137 | <tr class="qandadiv">
|
---|
138 | <td align="left" valign="top" colspan="2">
|
---|
139 | <xsl:call-template name="anchor">
|
---|
140 | <xsl:with-param name="conditional" select="0"/>
|
---|
141 | </xsl:call-template>
|
---|
142 | <xsl:apply-templates select="(blockinfo/title|title)[1]"/>
|
---|
143 | </td>
|
---|
144 | </tr>
|
---|
145 | </xsl:if>
|
---|
146 |
|
---|
147 | <xsl:variable name="toc">
|
---|
148 | <xsl:call-template name="dbhtml-attribute">
|
---|
149 | <xsl:with-param name="pis"
|
---|
150 | select="processing-instruction('dbhtml')"/>
|
---|
151 | <xsl:with-param name="attribute" select="'toc'"/>
|
---|
152 | </xsl:call-template>
|
---|
153 | </xsl:variable>
|
---|
154 |
|
---|
155 | <xsl:variable name="toc.params">
|
---|
156 | <xsl:call-template name="find.path.params">
|
---|
157 | <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
|
---|
158 | </xsl:call-template>
|
---|
159 | </xsl:variable>
|
---|
160 |
|
---|
161 | <xsl:if test="(contains($toc.params, 'toc') and $toc != '0') or $toc = '1'">
|
---|
162 | <tr class="toc" colspan="2">
|
---|
163 | <td align="left" valign="top" colspan="2">
|
---|
164 | <xsl:call-template name="process.qanda.toc"/>
|
---|
165 | </td>
|
---|
166 | </tr>
|
---|
167 | </xsl:if>
|
---|
168 | <xsl:if test="$preamble">
|
---|
169 | <tr class="toc" colspan="2">
|
---|
170 | <td align="left" valign="top" colspan="2">
|
---|
171 | <xsl:apply-templates select="$preamble"/>
|
---|
172 | </td>
|
---|
173 | </tr>
|
---|
174 | </xsl:if>
|
---|
175 | <xsl:apply-templates select="qandadiv|qandaentry"/>
|
---|
176 | </xsl:template>
|
---|
177 |
|
---|
178 | <xsl:template match="qandadiv/blockinfo/title|qandadiv/title">
|
---|
179 | <xsl:variable name="qalevel">
|
---|
180 | <xsl:call-template name="qandadiv.section.level"/>
|
---|
181 | </xsl:variable>
|
---|
182 |
|
---|
183 | <xsl:element name="h{string(number($qalevel)+1)}">
|
---|
184 | <xsl:attribute name="class">
|
---|
185 | <xsl:value-of select="name(.)"/>
|
---|
186 | </xsl:attribute>
|
---|
187 | <xsl:call-template name="anchor">
|
---|
188 | <xsl:with-param name="node" select=".."/>
|
---|
189 | <xsl:with-param name="conditional" select="0"/>
|
---|
190 | </xsl:call-template>
|
---|
191 | <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
|
---|
192 | <xsl:if test="$qandadiv.autolabel != 0">
|
---|
193 | <xsl:apply-templates select="." mode="intralabel.punctuation"/>
|
---|
194 | <xsl:text> </xsl:text>
|
---|
195 | </xsl:if>
|
---|
196 | <xsl:apply-templates/>
|
---|
197 | </xsl:element>
|
---|
198 | </xsl:template>
|
---|
199 |
|
---|
200 | <xsl:template match="qandaentry">
|
---|
201 | <xsl:apply-templates/>
|
---|
202 | </xsl:template>
|
---|
203 |
|
---|
204 | <xsl:template match="question">
|
---|
205 | <xsl:variable name="deflabel">
|
---|
206 | <xsl:choose>
|
---|
207 | <xsl:when test="ancestor-or-self::*[@defaultlabel]">
|
---|
208 | <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
|
---|
209 | /@defaultlabel"/>
|
---|
210 | </xsl:when>
|
---|
211 | <xsl:otherwise>
|
---|
212 | <xsl:value-of select="$qanda.defaultlabel"/>
|
---|
213 | </xsl:otherwise>
|
---|
214 | </xsl:choose>
|
---|
215 | </xsl:variable>
|
---|
216 |
|
---|
217 | <tr class="{name(.)}">
|
---|
218 | <td align="left" valign="top">
|
---|
219 | <xsl:call-template name="anchor">
|
---|
220 | <xsl:with-param name="node" select=".."/>
|
---|
221 | <xsl:with-param name="conditional" select="0"/>
|
---|
222 | </xsl:call-template>
|
---|
223 | <xsl:call-template name="anchor">
|
---|
224 | <xsl:with-param name="conditional" select="0"/>
|
---|
225 | </xsl:call-template>
|
---|
226 |
|
---|
227 | <b>
|
---|
228 | <xsl:apply-templates select="." mode="label.markup"/>
|
---|
229 | <xsl:if test="$deflabel = 'number' and not(label)">
|
---|
230 | <xsl:apply-templates select="." mode="intralabel.punctuation"/>
|
---|
231 | </xsl:if>
|
---|
232 | </b>
|
---|
233 | </td>
|
---|
234 | <td align="left" valign="top">
|
---|
235 | <xsl:choose>
|
---|
236 | <xsl:when test="$deflabel = 'none' and not(label)">
|
---|
237 | <b><xsl:apply-templates select="*[name(.) != 'label']"/></b>
|
---|
238 | </xsl:when>
|
---|
239 | <xsl:otherwise>
|
---|
240 | <xsl:apply-templates select="*[name(.) != 'label']"/>
|
---|
241 | </xsl:otherwise>
|
---|
242 | </xsl:choose>
|
---|
243 | </td>
|
---|
244 | </tr>
|
---|
245 | </xsl:template>
|
---|
246 |
|
---|
247 | <xsl:template match="answer">
|
---|
248 | <xsl:variable name="deflabel">
|
---|
249 | <xsl:choose>
|
---|
250 | <xsl:when test="ancestor-or-self::*[@defaultlabel]">
|
---|
251 | <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
|
---|
252 | /@defaultlabel"/>
|
---|
253 | </xsl:when>
|
---|
254 | <xsl:otherwise>
|
---|
255 | <xsl:value-of select="$qanda.defaultlabel"/>
|
---|
256 | </xsl:otherwise>
|
---|
257 | </xsl:choose>
|
---|
258 | </xsl:variable>
|
---|
259 |
|
---|
260 | <tr class="{name(.)}">
|
---|
261 | <td align="left" valign="top">
|
---|
262 | <xsl:call-template name="anchor"/>
|
---|
263 | <b>
|
---|
264 | <xsl:variable name="answer.label">
|
---|
265 | <xsl:apply-templates select="." mode="label.markup"/>
|
---|
266 | </xsl:variable>
|
---|
267 | <xsl:copy-of select="$answer.label"/>
|
---|
268 | </b>
|
---|
269 | </td>
|
---|
270 | <td align="left" valign="top">
|
---|
271 | <xsl:apply-templates select="*[name(.) != 'label']"/>
|
---|
272 | </td>
|
---|
273 | </tr>
|
---|
274 | </xsl:template>
|
---|
275 |
|
---|
276 | <xsl:template match="label">
|
---|
277 | <xsl:apply-templates/>
|
---|
278 | </xsl:template>
|
---|
279 |
|
---|
280 | <!-- ==================================================================== -->
|
---|
281 |
|
---|
282 | <xsl:template name="process.qanda.toc">
|
---|
283 | <dl>
|
---|
284 | <xsl:apply-templates select="qandadiv" mode="qandatoc.mode"/>
|
---|
285 | <xsl:apply-templates select="qandaentry" mode="qandatoc.mode"/>
|
---|
286 | </dl>
|
---|
287 | </xsl:template>
|
---|
288 |
|
---|
289 | <xsl:template match="qandadiv" mode="qandatoc.mode">
|
---|
290 | <dt><xsl:apply-templates select="title" mode="qandatoc.mode"/></dt>
|
---|
291 | <dd><xsl:call-template name="process.qanda.toc"/></dd>
|
---|
292 | </xsl:template>
|
---|
293 |
|
---|
294 | <xsl:template match="qandadiv/blockinfo/title|qandadiv/title" mode="qandatoc.mode">
|
---|
295 | <xsl:variable name="qalevel">
|
---|
296 | <xsl:call-template name="qandadiv.section.level"/>
|
---|
297 | </xsl:variable>
|
---|
298 | <xsl:variable name="id">
|
---|
299 | <xsl:call-template name="object.id">
|
---|
300 | <xsl:with-param name="object" select="parent::*"/>
|
---|
301 | </xsl:call-template>
|
---|
302 | </xsl:variable>
|
---|
303 |
|
---|
304 | <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
|
---|
305 | <xsl:value-of select="$autotoc.label.separator"/>
|
---|
306 | <xsl:text> </xsl:text>
|
---|
307 | <a>
|
---|
308 | <xsl:attribute name="href">
|
---|
309 | <xsl:call-template name="href.target">
|
---|
310 | <xsl:with-param name="object" select="parent::*"/>
|
---|
311 | </xsl:call-template>
|
---|
312 | </xsl:attribute>
|
---|
313 | <xsl:apply-templates/>
|
---|
314 | </a>
|
---|
315 | </xsl:template>
|
---|
316 |
|
---|
317 | <xsl:template match="qandaentry" mode="qandatoc.mode">
|
---|
318 | <xsl:apply-templates select="question" mode="qandatoc.mode"/>
|
---|
319 | </xsl:template>
|
---|
320 |
|
---|
321 | <xsl:template match="question" mode="qandatoc.mode">
|
---|
322 | <xsl:variable name="firstch" select="(*[name(.)!='label'])[1]"/>
|
---|
323 | <xsl:variable name="deflabel">
|
---|
324 | <xsl:choose>
|
---|
325 | <xsl:when test="ancestor-or-self::*[@defaultlabel]">
|
---|
326 | <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
|
---|
327 | /@defaultlabel"/>
|
---|
328 | </xsl:when>
|
---|
329 | <xsl:otherwise>
|
---|
330 | <xsl:value-of select="$qanda.defaultlabel"/>
|
---|
331 | </xsl:otherwise>
|
---|
332 | </xsl:choose>
|
---|
333 | </xsl:variable>
|
---|
334 |
|
---|
335 | <dt>
|
---|
336 | <xsl:apply-templates select="." mode="label.markup"/>
|
---|
337 | <xsl:if test="$deflabel = 'number' and not(label)">
|
---|
338 | <xsl:apply-templates select="." mode="intralabel.punctuation"/>
|
---|
339 | </xsl:if>
|
---|
340 | <xsl:text> </xsl:text>
|
---|
341 | <a>
|
---|
342 | <xsl:attribute name="href">
|
---|
343 | <xsl:call-template name="href.target">
|
---|
344 | <xsl:with-param name="object" select=".."/>
|
---|
345 | </xsl:call-template>
|
---|
346 | </xsl:attribute>
|
---|
347 | <xsl:value-of select="$firstch"/>
|
---|
348 | </a>
|
---|
349 | </dt>
|
---|
350 | </xsl:template>
|
---|
351 |
|
---|
352 | <!-- ==================================================================== -->
|
---|
353 |
|
---|
354 | <xsl:template match="*" mode="no.wrapper.mode">
|
---|
355 | <xsl:apply-templates/>
|
---|
356 | </xsl:template>
|
---|
357 |
|
---|
358 | <!-- ==================================================================== -->
|
---|
359 |
|
---|
360 | </xsl:stylesheet>
|
---|