formal.xsl 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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:apply-templates/>
  91. <!-- HACK: This doesn't belong inside formal.object; it
  92. should be done by the table template, but I want
  93. the link to be inside the DIV, so... -->
  94. <xsl:if test="local-name(.) = 'informaltable'">
  95. <xsl:call-template name="table.longdesc"/>
  96. </xsl:if>
  97. <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
  98. </div>
  99. </xsl:variable>
  100. <xsl:variable name="floatstyle">
  101. <xsl:call-template name="floatstyle"/>
  102. </xsl:variable>
  103. <xsl:choose>
  104. <xsl:when test="$floatstyle != ''">
  105. <xsl:call-template name="floater">
  106. <xsl:with-param name="class"><xsl:value-of select="$class"/>-float</xsl:with-param>
  107. <xsl:with-param name="floatstyle" select="$floatstyle"/>
  108. <xsl:with-param name="content" select="$content"/>
  109. </xsl:call-template>
  110. </xsl:when>
  111. <xsl:otherwise>
  112. <xsl:copy-of select="$content"/>
  113. </xsl:otherwise>
  114. </xsl:choose>
  115. </xsl:template>
  116. <xsl:template name="semiformal.object">
  117. <xsl:param name="placement" select="'before'"/>
  118. <xsl:param name="class" select="local-name(.)"/>
  119. <xsl:choose>
  120. <xsl:when test="title">
  121. <xsl:call-template name="formal.object">
  122. <xsl:with-param name="placement" select="$placement"/>
  123. <xsl:with-param name="class" select="$class"/>
  124. </xsl:call-template>
  125. </xsl:when>
  126. <xsl:otherwise>
  127. <xsl:call-template name="informal.object">
  128. <xsl:with-param name="class" select="$class"/>
  129. </xsl:call-template>
  130. </xsl:otherwise>
  131. </xsl:choose>
  132. </xsl:template>
  133. <xsl:template match="figure">
  134. <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement), concat(local-name(.), ' '))"/>
  135. <xsl:variable name="placement">
  136. <xsl:choose>
  137. <xsl:when test="contains($param.placement, ' ')">
  138. <xsl:value-of select="substring-before($param.placement, ' ')"/>
  139. </xsl:when>
  140. <xsl:when test="$param.placement = ''">before</xsl:when>
  141. <xsl:otherwise>
  142. <xsl:value-of select="$param.placement"/>
  143. </xsl:otherwise>
  144. </xsl:choose>
  145. </xsl:variable>
  146. <xsl:call-template name="formal.object">
  147. <xsl:with-param name="placement" select="$placement"/>
  148. </xsl:call-template>
  149. </xsl:template>
  150. <xsl:template match="table">
  151. <xsl:choose>
  152. <xsl:when test="tgroup|mediaobject|graphic">
  153. <xsl:call-template name="calsTable"/>
  154. </xsl:when>
  155. <xsl:otherwise>
  156. <xsl:copy>
  157. <xsl:copy-of select="@*[not(local-name()='id')]"/>
  158. <xsl:attribute name="id">
  159. <xsl:call-template name="object.id"/>
  160. </xsl:attribute>
  161. <xsl:call-template name="htmlTable"/>
  162. </xsl:copy>
  163. </xsl:otherwise>
  164. </xsl:choose>
  165. </xsl:template>
  166. <xsl:template name="calsTable">
  167. <xsl:if test="tgroup/tbody/tr |tgroup/thead/tr |tgroup/tfoot/tr">
  168. <xsl:message terminate="yes">Broken table: tr descendent of CALS Table.</xsl:message>
  169. </xsl:if>
  170. <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement), concat(local-name(.), ' '))"/>
  171. <xsl:variable name="placement">
  172. <xsl:choose>
  173. <xsl:when test="contains($param.placement, ' ')">
  174. <xsl:value-of select="substring-before($param.placement, ' ')"/>
  175. </xsl:when>
  176. <xsl:when test="$param.placement = ''">before</xsl:when>
  177. <xsl:otherwise>
  178. <xsl:value-of select="$param.placement"/>
  179. </xsl:otherwise>
  180. </xsl:choose>
  181. </xsl:variable>
  182. <xsl:call-template name="formal.object">
  183. <xsl:with-param name="placement" select="$placement"/>
  184. <xsl:with-param name="class">
  185. <xsl:choose>
  186. <xsl:when test="@tabstyle">
  187. <!-- hack, this will only ever occur on table, not example -->
  188. <xsl:value-of select="@tabstyle"/>
  189. </xsl:when>
  190. <xsl:otherwise>
  191. <xsl:value-of select="local-name(.)"/>
  192. </xsl:otherwise>
  193. </xsl:choose>
  194. </xsl:with-param>
  195. </xsl:call-template>
  196. </xsl:template>
  197. <xsl:template name="htmlTable">
  198. <xsl:if test="tgroup/tbody/row |tgroup/thead/row |tgroup/tfoot/row">
  199. <xsl:message terminate="yes">Broken table: row descendent of HTML table.</xsl:message>
  200. </xsl:if>
  201. <xsl:apply-templates mode="htmlTable"/>
  202. </xsl:template>
  203. <xsl:template match="example">
  204. <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement), concat(local-name(.), ' '))"/>
  205. <xsl:variable name="placement">
  206. <xsl:choose>
  207. <xsl:when test="contains($param.placement, ' ')">
  208. <xsl:value-of select="substring-before($param.placement, ' ')"/>
  209. </xsl:when>
  210. <xsl:when test="$param.placement = ''">before</xsl:when>
  211. <xsl:otherwise>
  212. <xsl:value-of select="$param.placement"/>
  213. </xsl:otherwise>
  214. </xsl:choose>
  215. </xsl:variable>
  216. <xsl:call-template name="formal.object">
  217. <xsl:with-param name="placement" select="$placement"/>
  218. </xsl:call-template>
  219. </xsl:template>
  220. <xsl:template match="equation">
  221. <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement), concat(local-name(.), ' '))"/>
  222. <xsl:variable name="placement">
  223. <xsl:choose>
  224. <xsl:when test="contains($param.placement, ' ')">
  225. <xsl:value-of select="substring-before($param.placement, ' ')"/>
  226. </xsl:when>
  227. <xsl:when test="$param.placement = ''">before</xsl:when>
  228. <xsl:otherwise>
  229. <xsl:value-of select="$param.placement"/>
  230. </xsl:otherwise>
  231. </xsl:choose>
  232. </xsl:variable>
  233. <xsl:call-template name="formal.object">
  234. <xsl:with-param name="placement" select="$placement"/>
  235. </xsl:call-template>
  236. </xsl:template>
  237. <xsl:template match="figure/title"/>
  238. <xsl:template match="figure/titleabbrev"/>
  239. <xsl:template match="table/title"/>
  240. <xsl:template match="table/titleabbrev"/>
  241. <xsl:template match="table/textobject"/>
  242. <xsl:template match="example/title"/>
  243. <xsl:template match="example/titleabbrev"/>
  244. <xsl:template match="equation/title"/>
  245. <xsl:template match="equation/titleabbrev"/>
  246. <xsl:template match="informalfigure">
  247. <xsl:call-template name="informal.object"/>
  248. </xsl:template>
  249. <xsl:template match="informalexample">
  250. <xsl:call-template name="informal.object"/>
  251. </xsl:template>
  252. <xsl:template match="informaltable">
  253. <xsl:choose>
  254. <xsl:when test="tgroup|mediaobject|graphic">
  255. <xsl:call-template name="informal.object">
  256. <xsl:with-param name="class">
  257. <xsl:choose>
  258. <xsl:when test="@tabstyle">
  259. <xsl:value-of select="@tabstyle"/>
  260. </xsl:when>
  261. <xsl:otherwise>
  262. <xsl:value-of select="local-name(.)"/>
  263. </xsl:otherwise>
  264. </xsl:choose>
  265. </xsl:with-param>
  266. </xsl:call-template>
  267. </xsl:when>
  268. <xsl:otherwise>
  269. <table>
  270. <xsl:copy-of select="@*"/>
  271. <xsl:call-template name="htmlTable"/>
  272. </table>
  273. </xsl:otherwise>
  274. </xsl:choose>
  275. </xsl:template>
  276. <xsl:template match="informaltable/textobject"/>
  277. <xsl:template name="table.longdesc">
  278. <!-- HACK: This doesn't belong inside formal.objectt; it should be done by -->
  279. <!-- the table template, but I want the link to be inside the DIV, so... -->
  280. <xsl:variable name="longdesc.uri">
  281. <xsl:call-template name="longdesc.uri">
  282. <xsl:with-param name="mediaobject" select="."/>
  283. </xsl:call-template>
  284. </xsl:variable>
  285. <xsl:variable name="irrelevant">
  286. <!-- write.longdesc returns the filename ... -->
  287. <xsl:call-template name="write.longdesc">
  288. <xsl:with-param name="mediaobject" select="."/>
  289. </xsl:call-template>
  290. </xsl:variable>
  291. <xsl:if test="$html.longdesc != 0 and $html.longdesc.link != 0 and textobject[not(phrase)]">
  292. <xsl:call-template name="longdesc.link">
  293. <xsl:with-param name="longdesc.uri" select="$longdesc.uri"/>
  294. </xsl:call-template>
  295. </xsl:if>
  296. </xsl:template>
  297. <xsl:template match="informalequation">
  298. <xsl:call-template name="informal.object"/>
  299. </xsl:template>
  300. <xsl:template name="floatstyle">
  301. <xsl:if test="(@float and @float != '0') or @floatstyle != ''">
  302. <xsl:choose>
  303. <xsl:when test="@floatstyle != ''">
  304. <xsl:value-of select="@floatstyle"/>
  305. </xsl:when>
  306. <xsl:when test="@float = '1'">
  307. <xsl:value-of select="$default.float.class"/>
  308. </xsl:when>
  309. <xsl:otherwise>
  310. <xsl:value-of select="@float"/>
  311. </xsl:otherwise>
  312. </xsl:choose>
  313. </xsl:if>
  314. </xsl:template>
  315. <xsl:template name="floater">
  316. <xsl:param name="content"/>
  317. <xsl:param name="class" select="'float'"/>
  318. <xsl:param name="floatstyle" select="'left'"/>
  319. <div class="{$class}">
  320. <xsl:if test="$floatstyle = 'left' or $floatstyle = 'right'">
  321. <xsl:attribute name="style">
  322. <xsl:text>float: </xsl:text>
  323. <xsl:value-of select="$floatstyle"/>
  324. <xsl:text>;</xsl:text>
  325. </xsl:attribute>
  326. </xsl:if>
  327. <xsl:copy-of select="$content"/>
  328. </div>
  329. </xsl:template>
  330. </xsl:stylesheet>