qandaset.xsl 14 KB

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