formal.xsl 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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="http://www.w3.org/1999/xhtml" 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. <xsl:param name="formal.object.break.after">1</xsl:param>
  13. <xsl:template name="formal.object">
  14. <xsl:param name="placement" select="'before'"/>
  15. <xsl:param name="class">
  16. <xsl:apply-templates select="." mode="class.value"/>
  17. </xsl:param>
  18. <xsl:call-template name="id.warning"/>
  19. <xsl:variable name="content">
  20. <div class="{$class}">
  21. <xsl:call-template name="anchor">
  22. <xsl:with-param name="conditional" select="0"/>
  23. </xsl:call-template>
  24. <xsl:choose>
  25. <xsl:when test="$placement = 'before'">
  26. <xsl:call-template name="formal.object.heading"/>
  27. <div class="{$class}-contents">
  28. <xsl:apply-templates/>
  29. </div>
  30. <!-- HACK: This doesn't belong inside formal.object; it
  31. should be done by the table template, but I want
  32. the link to be inside the DIV, so... -->
  33. <xsl:if test="local-name(.) = 'table'">
  34. <xsl:call-template name="table.longdesc"/>
  35. </xsl:if>
  36. <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
  37. </xsl:when>
  38. <xsl:otherwise>
  39. <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
  40. <div class="{$class}-contents"><xsl:apply-templates/></div>
  41. <!-- HACK: This doesn't belong inside formal.object; it
  42. should be done by the table template, but I want
  43. the link to be inside the DIV, so... -->
  44. <xsl:if test="local-name(.) = 'table'">
  45. <xsl:call-template name="table.longdesc"/>
  46. </xsl:if>
  47. <xsl:call-template name="formal.object.heading"/>
  48. </xsl:otherwise>
  49. </xsl:choose>
  50. </div>
  51. <xsl:if test="not($formal.object.break.after = '0')">
  52. <br class="{$class}-break"/>
  53. </xsl:if>
  54. </xsl:variable>
  55. <xsl:variable name="floatstyle">
  56. <xsl:call-template name="floatstyle"/>
  57. </xsl:variable>
  58. <xsl:choose>
  59. <xsl:when test="$floatstyle != ''">
  60. <xsl:call-template name="floater">
  61. <xsl:with-param name="class"><xsl:value-of select="$class"/>-float</xsl:with-param>
  62. <xsl:with-param name="floatstyle" select="$floatstyle"/>
  63. <xsl:with-param name="content" select="$content"/>
  64. </xsl:call-template>
  65. </xsl:when>
  66. <xsl:otherwise>
  67. <xsl:copy-of select="$content"/>
  68. </xsl:otherwise>
  69. </xsl:choose>
  70. </xsl:template>
  71. <xsl:template name="formal.object.heading">
  72. <xsl:param name="object" select="."/>
  73. <xsl:param name="title">
  74. <xsl:apply-templates select="$object" mode="object.title.markup">
  75. <xsl:with-param name="allow-anchors" select="1"/>
  76. </xsl:apply-templates>
  77. </xsl:param>
  78. <p class="title">
  79. <b>
  80. <xsl:copy-of select="$title"/>
  81. </b>
  82. </p>
  83. </xsl:template>
  84. <xsl:template name="informal.object">
  85. <xsl:param name="class" select="local-name(.)"/>
  86. <xsl:variable name="content">
  87. <div class="{$class}">
  88. <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
  89. <xsl:call-template name="anchor">
  90. <xsl:with-param name="conditional" select="0"/>
  91. </xsl:call-template>
  92. <xsl:apply-templates/>
  93. <!-- HACK: This doesn't belong inside formal.object; it
  94. should be done by the table template, but I want
  95. the link to be inside the DIV, so... -->
  96. <xsl:if test="local-name(.) = 'informaltable'">
  97. <xsl:call-template name="table.longdesc"/>
  98. </xsl:if>
  99. <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
  100. </div>
  101. </xsl:variable>
  102. <xsl:variable name="floatstyle">
  103. <xsl:call-template name="floatstyle"/>
  104. </xsl:variable>
  105. <xsl:choose>
  106. <xsl:when test="$floatstyle != ''">
  107. <xsl:call-template name="floater">
  108. <xsl:with-param name="class"><xsl:value-of select="$class"/>-float</xsl:with-param>
  109. <xsl:with-param name="floatstyle" select="$floatstyle"/>
  110. <xsl:with-param name="content" select="$content"/>
  111. </xsl:call-template>
  112. </xsl:when>
  113. <xsl:otherwise>
  114. <xsl:copy-of select="$content"/>
  115. </xsl:otherwise>
  116. </xsl:choose>
  117. </xsl:template>
  118. <xsl:template name="semiformal.object">
  119. <xsl:param name="placement" select="'before'"/>
  120. <xsl:param name="class" select="local-name(.)"/>
  121. <xsl:choose>
  122. <xsl:when test="title">
  123. <xsl:call-template name="formal.object">
  124. <xsl:with-param name="placement" select="$placement"/>
  125. <xsl:with-param name="class" select="$class"/>
  126. </xsl:call-template>
  127. </xsl:when>
  128. <xsl:otherwise>
  129. <xsl:call-template name="informal.object">
  130. <xsl:with-param name="class" select="$class"/>
  131. </xsl:call-template>
  132. </xsl:otherwise>
  133. </xsl:choose>
  134. </xsl:template>
  135. <xsl:template match="figure">
  136. <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement), concat(local-name(.), ' '))"/>
  137. <xsl:variable name="placement">
  138. <xsl:choose>
  139. <xsl:when test="contains($param.placement, ' ')">
  140. <xsl:value-of select="substring-before($param.placement, ' ')"/>
  141. </xsl:when>
  142. <xsl:when test="$param.placement = ''">before</xsl:when>
  143. <xsl:otherwise>
  144. <xsl:value-of select="$param.placement"/>
  145. </xsl:otherwise>
  146. </xsl:choose>
  147. </xsl:variable>
  148. <xsl:call-template name="formal.object">
  149. <xsl:with-param name="placement" select="$placement"/>
  150. </xsl:call-template>
  151. </xsl:template>
  152. <xsl:template match="table">
  153. <xsl:choose>
  154. <xsl:when test="tgroup|mediaobject|graphic">
  155. <xsl:call-template name="calsTable"/>
  156. </xsl:when>
  157. <xsl:otherwise>
  158. <xsl:copy>
  159. <xsl:copy-of select="@*[not(local-name()='id')]"/>
  160. <xsl:attribute name="id">
  161. <xsl:call-template name="object.id"/>
  162. </xsl:attribute>
  163. <xsl:call-template name="htmlTable"/>
  164. </xsl:copy>
  165. </xsl:otherwise>
  166. </xsl:choose>
  167. </xsl:template>
  168. <xsl:template name="calsTable">
  169. <xsl:if test="tgroup/tbody/tr |tgroup/thead/tr |tgroup/tfoot/tr">
  170. <xsl:message terminate="yes">Broken table: tr descendent of CALS Table.</xsl:message>
  171. </xsl:if>
  172. <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement), concat(local-name(.), ' '))"/>
  173. <xsl:variable name="placement">
  174. <xsl:choose>
  175. <xsl:when test="contains($param.placement, ' ')">
  176. <xsl:value-of select="substring-before($param.placement, ' ')"/>
  177. </xsl:when>
  178. <xsl:when test="$param.placement = ''">before</xsl:when>
  179. <xsl:otherwise>
  180. <xsl:value-of select="$param.placement"/>
  181. </xsl:otherwise>
  182. </xsl:choose>
  183. </xsl:variable>
  184. <xsl:call-template name="formal.object">
  185. <xsl:with-param name="placement" select="$placement"/>
  186. <xsl:with-param name="class">
  187. <xsl:choose>
  188. <xsl:when test="@tabstyle">
  189. <!-- hack, this will only ever occur on table, not example -->
  190. <xsl:value-of select="@tabstyle"/>
  191. </xsl:when>
  192. <xsl:otherwise>
  193. <xsl:value-of select="local-name(.)"/>
  194. </xsl:otherwise>
  195. </xsl:choose>
  196. </xsl:with-param>
  197. </xsl:call-template>
  198. </xsl:template>
  199. <xsl:template name="htmlTable">
  200. <xsl:if test="tgroup/tbody/row |tgroup/thead/row |tgroup/tfoot/row">
  201. <xsl:message terminate="yes">Broken table: row descendent of HTML table.</xsl:message>
  202. </xsl:if>
  203. <xsl:apply-templates mode="htmlTable"/>
  204. </xsl:template>
  205. <xsl:template match="example">
  206. <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement), concat(local-name(.), ' '))"/>
  207. <xsl:variable name="placement">
  208. <xsl:choose>
  209. <xsl:when test="contains($param.placement, ' ')">
  210. <xsl:value-of select="substring-before($param.placement, ' ')"/>
  211. </xsl:when>
  212. <xsl:when test="$param.placement = ''">before</xsl:when>
  213. <xsl:otherwise>
  214. <xsl:value-of select="$param.placement"/>
  215. </xsl:otherwise>
  216. </xsl:choose>
  217. </xsl:variable>
  218. <xsl:call-template name="formal.object">
  219. <xsl:with-param name="placement" select="$placement"/>
  220. </xsl:call-template>
  221. </xsl:template>
  222. <xsl:template match="equation">
  223. <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement), concat(local-name(.), ' '))"/>
  224. <xsl:variable name="placement">
  225. <xsl:choose>
  226. <xsl:when test="contains($param.placement, ' ')">
  227. <xsl:value-of select="substring-before($param.placement, ' ')"/>
  228. </xsl:when>
  229. <xsl:when test="$param.placement = ''">before</xsl:when>
  230. <xsl:otherwise>
  231. <xsl:value-of select="$param.placement"/>
  232. </xsl:otherwise>
  233. </xsl:choose>
  234. </xsl:variable>
  235. <xsl:call-template name="formal.object">
  236. <xsl:with-param name="placement" select="$placement"/>
  237. </xsl:call-template>
  238. </xsl:template>
  239. <xsl:template match="figure/title"/>
  240. <xsl:template match="figure/titleabbrev"/>
  241. <xsl:template match="table/title"/>
  242. <xsl:template match="table/titleabbrev"/>
  243. <xsl:template match="table/textobject"/>
  244. <xsl:template match="example/title"/>
  245. <xsl:template match="example/titleabbrev"/>
  246. <xsl:template match="equation/title"/>
  247. <xsl:template match="equation/titleabbrev"/>
  248. <xsl:template match="informalfigure">
  249. <xsl:call-template name="informal.object"/>
  250. </xsl:template>
  251. <xsl:template match="informalexample">
  252. <xsl:call-template name="informal.object"/>
  253. </xsl:template>
  254. <xsl:template match="informaltable">
  255. <xsl:choose>
  256. <xsl:when test="tgroup|mediaobject|graphic">
  257. <xsl:call-template name="informal.object">
  258. <xsl:with-param name="class">
  259. <xsl:choose>
  260. <xsl:when test="@tabstyle">
  261. <xsl:value-of select="@tabstyle"/>
  262. </xsl:when>
  263. <xsl:otherwise>
  264. <xsl:value-of select="local-name(.)"/>
  265. </xsl:otherwise>
  266. </xsl:choose>
  267. </xsl:with-param>
  268. </xsl:call-template>
  269. </xsl:when>
  270. <xsl:otherwise>
  271. <table>
  272. <xsl:copy-of select="@*"/>
  273. <xsl:call-template name="htmlTable"/>
  274. </table>
  275. </xsl:otherwise>
  276. </xsl:choose>
  277. </xsl:template>
  278. <xsl:template match="informaltable/textobject"/>
  279. <xsl:template name="table.longdesc">
  280. <!-- HACK: This doesn't belong inside formal.objectt; it should be done by -->
  281. <!-- the table template, but I want the link to be inside the DIV, so... -->
  282. <xsl:variable name="longdesc.uri">
  283. <xsl:call-template name="longdesc.uri">
  284. <xsl:with-param name="mediaobject" select="."/>
  285. </xsl:call-template>
  286. </xsl:variable>
  287. <xsl:variable name="irrelevant">
  288. <!-- write.longdesc returns the filename ... -->
  289. <xsl:call-template name="write.longdesc">
  290. <xsl:with-param name="mediaobject" select="."/>
  291. </xsl:call-template>
  292. </xsl:variable>
  293. <xsl:if test="$html.longdesc != 0 and $html.longdesc.link != 0 and textobject[not(phrase)]">
  294. <xsl:call-template name="longdesc.link">
  295. <xsl:with-param name="longdesc.uri" select="$longdesc.uri"/>
  296. </xsl:call-template>
  297. </xsl:if>
  298. </xsl:template>
  299. <xsl:template match="informalequation">
  300. <xsl:call-template name="informal.object"/>
  301. </xsl:template>
  302. <xsl:template name="floatstyle">
  303. <xsl:if test="(@float and @float != '0') or @floatstyle != ''">
  304. <xsl:choose>
  305. <xsl:when test="@floatstyle != ''">
  306. <xsl:value-of select="@floatstyle"/>
  307. </xsl:when>
  308. <xsl:when test="@float = '1'">
  309. <xsl:value-of select="$default.float.class"/>
  310. </xsl:when>
  311. <xsl:otherwise>
  312. <xsl:value-of select="@float"/>
  313. </xsl:otherwise>
  314. </xsl:choose>
  315. </xsl:if>
  316. </xsl:template>
  317. <xsl:template name="floater">
  318. <xsl:param name="content"/>
  319. <xsl:param name="class" select="'float'"/>
  320. <xsl:param name="floatstyle" select="'left'"/>
  321. <div class="{$class}">
  322. <xsl:if test="$floatstyle = 'left' or $floatstyle = 'right'">
  323. <xsl:attribute name="style">
  324. <xsl:text>float: </xsl:text>
  325. <xsl:value-of select="$floatstyle"/>
  326. <xsl:text>;</xsl:text>
  327. </xsl:attribute>
  328. </xsl:if>
  329. <xsl:copy-of select="$content"/>
  330. </div>
  331. </xsl:template>
  332. </xsl:stylesheet>