]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/evergreen_docbook_files/docbook-xsl-1.75.2/xhtml-1_1/qandaset.xsl
Add stylesheets for our evergreen docbook site.
[working/Evergreen.git] / stylesheets / evergreen_docbook_files / docbook-xsl-1.75.2 / xhtml-1_1 / qandaset.xsl
1 <?xml version="1.0" encoding="ASCII"?>
2 <!--This file was created automatically by html2xhtml-->
3 <!--from the HTML stylesheets.-->
4 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="doc" version="1.0">
5
6 <!-- ********************************************************************
7      $Id: qandaset.xsl 8421 2009-05-04 07:49:49Z bobstayton $
8      ********************************************************************
9
10      This file is part of the XSL DocBook Stylesheet distribution.
11      See ../README or http://docbook.sf.net/release/xsl/current/ for
12      copyright and other information.
13
14      ******************************************************************** -->
15
16 <!-- ==================================================================== -->
17
18 <xsl:template match="qandaset">
19   <xsl:variable name="title" select="(blockinfo/title|info/title|title)[1]"/>
20   <xsl:variable name="preamble" select="*[local-name(.) != 'title'                                           and local-name(.) != 'titleabbrev'                                           and local-name(.) != 'qandadiv'                                           and local-name(.) != 'qandaentry']"/>
21   <xsl:variable name="toc">
22     <xsl:call-template name="pi.dbhtml_toc"/>
23   </xsl:variable>
24
25   <xsl:variable name="toc.params">
26     <xsl:call-template name="find.path.params">
27       <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
28     </xsl:call-template>
29   </xsl:variable>
30
31   <div>
32     <xsl:apply-templates select="." mode="common.html.attributes"/>
33     <xsl:apply-templates select="$title"/>
34     <xsl:if test="not($title)">
35       <!-- id is output on title if there is one -->
36       <xsl:call-template name="anchor">
37         <xsl:with-param name="conditional" select="0"/>
38       </xsl:call-template>
39     </xsl:if>
40     <xsl:if test="((contains($toc.params, 'toc') and $toc != '0') or $toc = '1')                   and not(ancestor::answer and not($qanda.nested.in.toc=0))">
41       <xsl:call-template name="process.qanda.toc"/>
42     </xsl:if>
43     <xsl:apply-templates select="$preamble"/>
44     <xsl:call-template name="process.qandaset"/>
45   </div>
46 </xsl:template>
47
48 <xsl:template match="qandaset/blockinfo/title|                      qandaset/info/title|                      qandaset/title">
49   <xsl:variable name="qalevel">
50     <xsl:call-template name="qanda.section.level"/>
51   </xsl:variable>
52   <xsl:element name="h{string(number($qalevel)+1)}" namespace="http://www.w3.org/1999/xhtml">
53     <xsl:attribute name="class">
54       <xsl:value-of select="local-name(.)"/>
55     </xsl:attribute>
56     <xsl:call-template name="anchor">
57       <xsl:with-param name="node" select=".."/>
58       <xsl:with-param name="conditional" select="0"/>
59     </xsl:call-template>
60     <xsl:apply-templates/>
61   </xsl:element>
62 </xsl:template>
63
64 <xsl:template match="qandaset/blockinfo|qandaset/info">
65   <!-- what should this template really do? -->
66   <xsl:apply-templates select="legalnotice" mode="titlepage.mode"/>
67 </xsl:template>
68
69 <xsl:template match="qandadiv">
70   <xsl:variable name="preamble" select="*[local-name(.) != 'title'                                           and local-name(.) != 'titleabbrev'                                           and local-name(.) != 'qandadiv'                                           and local-name(.) != 'qandaentry']"/>
71
72   <xsl:if test="blockinfo/title|info/title|title">
73     <tr class="qandadiv">
74       <td align="{$direction.align.start}" valign="top" colspan="2">
75         <xsl:apply-templates select="(blockinfo/title|info/title|title)[1]"/>
76       </td>
77     </tr>
78   </xsl:if>
79
80   <xsl:variable name="toc">
81     <xsl:call-template name="pi.dbhtml_toc"/>
82   </xsl:variable>
83
84   <xsl:variable name="toc.params">
85     <xsl:call-template name="find.path.params">
86       <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
87     </xsl:call-template>
88   </xsl:variable>
89
90   <xsl:if test="(contains($toc.params, 'toc') and $toc != '0') or $toc = '1'">
91     <tr class="toc">
92       <td align="{$direction.align.start}" valign="top" colspan="2">
93         <xsl:call-template name="process.qanda.toc"/>
94       </td>
95     </tr>
96   </xsl:if>
97   <xsl:if test="$preamble">
98     <tr class="toc">
99       <td align="{$direction.align.start}" valign="top" colspan="2">
100         <xsl:apply-templates select="$preamble"/>
101       </td>
102     </tr>
103   </xsl:if>
104   <xsl:apply-templates select="qandadiv|qandaentry"/>
105 </xsl:template>
106
107 <xsl:template match="qandadiv/blockinfo/title|                      qandadiv/info/title|                      qandadiv/title">
108   <xsl:variable name="qalevel">
109     <xsl:call-template name="qandadiv.section.level"/>
110   </xsl:variable>
111
112   <xsl:element name="h{string(number($qalevel)+1)}" namespace="http://www.w3.org/1999/xhtml">
113     <xsl:attribute name="class">
114       <xsl:value-of select="local-name(.)"/>
115     </xsl:attribute>
116     <xsl:call-template name="anchor">
117       <xsl:with-param name="node" select=".."/>
118       <xsl:with-param name="conditional" select="0"/>
119     </xsl:call-template>
120     <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
121     <xsl:if test="$qandadiv.autolabel != 0">
122       <xsl:apply-templates select="." mode="intralabel.punctuation"/>
123       <xsl:text> </xsl:text>
124     </xsl:if>
125     <xsl:apply-templates/>
126   </xsl:element>
127 </xsl:template>
128
129 <xsl:template match="qandaentry">
130   <xsl:apply-templates/>
131 </xsl:template>
132
133 <xsl:template match="question">
134   <xsl:variable name="deflabel">
135     <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
136   </xsl:variable>
137
138   <tr>
139     <xsl:apply-templates select="." mode="common.html.attributes"/>
140     <td align="{$direction.align.start}" valign="top">
141       <xsl:call-template name="anchor">
142         <xsl:with-param name="node" select=".."/>
143         <xsl:with-param name="conditional" select="0"/>
144       </xsl:call-template>
145       <xsl:call-template name="anchor">
146         <xsl:with-param name="conditional" select="0"/>
147       </xsl:call-template>
148
149       <xsl:variable name="label.content">
150         <xsl:apply-templates select="." mode="qanda.label"/>
151       </xsl:variable>
152
153       <xsl:if test="string-length($label.content) &gt; 0">
154         <p><b>
155           <xsl:copy-of select="$label.content"/>
156         </b></p>
157       </xsl:if>
158     </td>
159     <td align="{$direction.align.start}" valign="top">
160       <xsl:choose>
161         <xsl:when test="$deflabel = 'none' and not(label)">
162           <b><xsl:apply-templates select="*[local-name(.) != 'label']"/></b>
163         </xsl:when>
164         <xsl:otherwise>
165           <xsl:apply-templates select="*[local-name(.) != 'label']"/>
166         </xsl:otherwise>
167       </xsl:choose>
168     </td>
169   </tr>
170 </xsl:template>
171
172 <xsl:template match="*" mode="qanda.defaultlabel">
173   <xsl:choose>
174     <xsl:when test="ancestor-or-self::*[@defaultlabel]">
175       <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]                             /@defaultlabel"/>
176     </xsl:when>
177     <xsl:otherwise>
178       <xsl:value-of select="$qanda.defaultlabel"/>
179     </xsl:otherwise>
180   </xsl:choose>
181 </xsl:template>
182
183 <xsl:template match="question" mode="qanda.label">
184   <xsl:variable name="deflabel">
185     <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
186   </xsl:variable>
187   <xsl:apply-templates select="." mode="label.markup"/>
188   <xsl:if test="contains($deflabel, 'number') and not(label)">
189     <xsl:apply-templates select="." mode="intralabel.punctuation"/>
190   </xsl:if>
191 </xsl:template>
192
193 <xsl:template match="answer">
194   <xsl:variable name="deflabel">
195     <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
196   </xsl:variable>
197
198   <tr class="{local-name(.)}">
199     <td align="{$direction.align.start}" valign="top">
200       <xsl:call-template name="anchor"/>
201       <xsl:variable name="answer.label">
202         <xsl:apply-templates select="." mode="label.markup"/>
203       </xsl:variable>
204       <xsl:if test="string-length($answer.label) &gt; 0">
205         <p><b>
206           <xsl:copy-of select="$answer.label"/>
207         </b></p>
208       </xsl:if>
209     </td>
210     <td align="{$direction.align.start}" valign="top">
211       <xsl:apply-templates select="*[local-name(.) != 'label'         and local-name(.) != 'qandaentry']"/>
212       <!-- * handle nested answer/qandaentry instances -->
213       <!-- * (bug 1509043 from Daniel Leidert) -->
214       <xsl:if test="descendant::question">
215         <xsl:call-template name="process.qandaset"/>
216       </xsl:if>
217     </td>
218   </tr>
219 </xsl:template>
220
221 <xsl:template match="answer" mode="qanda.label">
222   <xsl:apply-templates select="." mode="label.markup"/>
223 </xsl:template>
224
225 <xsl:template match="label">
226   <xsl:apply-templates/>
227 </xsl:template>
228
229 <!-- ==================================================================== -->
230
231 <xsl:template name="process.qanda.toc">
232   <!-- * if user wants nested qandaset and qandaentry in main Qandaset TOC, -->
233   <!-- * then don't also include the nested stuff in the sub TOCs -->
234   <dl>
235     <xsl:apply-templates select="qandadiv" mode="qandatoc.mode"/>
236     <xsl:apply-templates select="qandaset|qandaentry" mode="qandatoc.mode"/>
237   </dl>
238 </xsl:template>
239
240 <xsl:template match="qandadiv" mode="qandatoc.mode">
241   <dt><xsl:apply-templates select="title" mode="qandatoc.mode"/></dt>
242   <dd><xsl:call-template name="process.qanda.toc"/></dd>
243 </xsl:template>
244
245 <xsl:template match="qandadiv/blockinfo/title|                      qandadiv/info/title|                      qandadiv/title" mode="qandatoc.mode">
246   <xsl:variable name="qalevel">
247     <xsl:call-template name="qandadiv.section.level"/>
248   </xsl:variable>
249   <xsl:variable name="id">
250     <xsl:call-template name="object.id">
251       <xsl:with-param name="object" select="parent::*"/>
252     </xsl:call-template>
253   </xsl:variable>
254
255   <xsl:variable name="div.label">
256     <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
257   </xsl:variable>
258   <xsl:if test="string-length($div.label) != 0">
259     <xsl:copy-of select="$div.label"/>
260     <xsl:value-of select="$autotoc.label.separator"/>
261   </xsl:if>
262   <xsl:text> </xsl:text>
263   <a>
264     <xsl:attribute name="href">
265       <xsl:call-template name="href.target">
266         <xsl:with-param name="object" select="parent::*"/>
267       </xsl:call-template>
268     </xsl:attribute>
269     <xsl:apply-templates/>
270   </a>
271 </xsl:template>
272
273 <xsl:template match="qandaset" mode="qandatoc.mode">
274   <xsl:for-each select="qandaentry">
275     <xsl:apply-templates select="." mode="qandatoc.mode"/>
276   </xsl:for-each>
277 </xsl:template>
278
279 <xsl:template match="qandaentry" mode="qandatoc.mode">
280   <xsl:apply-templates select="question" mode="qandatoc.mode"/>
281 </xsl:template>
282
283 <xsl:template match="question" mode="qandatoc.mode">
284   <xsl:variable name="firstch">
285     <!-- Use a titleabbrev or title if available -->
286     <xsl:choose>
287       <xsl:when test="../blockinfo/titleabbrev">
288         <xsl:apply-templates select="../blockinfo/titleabbrev[1]/node()"/>
289       </xsl:when>
290       <xsl:when test="../blockinfo/title">
291         <xsl:apply-templates select="../blockinfo/title[1]/node()"/>
292       </xsl:when>
293       <xsl:when test="../info/titleabbrev">
294         <xsl:apply-templates select="../info/titleabbrev[1]/node()"/>
295       </xsl:when>
296       <xsl:when test="../titleabbrev">
297         <xsl:apply-templates select="../titleabbrev[1]/node()"/>
298       </xsl:when>
299       <xsl:when test="../info/title">
300         <xsl:apply-templates select="../info/title[1]/node()"/>
301       </xsl:when>
302       <xsl:when test="../title">
303         <xsl:apply-templates select="../title[1]/node()"/>
304       </xsl:when>
305       <xsl:otherwise>
306         <xsl:apply-templates select="(*[local-name(.)!='label'])[1]/node()"/>
307       </xsl:otherwise>
308     </xsl:choose>
309   </xsl:variable>
310   <xsl:variable name="deflabel">
311     <xsl:choose>
312       <xsl:when test="ancestor-or-self::*[@defaultlabel]">
313         <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]                               /@defaultlabel"/>
314       </xsl:when>
315       <xsl:otherwise>
316         <xsl:value-of select="$qanda.defaultlabel"/>
317       </xsl:otherwise>
318     </xsl:choose>
319   </xsl:variable>
320
321   <dt>
322     <xsl:apply-templates select="." mode="label.markup"/>
323     <xsl:if test="contains($deflabel,'number') and not(label)">
324       <xsl:apply-templates select="." mode="intralabel.punctuation"/>
325     </xsl:if>
326     <xsl:text> </xsl:text>
327     <a>
328       <xsl:attribute name="href">
329         <xsl:call-template name="href.target">
330           <xsl:with-param name="object" select=".."/>
331         </xsl:call-template>
332       </xsl:attribute>
333       <xsl:value-of select="$firstch"/>
334     </a>
335   </dt>
336   <!-- * include nested qandaset/qandaentry in TOC if user wants it -->
337   <xsl:if test="not($qanda.nested.in.toc = 0)">
338     <xsl:apply-templates select="following-sibling::answer" mode="qandatoc.mode"/>
339   </xsl:if>
340 </xsl:template>
341
342 <xsl:template match="answer" mode="qandatoc.mode">
343   <xsl:if test="descendant::question">
344     <dd>
345       <xsl:call-template name="process.qanda.toc"/>
346     </dd>
347   </xsl:if>
348 </xsl:template>
349
350 <!-- ==================================================================== -->
351
352 <xsl:template name="process.qandaset">
353
354   <xsl:variable name="deflabel">
355     <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
356   </xsl:variable>
357
358   <xsl:variable name="label-width">
359     <xsl:call-template name="pi.dbhtml_label-width"/>
360   </xsl:variable>
361
362   <xsl:variable name="table-summary">
363     <xsl:call-template name="pi.dbhtml_table-summary"/>
364   </xsl:variable>
365
366   <xsl:variable name="cellpadding">
367     <xsl:call-template name="pi.dbhtml_cellpadding"/>
368   </xsl:variable>
369
370   <xsl:variable name="cellspacing">
371     <xsl:call-template name="pi.dbhtml_cellspacing"/>
372   </xsl:variable>
373
374   <table border="0" width="100%" summary="Q and A Set">
375     <xsl:if test="$table-summary != ''">
376       <xsl:attribute name="summary">
377         <xsl:value-of select="$table-summary"/>
378       </xsl:attribute>
379     </xsl:if>
380
381     <xsl:if test="$cellpadding != ''">
382       <xsl:attribute name="cellpadding">
383         <xsl:value-of select="$cellpadding"/>
384       </xsl:attribute>
385     </xsl:if>
386
387     <xsl:if test="$cellspacing != ''">
388       <xsl:attribute name="cellspacing">
389         <xsl:value-of select="$cellspacing"/>
390       </xsl:attribute>
391     </xsl:if>
392
393     <col align="{$direction.align.start}">
394       <xsl:attribute name="width">
395         <xsl:choose>
396           <xsl:when test="$label-width != ''">
397             <xsl:value-of select="$label-width"/>
398           </xsl:when>
399           <xsl:otherwise>
400             <xsl:text>1%</xsl:text>
401           </xsl:otherwise>
402         </xsl:choose>
403       </xsl:attribute>
404     </col>
405     <col/>
406     <tbody>
407       <xsl:apply-templates select="qandaentry|qandadiv"/>
408     </tbody>
409   </table>
410 </xsl:template>
411
412 <!-- ==================================================================== -->
413
414 <xsl:template match="*" mode="no.wrapper.mode">
415   <xsl:apply-templates/>
416 </xsl:template>
417
418 <!-- ==================================================================== -->
419
420 </xsl:stylesheet>