qandaset.xsl 16 KB

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