table.xsl 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093
  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:stbl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Table" xmlns:xtbl="xalan://com.nwalsh.xalan.Table" xmlns:lxslt="http://xml.apache.org/xslt" xmlns:ptbl="http://nwalsh.com/xslt/ext/xsltproc/python/Table" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="doc stbl xtbl lxslt ptbl" version="1.0">
  5. <xsl:include href="../common/table.xsl"/>
  6. <!-- ********************************************************************
  7. $Id$
  8. ********************************************************************
  9. This file is part of the XSL DocBook Stylesheet distribution.
  10. See ../README or http://docbook.sf.net/release/xsl/current/ for
  11. copyright and other information.
  12. ******************************************************************** -->
  13. <lxslt:component prefix="xtbl" functions="adjustColumnWidths"/>
  14. <xsl:template name="empty.table.cell">
  15. <xsl:param name="colnum" select="0"/>
  16. <xsl:variable name="rowsep">
  17. <xsl:choose>
  18. <!-- If this is the last row, rowsep never applies. -->
  19. <xsl:when test="not(ancestor-or-self::row[1]/following-sibling::row or ancestor-or-self::thead/following-sibling::tbody or ancestor-or-self::tbody/preceding-sibling::tfoot)">
  20. <xsl:value-of select="0"/>
  21. </xsl:when>
  22. <xsl:otherwise>
  23. <xsl:call-template name="inherited.table.attribute">
  24. <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
  25. <xsl:with-param name="row" select="ancestor-or-self::row[1]"/>
  26. <xsl:with-param name="colnum" select="$colnum"/>
  27. <xsl:with-param name="attribute" select="'rowsep'"/>
  28. </xsl:call-template>
  29. </xsl:otherwise>
  30. </xsl:choose>
  31. </xsl:variable>
  32. <xsl:variable name="colsep">
  33. <xsl:choose>
  34. <!-- If this is the last column, colsep never applies. -->
  35. <xsl:when test="number($colnum) &gt;= ancestor::tgroup/@cols">0</xsl:when>
  36. <xsl:otherwise>
  37. <xsl:call-template name="inherited.table.attribute">
  38. <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
  39. <xsl:with-param name="row" select="ancestor-or-self::row[1]"/>
  40. <xsl:with-param name="colnum" select="$colnum"/>
  41. <xsl:with-param name="attribute" select="'colsep'"/>
  42. </xsl:call-template>
  43. </xsl:otherwise>
  44. </xsl:choose>
  45. </xsl:variable>
  46. <td class="auto-generated">
  47. <xsl:if test="$table.borders.with.css != 0">
  48. <xsl:attribute name="style">
  49. <xsl:if test="$colsep &gt; 0">
  50. <xsl:call-template name="border">
  51. <xsl:with-param name="side" select="'right'"/>
  52. </xsl:call-template>
  53. </xsl:if>
  54. <xsl:if test="$rowsep &gt; 0">
  55. <xsl:call-template name="border">
  56. <xsl:with-param name="side" select="'bottom'"/>
  57. </xsl:call-template>
  58. </xsl:if>
  59. </xsl:attribute>
  60. </xsl:if>
  61. <xsl:text>&#160;</xsl:text>
  62. </td>
  63. </xsl:template>
  64. <!-- ==================================================================== -->
  65. <xsl:template name="border">
  66. <xsl:param name="side" select="'left'"/>
  67. <xsl:param name="padding" select="0"/>
  68. <xsl:param name="style" select="$table.cell.border.style"/>
  69. <xsl:param name="color" select="$table.cell.border.color"/>
  70. <xsl:param name="thickness" select="$table.cell.border.thickness"/>
  71. <!-- Note: Some browsers (mozilla) require at least a width and style. -->
  72. <xsl:choose>
  73. <xsl:when test="($thickness != '' and $style != '' and $color != '') or ($thickness != '' and $style != '') or ($thickness != '')">
  74. <!-- use the compound property if we can: -->
  75. <!-- it saves space and probably works more reliably -->
  76. <xsl:text>border-</xsl:text>
  77. <xsl:value-of select="$side"/>
  78. <xsl:text>: </xsl:text>
  79. <xsl:value-of select="$thickness"/>
  80. <xsl:text> </xsl:text>
  81. <xsl:value-of select="$style"/>
  82. <xsl:text> </xsl:text>
  83. <xsl:value-of select="$color"/>
  84. <xsl:text>; </xsl:text>
  85. </xsl:when>
  86. <xsl:otherwise>
  87. <!-- we need to specify the styles individually -->
  88. <xsl:if test="$thickness != ''">
  89. <xsl:text>border-</xsl:text>
  90. <xsl:value-of select="$side"/>
  91. <xsl:text>-width: </xsl:text>
  92. <xsl:value-of select="$thickness"/>
  93. <xsl:text>; </xsl:text>
  94. </xsl:if>
  95. <xsl:if test="$style != ''">
  96. <xsl:text>border-</xsl:text>
  97. <xsl:value-of select="$side"/>
  98. <xsl:text>-style: </xsl:text>
  99. <xsl:value-of select="$style"/>
  100. <xsl:text>; </xsl:text>
  101. </xsl:if>
  102. <xsl:if test="$color != ''">
  103. <xsl:text>border-</xsl:text>
  104. <xsl:value-of select="$side"/>
  105. <xsl:text>-color: </xsl:text>
  106. <xsl:value-of select="$color"/>
  107. <xsl:text>; </xsl:text>
  108. </xsl:if>
  109. </xsl:otherwise>
  110. </xsl:choose>
  111. </xsl:template>
  112. <!-- ==================================================================== -->
  113. <xsl:template match="tgroup" name="tgroup">
  114. <xsl:if test="not(@cols) or @cols = '' or string(number(@cols)) = 'NaN'">
  115. <xsl:message terminate="yes">
  116. <xsl:text>Error: CALS tables must specify the number of columns.</xsl:text>
  117. </xsl:message>
  118. </xsl:if>
  119. <xsl:variable name="summary">
  120. <xsl:call-template name="pi.dbhtml_table-summary"/>
  121. </xsl:variable>
  122. <xsl:variable name="cellspacing">
  123. <xsl:call-template name="pi.dbhtml_cellspacing"/>
  124. </xsl:variable>
  125. <xsl:variable name="cellpadding">
  126. <xsl:call-template name="pi.dbhtml_cellpadding"/>
  127. </xsl:variable>
  128. <table>
  129. <xsl:choose>
  130. <!-- If there's a textobject/phrase for the table summary, use it -->
  131. <xsl:when test="../textobject/phrase">
  132. <xsl:attribute name="summary">
  133. <xsl:value-of select="../textobject/phrase"/>
  134. </xsl:attribute>
  135. </xsl:when>
  136. <!-- If there's a <?dbhtml table-summary="foo"?> PI, use it for
  137. the HTML table summary attribute -->
  138. <xsl:when test="$summary != ''">
  139. <xsl:attribute name="summary">
  140. <xsl:value-of select="$summary"/>
  141. </xsl:attribute>
  142. </xsl:when>
  143. <!-- Otherwise, if there's a title, use that -->
  144. <xsl:when test="../title">
  145. <xsl:attribute name="summary">
  146. <xsl:value-of select="string(../title)"/>
  147. </xsl:attribute>
  148. </xsl:when>
  149. <!-- Otherwise, forget the whole idea -->
  150. <xsl:otherwise><!-- nevermind --></xsl:otherwise>
  151. </xsl:choose>
  152. <xsl:if test="$cellspacing != '' or $html.cellspacing != ''">
  153. <xsl:attribute name="cellspacing">
  154. <xsl:choose>
  155. <xsl:when test="$cellspacing != ''">
  156. <xsl:value-of select="$cellspacing"/>
  157. </xsl:when>
  158. <xsl:otherwise>
  159. <xsl:value-of select="$html.cellspacing"/>
  160. </xsl:otherwise>
  161. </xsl:choose>
  162. </xsl:attribute>
  163. </xsl:if>
  164. <xsl:if test="$cellpadding != '' or $html.cellpadding != ''">
  165. <xsl:attribute name="cellpadding">
  166. <xsl:choose>
  167. <xsl:when test="$cellpadding != ''">
  168. <xsl:value-of select="$cellpadding"/>
  169. </xsl:when>
  170. <xsl:otherwise>
  171. <xsl:value-of select="$html.cellpadding"/>
  172. </xsl:otherwise>
  173. </xsl:choose>
  174. </xsl:attribute>
  175. </xsl:if>
  176. <xsl:if test="../@pgwide=1 or local-name(.) = 'entrytbl'">
  177. <xsl:attribute name="width">100%</xsl:attribute>
  178. </xsl:if>
  179. <xsl:choose>
  180. <xsl:when test="$table.borders.with.css != 0">
  181. <xsl:choose>
  182. <xsl:when test="../@frame='all' or (not(../@frame) and $default.table.frame='all')">
  183. <xsl:attribute name="style">
  184. <xsl:text>border-collapse: collapse;</xsl:text>
  185. <xsl:call-template name="border">
  186. <xsl:with-param name="side" select="'top'"/>
  187. <xsl:with-param name="style" select="$table.frame.border.style"/>
  188. <xsl:with-param name="color" select="$table.frame.border.color"/>
  189. <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
  190. </xsl:call-template>
  191. <xsl:call-template name="border">
  192. <xsl:with-param name="side" select="'bottom'"/>
  193. <xsl:with-param name="style" select="$table.frame.border.style"/>
  194. <xsl:with-param name="color" select="$table.frame.border.color"/>
  195. <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
  196. </xsl:call-template>
  197. <xsl:call-template name="border">
  198. <xsl:with-param name="side" select="'left'"/>
  199. <xsl:with-param name="style" select="$table.frame.border.style"/>
  200. <xsl:with-param name="color" select="$table.frame.border.color"/>
  201. <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
  202. </xsl:call-template>
  203. <xsl:call-template name="border">
  204. <xsl:with-param name="side" select="'right'"/>
  205. <xsl:with-param name="style" select="$table.frame.border.style"/>
  206. <xsl:with-param name="color" select="$table.frame.border.color"/>
  207. <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
  208. </xsl:call-template>
  209. </xsl:attribute>
  210. </xsl:when>
  211. <xsl:when test="../@frame='topbot' or (not(../@frame) and $default.table.frame='topbot')">
  212. <xsl:attribute name="style">
  213. <xsl:text>border-collapse: collapse;</xsl:text>
  214. <xsl:call-template name="border">
  215. <xsl:with-param name="side" select="'top'"/>
  216. <xsl:with-param name="style" select="$table.frame.border.style"/>
  217. <xsl:with-param name="color" select="$table.frame.border.color"/>
  218. <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
  219. </xsl:call-template>
  220. <xsl:call-template name="border">
  221. <xsl:with-param name="side" select="'bottom'"/>
  222. <xsl:with-param name="style" select="$table.frame.border.style"/>
  223. <xsl:with-param name="color" select="$table.frame.border.color"/>
  224. <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
  225. </xsl:call-template>
  226. </xsl:attribute>
  227. </xsl:when>
  228. <xsl:when test="../@frame='top' or (not(../@frame) and $default.table.frame='top')">
  229. <xsl:attribute name="style">
  230. <xsl:text>border-collapse: collapse;</xsl:text>
  231. <xsl:call-template name="border">
  232. <xsl:with-param name="side" select="'top'"/>
  233. <xsl:with-param name="style" select="$table.frame.border.style"/>
  234. <xsl:with-param name="color" select="$table.frame.border.color"/>
  235. <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
  236. </xsl:call-template>
  237. </xsl:attribute>
  238. </xsl:when>
  239. <xsl:when test="../@frame='bottom' or (not(../@frame) and $default.table.frame='bottom')">
  240. <xsl:attribute name="style">
  241. <xsl:text>border-collapse: collapse;</xsl:text>
  242. <xsl:call-template name="border">
  243. <xsl:with-param name="side" select="'bottom'"/>
  244. <xsl:with-param name="style" select="$table.frame.border.style"/>
  245. <xsl:with-param name="color" select="$table.frame.border.color"/>
  246. <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
  247. </xsl:call-template>
  248. </xsl:attribute>
  249. </xsl:when>
  250. <xsl:when test="../@frame='sides' or (not(../@frame) and $default.table.frame='sides')">
  251. <xsl:attribute name="style">
  252. <xsl:text>border-collapse: collapse;</xsl:text>
  253. <xsl:call-template name="border">
  254. <xsl:with-param name="side" select="'left'"/>
  255. <xsl:with-param name="style" select="$table.frame.border.style"/>
  256. <xsl:with-param name="color" select="$table.frame.border.color"/>
  257. <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
  258. </xsl:call-template>
  259. <xsl:call-template name="border">
  260. <xsl:with-param name="side" select="'right'"/>
  261. <xsl:with-param name="style" select="$table.frame.border.style"/>
  262. <xsl:with-param name="color" select="$table.frame.border.color"/>
  263. <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
  264. </xsl:call-template>
  265. </xsl:attribute>
  266. </xsl:when>
  267. <xsl:when test="../@frame='none'">
  268. <xsl:attribute name="style">
  269. <xsl:text>border: none;</xsl:text>
  270. </xsl:attribute>
  271. </xsl:when>
  272. <xsl:otherwise>
  273. <xsl:attribute name="style">
  274. <xsl:text>border-collapse: collapse;</xsl:text>
  275. </xsl:attribute>
  276. </xsl:otherwise>
  277. </xsl:choose>
  278. </xsl:when>
  279. <xsl:when test="../@frame='none' or (not(../@frame) and $default.table.frame='none') or local-name(.) = 'entrytbl'">
  280. <xsl:attribute name="border">0</xsl:attribute>
  281. </xsl:when>
  282. <xsl:otherwise>
  283. <xsl:attribute name="border">1</xsl:attribute>
  284. </xsl:otherwise>
  285. </xsl:choose>
  286. <xsl:variable name="colgroup">
  287. <colgroup>
  288. <xsl:call-template name="generate.colgroup">
  289. <xsl:with-param name="cols" select="@cols"/>
  290. </xsl:call-template>
  291. </colgroup>
  292. </xsl:variable>
  293. <xsl:variable name="explicit.table.width">
  294. <xsl:call-template name="pi.dbhtml_table-width">
  295. <xsl:with-param name="node" select=".."/>
  296. </xsl:call-template>
  297. </xsl:variable>
  298. <xsl:variable name="table.width">
  299. <xsl:choose>
  300. <xsl:when test="$explicit.table.width != ''">
  301. <xsl:value-of select="$explicit.table.width"/>
  302. </xsl:when>
  303. <xsl:when test="$default.table.width = ''">
  304. <xsl:text>100%</xsl:text>
  305. </xsl:when>
  306. <xsl:otherwise>
  307. <xsl:value-of select="$default.table.width"/>
  308. </xsl:otherwise>
  309. </xsl:choose>
  310. </xsl:variable>
  311. <xsl:if test="$default.table.width != '' or $explicit.table.width != ''">
  312. <xsl:attribute name="width">
  313. <xsl:choose>
  314. <xsl:when test="contains($table.width, '%')">
  315. <xsl:value-of select="$table.width"/>
  316. </xsl:when>
  317. <xsl:when test="$use.extensions != 0 and $tablecolumns.extension != 0">
  318. <xsl:choose>
  319. <xsl:when test="function-available('stbl:convertLength')">
  320. <xsl:value-of select="stbl:convertLength($table.width)"/>
  321. </xsl:when>
  322. <xsl:when test="function-available('xtbl:convertLength')">
  323. <xsl:value-of select="xtbl:convertLength($table.width)"/>
  324. </xsl:when>
  325. <xsl:otherwise>
  326. <xsl:message terminate="yes">
  327. <xsl:text>No convertLength function available.</xsl:text>
  328. </xsl:message>
  329. </xsl:otherwise>
  330. </xsl:choose>
  331. </xsl:when>
  332. <xsl:otherwise>
  333. <xsl:value-of select="$table.width"/>
  334. </xsl:otherwise>
  335. </xsl:choose>
  336. </xsl:attribute>
  337. </xsl:if>
  338. <xsl:choose>
  339. <xsl:when test="$use.extensions != 0 and $tablecolumns.extension != 0">
  340. <xsl:choose>
  341. <xsl:when test="function-available('stbl:adjustColumnWidths')">
  342. <xsl:copy-of select="stbl:adjustColumnWidths($colgroup)"/>
  343. </xsl:when>
  344. <xsl:when test="function-available('xtbl:adjustColumnWidths')">
  345. <xsl:copy-of select="xtbl:adjustColumnWidths($colgroup)"/>
  346. </xsl:when>
  347. <xsl:when test="function-available('ptbl:adjustColumnWidths')">
  348. <xsl:copy-of select="ptbl:adjustColumnWidths($colgroup)"/>
  349. </xsl:when>
  350. <xsl:otherwise>
  351. <xsl:message terminate="yes">
  352. <xsl:text>No adjustColumnWidths function available.</xsl:text>
  353. </xsl:message>
  354. </xsl:otherwise>
  355. </xsl:choose>
  356. </xsl:when>
  357. <xsl:otherwise>
  358. <xsl:copy-of select="$colgroup"/>
  359. </xsl:otherwise>
  360. </xsl:choose>
  361. <xsl:apply-templates select="thead"/>
  362. <xsl:apply-templates select="tfoot"/>
  363. <xsl:apply-templates select="tbody"/>
  364. <xsl:if test=".//footnote">
  365. <tbody class="footnotes">
  366. <tr>
  367. <td colspan="{@cols}">
  368. <xsl:apply-templates select=".//footnote" mode="table.footnote.mode"/>
  369. </td>
  370. </tr>
  371. </tbody>
  372. </xsl:if>
  373. </table>
  374. </xsl:template>
  375. <xsl:template match="tgroup/processing-instruction('dbhtml')">
  376. <xsl:variable name="summary">
  377. <xsl:call-template name="pi.dbhtml_table-summary"/>
  378. </xsl:variable>
  379. <!-- Suppress the table-summary PI -->
  380. <xsl:if test="$summary = ''">
  381. <xsl:processing-instruction name="dbhtml">
  382. <xsl:value-of select="."/>
  383. </xsl:processing-instruction>
  384. </xsl:if>
  385. </xsl:template>
  386. <xsl:template match="colspec"/>
  387. <xsl:template match="spanspec"/>
  388. <xsl:template match="thead|tfoot">
  389. <xsl:element name="{local-name(.)}" namespace="http://www.w3.org/1999/xhtml">
  390. <xsl:if test="@align">
  391. <xsl:attribute name="align">
  392. <xsl:value-of select="@align"/>
  393. </xsl:attribute>
  394. </xsl:if>
  395. <xsl:if test="@char">
  396. <xsl:attribute name="char">
  397. <xsl:value-of select="@char"/>
  398. </xsl:attribute>
  399. </xsl:if>
  400. <xsl:if test="@charoff">
  401. <xsl:attribute name="charoff">
  402. <xsl:value-of select="@charoff"/>
  403. </xsl:attribute>
  404. </xsl:if>
  405. <xsl:if test="@valign">
  406. <xsl:attribute name="valign">
  407. <xsl:value-of select="@valign"/>
  408. </xsl:attribute>
  409. </xsl:if>
  410. <xsl:apply-templates select="row[1]">
  411. <xsl:with-param name="spans">
  412. <xsl:call-template name="blank.spans">
  413. <xsl:with-param name="cols" select="../@cols"/>
  414. </xsl:call-template>
  415. </xsl:with-param>
  416. </xsl:apply-templates>
  417. </xsl:element>
  418. </xsl:template>
  419. <xsl:template match="tbody">
  420. <tbody>
  421. <xsl:if test="@align">
  422. <xsl:attribute name="align">
  423. <xsl:value-of select="@align"/>
  424. </xsl:attribute>
  425. </xsl:if>
  426. <xsl:if test="@char">
  427. <xsl:attribute name="char">
  428. <xsl:value-of select="@char"/>
  429. </xsl:attribute>
  430. </xsl:if>
  431. <xsl:if test="@charoff">
  432. <xsl:attribute name="charoff">
  433. <xsl:value-of select="@charoff"/>
  434. </xsl:attribute>
  435. </xsl:if>
  436. <xsl:if test="@valign">
  437. <xsl:attribute name="valign">
  438. <xsl:value-of select="@valign"/>
  439. </xsl:attribute>
  440. </xsl:if>
  441. <xsl:apply-templates select="row[1]">
  442. <xsl:with-param name="spans">
  443. <xsl:call-template name="blank.spans">
  444. <xsl:with-param name="cols" select="../@cols"/>
  445. </xsl:call-template>
  446. </xsl:with-param>
  447. </xsl:apply-templates>
  448. </tbody>
  449. </xsl:template>
  450. <xsl:template match="row">
  451. <xsl:param name="spans"/>
  452. <xsl:choose>
  453. <xsl:when test="contains($spans, '0')">
  454. <xsl:call-template name="normal-row">
  455. <xsl:with-param name="spans" select="$spans"/>
  456. </xsl:call-template>
  457. </xsl:when>
  458. <xsl:otherwise>
  459. <!--
  460. <xsl:message>
  461. <xsl:text>Ignoring row: </xsl:text>
  462. <xsl:value-of select="$spans"/>
  463. <xsl:text> = </xsl:text>
  464. <xsl:call-template name="consume-row">
  465. <xsl:with-param name="spans" select="$spans"/>
  466. </xsl:call-template>
  467. </xsl:message>
  468. -->
  469. <xsl:if test="normalize-space(.//text()) != ''">
  470. <xsl:message>Warning: overlapped row contains content!</xsl:message>
  471. </xsl:if>
  472. <tr><xsl:comment> This row intentionally left blank </xsl:comment></tr>
  473. <xsl:apply-templates select="following-sibling::row[1]">
  474. <xsl:with-param name="spans">
  475. <xsl:call-template name="consume-row">
  476. <xsl:with-param name="spans" select="$spans"/>
  477. </xsl:call-template>
  478. </xsl:with-param>
  479. </xsl:apply-templates>
  480. </xsl:otherwise>
  481. </xsl:choose>
  482. </xsl:template>
  483. <xsl:template name="normal-row">
  484. <xsl:param name="spans"/>
  485. <xsl:variable name="row-height">
  486. <xsl:if test="processing-instruction('dbhtml')">
  487. <xsl:call-template name="pi.dbhtml_row-height"/>
  488. </xsl:if>
  489. </xsl:variable>
  490. <xsl:variable name="bgcolor">
  491. <xsl:if test="processing-instruction('dbhtml')">
  492. <xsl:call-template name="pi.dbhtml_bgcolor"/>
  493. </xsl:if>
  494. </xsl:variable>
  495. <xsl:variable name="class">
  496. <xsl:if test="processing-instruction('dbhtml')">
  497. <xsl:call-template name="pi.dbhtml_class"/>
  498. </xsl:if>
  499. </xsl:variable>
  500. <tr>
  501. <xsl:call-template name="tr.attributes">
  502. <xsl:with-param name="rownum">
  503. <xsl:number from="tgroup" count="row"/>
  504. </xsl:with-param>
  505. </xsl:call-template>
  506. <xsl:if test="$row-height != ''">
  507. <xsl:attribute name="height">
  508. <xsl:value-of select="$row-height"/>
  509. </xsl:attribute>
  510. </xsl:if>
  511. <xsl:if test="$bgcolor != ''">
  512. <xsl:attribute name="bgcolor">
  513. <xsl:value-of select="$bgcolor"/>
  514. </xsl:attribute>
  515. </xsl:if>
  516. <xsl:if test="$class != ''">
  517. <xsl:attribute name="class">
  518. <xsl:value-of select="$class"/>
  519. </xsl:attribute>
  520. </xsl:if>
  521. <xsl:if test="$table.borders.with.css != 0">
  522. <xsl:if test="@rowsep = 1 and following-sibling::row">
  523. <xsl:attribute name="style">
  524. <xsl:call-template name="border">
  525. <xsl:with-param name="side" select="'bottom'"/>
  526. </xsl:call-template>
  527. </xsl:attribute>
  528. </xsl:if>
  529. </xsl:if>
  530. <xsl:if test="@align">
  531. <xsl:attribute name="align">
  532. <xsl:value-of select="@align"/>
  533. </xsl:attribute>
  534. </xsl:if>
  535. <xsl:if test="@char">
  536. <xsl:attribute name="char">
  537. <xsl:value-of select="@char"/>
  538. </xsl:attribute>
  539. </xsl:if>
  540. <xsl:if test="@charoff">
  541. <xsl:attribute name="charoff">
  542. <xsl:value-of select="@charoff"/>
  543. </xsl:attribute>
  544. </xsl:if>
  545. <xsl:if test="@valign">
  546. <xsl:attribute name="valign">
  547. <xsl:value-of select="@valign"/>
  548. </xsl:attribute>
  549. </xsl:if>
  550. <xsl:apply-templates select="(entry|entrytbl)[1]">
  551. <xsl:with-param name="spans" select="$spans"/>
  552. </xsl:apply-templates>
  553. </tr>
  554. <xsl:if test="following-sibling::row">
  555. <xsl:variable name="nextspans">
  556. <xsl:apply-templates select="(entry|entrytbl)[1]" mode="span">
  557. <xsl:with-param name="spans" select="$spans"/>
  558. </xsl:apply-templates>
  559. </xsl:variable>
  560. <xsl:apply-templates select="following-sibling::row[1]">
  561. <xsl:with-param name="spans" select="$nextspans"/>
  562. </xsl:apply-templates>
  563. </xsl:if>
  564. </xsl:template>
  565. <xsl:template match="entry|entrytbl" name="entry">
  566. <xsl:param name="col" select="1"/>
  567. <xsl:param name="spans"/>
  568. <xsl:variable name="cellgi">
  569. <xsl:choose>
  570. <xsl:when test="ancestor::thead">th</xsl:when>
  571. <xsl:when test="ancestor::tfoot">th</xsl:when>
  572. <xsl:otherwise>td</xsl:otherwise>
  573. </xsl:choose>
  574. </xsl:variable>
  575. <xsl:variable name="empty.cell" select="count(node()) = 0"/>
  576. <xsl:variable name="named.colnum">
  577. <xsl:call-template name="entry.colnum"/>
  578. </xsl:variable>
  579. <xsl:variable name="entry.colnum">
  580. <xsl:choose>
  581. <xsl:when test="$named.colnum &gt; 0">
  582. <xsl:value-of select="$named.colnum"/>
  583. </xsl:when>
  584. <xsl:otherwise>
  585. <xsl:value-of select="$col"/>
  586. </xsl:otherwise>
  587. </xsl:choose>
  588. </xsl:variable>
  589. <xsl:variable name="entry.colspan">
  590. <xsl:choose>
  591. <xsl:when test="@spanname or @namest">
  592. <xsl:call-template name="calculate.colspan"/>
  593. </xsl:when>
  594. <xsl:otherwise>1</xsl:otherwise>
  595. </xsl:choose>
  596. </xsl:variable>
  597. <xsl:variable name="following.spans">
  598. <xsl:call-template name="calculate.following.spans">
  599. <xsl:with-param name="colspan" select="$entry.colspan"/>
  600. <xsl:with-param name="spans" select="$spans"/>
  601. </xsl:call-template>
  602. </xsl:variable>
  603. <xsl:variable name="rowsep">
  604. <xsl:choose>
  605. <!-- If this is the last row, rowsep never applies. -->
  606. <xsl:when test="ancestor::entrytbl and not (ancestor-or-self::row[1]/following-sibling::row)">
  607. <xsl:value-of select="0"/>
  608. </xsl:when>
  609. <xsl:when test="not(ancestor-or-self::row[1]/following-sibling::row or ancestor-or-self::thead/following-sibling::tbody or ancestor-or-self::tbody/preceding-sibling::tfoot)">
  610. <xsl:value-of select="0"/>
  611. </xsl:when>
  612. <xsl:when test="@morerows and not(@morerows &lt; count(ancestor-or-self::row[1]/following-sibling::row))">
  613. <xsl:value-of select="0"/>
  614. </xsl:when>
  615. <xsl:otherwise>
  616. <xsl:call-template name="inherited.table.attribute">
  617. <xsl:with-param name="entry" select="."/>
  618. <xsl:with-param name="colnum" select="$entry.colnum"/>
  619. <xsl:with-param name="attribute" select="'rowsep'"/>
  620. </xsl:call-template>
  621. </xsl:otherwise>
  622. </xsl:choose>
  623. </xsl:variable>
  624. <xsl:variable name="colsep">
  625. <xsl:choose>
  626. <!-- If this is the last column, colsep never applies. -->
  627. <xsl:when test="$following.spans = ''">0</xsl:when>
  628. <xsl:otherwise>
  629. <xsl:call-template name="inherited.table.attribute">
  630. <xsl:with-param name="entry" select="."/>
  631. <xsl:with-param name="colnum" select="$entry.colnum"/>
  632. <xsl:with-param name="attribute" select="'colsep'"/>
  633. </xsl:call-template>
  634. </xsl:otherwise>
  635. </xsl:choose>
  636. </xsl:variable>
  637. <xsl:variable name="valign">
  638. <xsl:call-template name="inherited.table.attribute">
  639. <xsl:with-param name="entry" select="."/>
  640. <xsl:with-param name="colnum" select="$entry.colnum"/>
  641. <xsl:with-param name="attribute" select="'valign'"/>
  642. </xsl:call-template>
  643. </xsl:variable>
  644. <xsl:variable name="align">
  645. <xsl:call-template name="inherited.table.attribute">
  646. <xsl:with-param name="entry" select="."/>
  647. <xsl:with-param name="colnum" select="$entry.colnum"/>
  648. <xsl:with-param name="attribute" select="'align'"/>
  649. </xsl:call-template>
  650. </xsl:variable>
  651. <xsl:variable name="char">
  652. <xsl:call-template name="inherited.table.attribute">
  653. <xsl:with-param name="entry" select="."/>
  654. <xsl:with-param name="colnum" select="$entry.colnum"/>
  655. <xsl:with-param name="attribute" select="'char'"/>
  656. </xsl:call-template>
  657. </xsl:variable>
  658. <xsl:variable name="charoff">
  659. <xsl:call-template name="inherited.table.attribute">
  660. <xsl:with-param name="entry" select="."/>
  661. <xsl:with-param name="colnum" select="$entry.colnum"/>
  662. <xsl:with-param name="attribute" select="'charoff'"/>
  663. </xsl:call-template>
  664. </xsl:variable>
  665. <xsl:choose>
  666. <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
  667. <xsl:call-template name="entry">
  668. <xsl:with-param name="col" select="$col+1"/>
  669. <xsl:with-param name="spans" select="substring-after($spans,':')"/>
  670. </xsl:call-template>
  671. </xsl:when>
  672. <xsl:when test="number($entry.colnum) &gt; $col">
  673. <xsl:call-template name="empty.table.cell"/>
  674. <xsl:call-template name="entry">
  675. <xsl:with-param name="col" select="$col+1"/>
  676. <xsl:with-param name="spans" select="substring-after($spans,':')"/>
  677. </xsl:call-template>
  678. </xsl:when>
  679. <xsl:otherwise>
  680. <xsl:variable name="bgcolor">
  681. <xsl:if test="processing-instruction('dbhtml')">
  682. <xsl:call-template name="pi.dbhtml_bgcolor"/>
  683. </xsl:if>
  684. </xsl:variable>
  685. <xsl:element name="{$cellgi}" namespace="http://www.w3.org/1999/xhtml">
  686. <xsl:if test="$bgcolor != ''">
  687. <xsl:attribute name="bgcolor">
  688. <xsl:value-of select="$bgcolor"/>
  689. </xsl:attribute>
  690. </xsl:if>
  691. <xsl:if test="$entry.propagates.style != 0 and @role">
  692. <xsl:apply-templates select="." mode="class.attribute">
  693. <xsl:with-param name="class" select="@role"/>
  694. </xsl:apply-templates>
  695. </xsl:if>
  696. <xsl:if test="$show.revisionflag and @revisionflag">
  697. <xsl:attribute name="class">
  698. <xsl:value-of select="@revisionflag"/>
  699. </xsl:attribute>
  700. </xsl:if>
  701. <xsl:if test="$table.borders.with.css != 0">
  702. <xsl:attribute name="style">
  703. <xsl:if test="$colsep &gt; 0">
  704. <xsl:call-template name="border">
  705. <xsl:with-param name="side" select="'right'"/>
  706. </xsl:call-template>
  707. </xsl:if>
  708. <xsl:if test="$rowsep &gt; 0">
  709. <xsl:call-template name="border">
  710. <xsl:with-param name="side" select="'bottom'"/>
  711. </xsl:call-template>
  712. </xsl:if>
  713. </xsl:attribute>
  714. </xsl:if>
  715. <xsl:if test="@morerows &gt; 0">
  716. <xsl:attribute name="rowspan">
  717. <xsl:value-of select="1+@morerows"/>
  718. </xsl:attribute>
  719. </xsl:if>
  720. <xsl:if test="$entry.colspan &gt; 1">
  721. <xsl:attribute name="colspan">
  722. <xsl:value-of select="$entry.colspan"/>
  723. </xsl:attribute>
  724. </xsl:if>
  725. <xsl:if test="$align != ''">
  726. <xsl:attribute name="align">
  727. <xsl:value-of select="$align"/>
  728. </xsl:attribute>
  729. </xsl:if>
  730. <xsl:if test="$valign != ''">
  731. <xsl:attribute name="valign">
  732. <xsl:value-of select="$valign"/>
  733. </xsl:attribute>
  734. </xsl:if>
  735. <xsl:if test="$char != ''">
  736. <xsl:attribute name="char">
  737. <xsl:value-of select="$char"/>
  738. </xsl:attribute>
  739. </xsl:if>
  740. <xsl:if test="$charoff != ''">
  741. <xsl:attribute name="charoff">
  742. <xsl:value-of select="$charoff"/>
  743. </xsl:attribute>
  744. </xsl:if>
  745. <xsl:if test="not(preceding-sibling::*) and (ancestor::row[1]/@id or ancestor::row[1]/@xml:id)">
  746. <xsl:call-template name="anchor">
  747. <xsl:with-param name="node" select="ancestor::row[1]"/>
  748. </xsl:call-template>
  749. </xsl:if>
  750. <xsl:call-template name="anchor"/>
  751. <xsl:choose>
  752. <xsl:when test="$empty.cell">
  753. <xsl:text>&#160;</xsl:text>
  754. </xsl:when>
  755. <xsl:when test="self::entrytbl">
  756. <xsl:call-template name="tgroup"/>
  757. </xsl:when>
  758. <xsl:otherwise>
  759. <xsl:apply-templates/>
  760. </xsl:otherwise>
  761. </xsl:choose>
  762. </xsl:element>
  763. <xsl:choose>
  764. <xsl:when test="following-sibling::entry|following-sibling::entrytbl">
  765. <xsl:apply-templates select="(following-sibling::entry |following-sibling::entrytbl)[1]">
  766. <xsl:with-param name="col" select="$col+$entry.colspan"/>
  767. <xsl:with-param name="spans" select="$following.spans"/>
  768. </xsl:apply-templates>
  769. </xsl:when>
  770. <xsl:otherwise>
  771. <xsl:call-template name="finaltd">
  772. <xsl:with-param name="spans" select="$following.spans"/>
  773. <xsl:with-param name="col" select="$col+$entry.colspan"/>
  774. </xsl:call-template>
  775. </xsl:otherwise>
  776. </xsl:choose>
  777. </xsl:otherwise>
  778. </xsl:choose>
  779. </xsl:template>
  780. <xsl:template match="entry|entrytbl" name="sentry" mode="span">
  781. <xsl:param name="col" select="1"/>
  782. <xsl:param name="spans"/>
  783. <xsl:variable name="entry.colnum">
  784. <xsl:call-template name="entry.colnum"/>
  785. </xsl:variable>
  786. <xsl:variable name="entry.colspan">
  787. <xsl:choose>
  788. <xsl:when test="@spanname or @namest">
  789. <xsl:call-template name="calculate.colspan"/>
  790. </xsl:when>
  791. <xsl:otherwise>1</xsl:otherwise>
  792. </xsl:choose>
  793. </xsl:variable>
  794. <xsl:variable name="following.spans">
  795. <xsl:call-template name="calculate.following.spans">
  796. <xsl:with-param name="colspan" select="$entry.colspan"/>
  797. <xsl:with-param name="spans" select="$spans"/>
  798. </xsl:call-template>
  799. </xsl:variable>
  800. <xsl:choose>
  801. <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
  802. <xsl:value-of select="substring-before($spans,':')-1"/>
  803. <xsl:text>:</xsl:text>
  804. <xsl:call-template name="sentry">
  805. <xsl:with-param name="col" select="$col+1"/>
  806. <xsl:with-param name="spans" select="substring-after($spans,':')"/>
  807. </xsl:call-template>
  808. </xsl:when>
  809. <xsl:when test="number($entry.colnum) &gt; $col">
  810. <xsl:text>0:</xsl:text>
  811. <xsl:call-template name="sentry">
  812. <xsl:with-param name="col" select="$col+$entry.colspan"/>
  813. <xsl:with-param name="spans" select="$following.spans"/>
  814. </xsl:call-template>
  815. </xsl:when>
  816. <xsl:otherwise>
  817. <xsl:call-template name="copy-string">
  818. <xsl:with-param name="count" select="$entry.colspan"/>
  819. <xsl:with-param name="string">
  820. <xsl:choose>
  821. <xsl:when test="@morerows">
  822. <xsl:value-of select="@morerows"/>
  823. </xsl:when>
  824. <xsl:otherwise>0</xsl:otherwise>
  825. </xsl:choose>
  826. <xsl:text>:</xsl:text>
  827. </xsl:with-param>
  828. </xsl:call-template>
  829. <xsl:choose>
  830. <xsl:when test="following-sibling::entry|following-sibling::entrytbl">
  831. <xsl:apply-templates select="(following-sibling::entry |following-sibling::entrytbl)[1]" mode="span">
  832. <xsl:with-param name="col" select="$col+$entry.colspan"/>
  833. <xsl:with-param name="spans" select="$following.spans"/>
  834. </xsl:apply-templates>
  835. </xsl:when>
  836. <xsl:otherwise>
  837. <xsl:call-template name="sfinaltd">
  838. <xsl:with-param name="spans" select="$following.spans"/>
  839. </xsl:call-template>
  840. </xsl:otherwise>
  841. </xsl:choose>
  842. </xsl:otherwise>
  843. </xsl:choose>
  844. </xsl:template>
  845. <xsl:template name="generate.colgroup">
  846. <xsl:param name="cols" select="1"/>
  847. <xsl:param name="count" select="1"/>
  848. <xsl:choose>
  849. <xsl:when test="$count &gt; $cols"/>
  850. <xsl:otherwise>
  851. <xsl:call-template name="generate.col">
  852. <xsl:with-param name="countcol" select="$count"/>
  853. </xsl:call-template>
  854. <xsl:call-template name="generate.colgroup">
  855. <xsl:with-param name="cols" select="$cols"/>
  856. <xsl:with-param name="count" select="$count+1"/>
  857. </xsl:call-template>
  858. </xsl:otherwise>
  859. </xsl:choose>
  860. </xsl:template>
  861. <xsl:template name="generate.col">
  862. <xsl:param name="countcol">1</xsl:param>
  863. <xsl:param name="colspecs" select="./colspec"/>
  864. <xsl:param name="count">1</xsl:param>
  865. <xsl:param name="colnum">1</xsl:param>
  866. <xsl:choose>
  867. <xsl:when test="$count&gt;count($colspecs)">
  868. <col/>
  869. </xsl:when>
  870. <xsl:otherwise>
  871. <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
  872. <xsl:variable name="colspec.colnum">
  873. <xsl:choose>
  874. <xsl:when test="$colspec/@colnum">
  875. <xsl:value-of select="$colspec/@colnum"/>
  876. </xsl:when>
  877. <xsl:otherwise>
  878. <xsl:value-of select="$colnum"/>
  879. </xsl:otherwise>
  880. </xsl:choose>
  881. </xsl:variable>
  882. <xsl:choose>
  883. <xsl:when test="$colspec.colnum=$countcol">
  884. <col>
  885. <xsl:if test="$colspec/@colwidth and $use.extensions != 0 and $tablecolumns.extension != 0">
  886. <xsl:attribute name="width">
  887. <xsl:choose>
  888. <xsl:when test="normalize-space($colspec/@colwidth) = '*'">
  889. <xsl:value-of select="'1*'"/>
  890. </xsl:when>
  891. <xsl:otherwise>
  892. <xsl:value-of select="$colspec/@colwidth"/>
  893. </xsl:otherwise>
  894. </xsl:choose>
  895. </xsl:attribute>
  896. </xsl:if>
  897. <xsl:choose>
  898. <xsl:when test="$colspec/@align">
  899. <xsl:attribute name="align">
  900. <xsl:value-of select="$colspec/@align"/>
  901. </xsl:attribute>
  902. </xsl:when>
  903. <!-- Suggested by Pavel ZAMPACH <zampach@nemcb.cz> -->
  904. <xsl:when test="$colspecs/ancestor::tgroup/@align">
  905. <xsl:attribute name="align">
  906. <xsl:value-of select="$colspecs/ancestor::tgroup/@align"/>
  907. </xsl:attribute>
  908. </xsl:when>
  909. </xsl:choose>
  910. <xsl:if test="$colspec/@char">
  911. <xsl:attribute name="char">
  912. <xsl:value-of select="$colspec/@char"/>
  913. </xsl:attribute>
  914. </xsl:if>
  915. <xsl:if test="$colspec/@charoff">
  916. <xsl:attribute name="charoff">
  917. <xsl:value-of select="$colspec/@charoff"/>
  918. </xsl:attribute>
  919. </xsl:if>
  920. </col>
  921. </xsl:when>
  922. <xsl:otherwise>
  923. <xsl:call-template name="generate.col">
  924. <xsl:with-param name="countcol" select="$countcol"/>
  925. <xsl:with-param name="colspecs" select="$colspecs"/>
  926. <xsl:with-param name="count" select="$count+1"/>
  927. <xsl:with-param name="colnum">
  928. <xsl:choose>
  929. <xsl:when test="$colspec/@colnum">
  930. <xsl:value-of select="$colspec/@colnum + 1"/>
  931. </xsl:when>
  932. <xsl:otherwise>
  933. <xsl:value-of select="$colnum + 1"/>
  934. </xsl:otherwise>
  935. </xsl:choose>
  936. </xsl:with-param>
  937. </xsl:call-template>
  938. </xsl:otherwise>
  939. </xsl:choose>
  940. </xsl:otherwise>
  941. </xsl:choose>
  942. </xsl:template>
  943. <xsl:template name="colspec.colwidth">
  944. <!-- when this macro is called, the current context must be an entry -->
  945. <xsl:param name="colname"/>
  946. <!-- .. = row, ../.. = thead|tbody, ../../.. = tgroup -->
  947. <xsl:param name="colspecs" select="../../../../tgroup/colspec"/>
  948. <xsl:param name="count">1</xsl:param>
  949. <xsl:choose>
  950. <xsl:when test="$count&gt;count($colspecs)"/>
  951. <xsl:otherwise>
  952. <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
  953. <xsl:choose>
  954. <xsl:when test="$colspec/@colname=$colname">
  955. <xsl:value-of select="$colspec/@colwidth"/>
  956. </xsl:when>
  957. <xsl:otherwise>
  958. <xsl:call-template name="colspec.colwidth">
  959. <xsl:with-param name="colname" select="$colname"/>
  960. <xsl:with-param name="colspecs" select="$colspecs"/>
  961. <xsl:with-param name="count" select="$count+1"/>
  962. </xsl:call-template>
  963. </xsl:otherwise>
  964. </xsl:choose>
  965. </xsl:otherwise>
  966. </xsl:choose>
  967. </xsl:template>
  968. <!-- ====================================================================== -->
  969. <xsl:template name="tr.attributes">
  970. <xsl:param name="row" select="."/>
  971. <xsl:param name="rownum" select="0"/>
  972. <!-- by default, do nothing. But you might want to say:
  973. <xsl:if test="$rownum mod 2 = 0">
  974. <xsl:attribute name="class">oddrow</xsl:attribute>
  975. </xsl:if>
  976. -->
  977. </xsl:template>
  978. </xsl:stylesheet>