table.xsl 43 KB

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