qandaset.xsl 13 KB

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