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