table.xsl 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693
  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:fo="http://www.w3.org/1999/XSL/Format"
  5. xmlns:rx="http://www.renderx.com/XSL/Extensions"
  6. xmlns:stbl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Table"
  7. xmlns:xtbl="com.nwalsh.xalan.Table"
  8. xmlns:lxslt="http://xml.apache.org/xslt"
  9. xmlns:ptbl="http://nwalsh.com/xslt/ext/xsltproc/python/Table"
  10. exclude-result-prefixes="doc stbl xtbl lxslt ptbl"
  11. version='1.0'>
  12. <xsl:include href="../common/table.xsl"/>
  13. <!-- ********************************************************************
  14. $Id: table.xsl 9666 2012-11-14 04:42:56Z bobstayton $
  15. ********************************************************************
  16. This file is part of the XSL DocBook Stylesheet distribution.
  17. See ../README or http://docbook.sf.net/release/xsl/current/ for
  18. copyright and other information.
  19. ******************************************************************** -->
  20. <doc:reference xmlns="" xml:id="table-templates">
  21. <?dbhtml dir="fo"?>
  22. <info>
  23. <title>Formatting Object Table Reference</title>
  24. <releaseinfo role="meta">
  25. $Id: table.xsl 9666 2012-11-14 04:42:56Z bobstayton $
  26. </releaseinfo>
  27. </info>
  28. <partintro xml:id="partintro">
  29. <title>Introduction</title>
  30. <para>This is technical reference documentation for the FO
  31. table-processing templates in the DocBook XSL Stylesheets.</para>
  32. <para>This is not intended to be user documentation. It is
  33. provided for developers writing customization layers for the
  34. stylesheets.</para>
  35. </partintro>
  36. </doc:reference>
  37. <!-- ==================================================================== -->
  38. <lxslt:component prefix="xtbl"
  39. functions="adjustColumnWidths"/>
  40. <!-- ==================================================================== -->
  41. <xsl:template name="make.table.content">
  42. <xsl:choose>
  43. <xsl:when test="tgroup|mediaobject|graphic">
  44. <xsl:call-template name="calsTable"/>
  45. </xsl:when>
  46. <xsl:otherwise>
  47. <xsl:apply-templates select="." mode="htmlTable"/>
  48. </xsl:otherwise>
  49. </xsl:choose>
  50. </xsl:template>
  51. <!-- ==================================================================== -->
  52. <xsl:template name="calsTable">
  53. <xsl:variable name="keep.together">
  54. <xsl:call-template name="pi.dbfo_keep-together"/>
  55. </xsl:variable>
  56. <xsl:for-each select="tgroup">
  57. <fo:table xsl:use-attribute-sets="table.table.properties">
  58. <xsl:if test="$keep.together != ''">
  59. <xsl:attribute name="keep-together.within-column">
  60. <xsl:value-of select="$keep.together"/>
  61. </xsl:attribute>
  62. </xsl:if>
  63. <xsl:call-template name="table.frame"/>
  64. <xsl:if test="following-sibling::tgroup">
  65. <xsl:attribute name="border-bottom-width">0pt</xsl:attribute>
  66. <xsl:attribute name="border-bottom-style">none</xsl:attribute>
  67. <xsl:attribute name="padding-bottom">0pt</xsl:attribute>
  68. <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
  69. <xsl:attribute name="space-after">0pt</xsl:attribute>
  70. <xsl:attribute name="space-after.minimum">0pt</xsl:attribute>
  71. <xsl:attribute name="space-after.optimum">0pt</xsl:attribute>
  72. <xsl:attribute name="space-after.maximum">0pt</xsl:attribute>
  73. </xsl:if>
  74. <xsl:if test="preceding-sibling::tgroup">
  75. <xsl:attribute name="border-top-width">0pt</xsl:attribute>
  76. <xsl:attribute name="border-top-style">none</xsl:attribute>
  77. <xsl:attribute name="padding-top">0pt</xsl:attribute>
  78. <xsl:attribute name="margin-top">0pt</xsl:attribute>
  79. <xsl:attribute name="space-before">0pt</xsl:attribute>
  80. <xsl:attribute name="space-before.minimum">0pt</xsl:attribute>
  81. <xsl:attribute name="space-before.optimum">0pt</xsl:attribute>
  82. <xsl:attribute name="space-before.maximum">0pt</xsl:attribute>
  83. </xsl:if>
  84. <xsl:apply-templates select="."/>
  85. </fo:table>
  86. <xsl:for-each select="mediaobject|graphic">
  87. <xsl:apply-templates select="."/>
  88. </xsl:for-each>
  89. </xsl:for-each>
  90. <xsl:apply-templates select="caption"/>
  91. </xsl:template>
  92. <!-- ==================================================================== -->
  93. <!-- Placeholder template enables wrapping a fo:table in
  94. another table for purposes of layout or applying
  95. extensions such as XEP table-omit-initial-header to
  96. create "continued" titles on page breaks. -->
  97. <xsl:template name="table.layout">
  98. <xsl:param name="table.content" select="NOTANODE"/>
  99. <xsl:copy-of select="$table.content"/>
  100. </xsl:template>
  101. <xsl:template name="table.block">
  102. <xsl:param name="table.layout" select="NOTANODE"/>
  103. <xsl:variable name="id">
  104. <xsl:call-template name="object.id"/>
  105. </xsl:variable>
  106. <xsl:variable name="param.placement"
  107. select="substring-after(normalize-space(
  108. $formal.title.placement), concat(local-name(.), ' '))"/>
  109. <xsl:variable name="placement">
  110. <xsl:choose>
  111. <xsl:when test="contains($param.placement, ' ')">
  112. <xsl:value-of select="substring-before($param.placement, ' ')"/>
  113. </xsl:when>
  114. <xsl:when test="$param.placement = ''">before</xsl:when>
  115. <xsl:otherwise>
  116. <xsl:value-of select="$param.placement"/>
  117. </xsl:otherwise>
  118. </xsl:choose>
  119. </xsl:variable>
  120. <xsl:variable name="keep.together">
  121. <xsl:call-template name="pi.dbfo_keep-together"/>
  122. </xsl:variable>
  123. <xsl:choose>
  124. <xsl:when test="self::table">
  125. <fo:block id="{$id}"
  126. xsl:use-attribute-sets="table.properties">
  127. <xsl:if test="$keep.together != ''">
  128. <xsl:attribute name="keep-together.within-column">
  129. <xsl:value-of select="$keep.together"/>
  130. </xsl:attribute>
  131. </xsl:if>
  132. <xsl:if test="$placement = 'before'">
  133. <xsl:call-template name="formal.object.heading">
  134. <xsl:with-param name="placement" select="$placement"/>
  135. </xsl:call-template>
  136. </xsl:if>
  137. <xsl:copy-of select="$table.layout"/>
  138. <xsl:call-template name="table.footnote.block"/>
  139. <xsl:if test="$placement != 'before'">
  140. <xsl:call-template name="formal.object.heading">
  141. <xsl:with-param name="placement" select="$placement"/>
  142. </xsl:call-template>
  143. </xsl:if>
  144. </fo:block>
  145. </xsl:when>
  146. <xsl:otherwise>
  147. <fo:block id="{$id}"
  148. xsl:use-attribute-sets="informaltable.properties">
  149. <xsl:if test="$keep.together != ''">
  150. <xsl:attribute name="keep-together.within-column">
  151. <xsl:value-of select="$keep.together"/>
  152. </xsl:attribute>
  153. </xsl:if>
  154. <xsl:copy-of select="$table.layout"/>
  155. <xsl:call-template name="table.footnote.block"/>
  156. </fo:block>
  157. </xsl:otherwise>
  158. </xsl:choose>
  159. </xsl:template>
  160. <!-- Output a table's footnotes in a block -->
  161. <xsl:template name="table.footnote.block">
  162. <xsl:if test=".//footnote">
  163. <fo:block keep-with-previous.within-column="always">
  164. <xsl:apply-templates select=".//footnote" mode="table.footnote.mode"/>
  165. </fo:block>
  166. </xsl:if>
  167. </xsl:template>
  168. <!-- ==================================================================== -->
  169. <xsl:template name="table.container">
  170. <xsl:param name="table.block"/>
  171. <xsl:choose>
  172. <xsl:when test="@orient='land' and
  173. $fop.extensions = 0" >
  174. <fo:block-container reference-orientation="90"
  175. padding="6pt"
  176. xsl:use-attribute-sets="list.block.spacing">
  177. <xsl:attribute name="width">
  178. <xsl:call-template name="table.width"/>
  179. </xsl:attribute>
  180. <fo:block start-indent="0pt" end-indent="0pt">
  181. <xsl:copy-of select="$table.block"/>
  182. </fo:block>
  183. </fo:block-container>
  184. </xsl:when>
  185. <xsl:when test="@pgwide = 1">
  186. <fo:block xsl:use-attribute-sets="pgwide.properties">
  187. <xsl:copy-of select="$table.block"/>
  188. </fo:block>
  189. </xsl:when>
  190. <xsl:otherwise>
  191. <xsl:copy-of select="$table.block"/>
  192. </xsl:otherwise>
  193. </xsl:choose>
  194. </xsl:template>
  195. <!-- ==================================================================== -->
  196. <xsl:template name="empty.table.cell">
  197. <xsl:param name="colnum" select="0"/>
  198. <xsl:variable name="rowsep">
  199. <xsl:choose>
  200. <!-- If this is the last row, rowsep never applies (except when
  201. the ancestor tgroup has a following sibling tgroup) -->
  202. <xsl:when test="not(ancestor-or-self::row[1]/following-sibling::row
  203. or ancestor-or-self::thead/following-sibling::tbody
  204. or ancestor-or-self::tbody/preceding-sibling::tfoot)
  205. and not(ancestor::tgroup/following-sibling::tgroup)">
  206. <xsl:value-of select="0"/>
  207. </xsl:when>
  208. <xsl:otherwise>
  209. <xsl:call-template name="inherited.table.attribute">
  210. <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
  211. <xsl:with-param name="row" select="ancestor-or-self::row[1]"/>
  212. <xsl:with-param name="colnum" select="$colnum"/>
  213. <xsl:with-param name="attribute" select="'rowsep'"/>
  214. </xsl:call-template>
  215. </xsl:otherwise>
  216. </xsl:choose>
  217. </xsl:variable>
  218. <xsl:variable name="colsep">
  219. <xsl:choose>
  220. <!-- If this is the last column, colsep never applies. -->
  221. <xsl:when test="number($colnum) &gt;= ancestor::tgroup/@cols">0</xsl:when>
  222. <xsl:otherwise>
  223. <xsl:call-template name="inherited.table.attribute">
  224. <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
  225. <xsl:with-param name="row" select="ancestor-or-self::row[1]"/>
  226. <xsl:with-param name="colnum" select="$colnum"/>
  227. <xsl:with-param name="attribute" select="'colsep'"/>
  228. </xsl:call-template>
  229. </xsl:otherwise>
  230. </xsl:choose>
  231. </xsl:variable>
  232. <fo:table-cell text-align="center"
  233. display-align="center"
  234. xsl:use-attribute-sets="table.cell.padding">
  235. <xsl:if test="$xep.extensions != 0">
  236. <!-- Suggested by RenderX to workaround a bug in their implementation -->
  237. <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  238. </xsl:if>
  239. <xsl:if test="$rowsep &gt; 0">
  240. <xsl:call-template name="border">
  241. <xsl:with-param name="side" select="'bottom'"/>
  242. </xsl:call-template>
  243. </xsl:if>
  244. <xsl:if test="$colsep &gt; 0 and number($colnum) &lt; ancestor::tgroup/@cols">
  245. <xsl:call-template name="border">
  246. <xsl:with-param name="side" select="'end'"/>
  247. </xsl:call-template>
  248. </xsl:if>
  249. <!-- fo:table-cell should not be empty -->
  250. <fo:block/>
  251. </fo:table-cell>
  252. </xsl:template>
  253. <!-- ==================================================================== -->
  254. <xsl:template name="table.frame">
  255. <xsl:param name="frame">
  256. <xsl:choose>
  257. <xsl:when test="../@frame">
  258. <xsl:value-of select="../@frame"/>
  259. </xsl:when>
  260. <xsl:when test="$default.table.frame != ''">
  261. <xsl:value-of select="$default.table.frame"/>
  262. </xsl:when>
  263. <xsl:otherwise>all</xsl:otherwise>
  264. </xsl:choose>
  265. </xsl:param>
  266. <xsl:choose>
  267. <xsl:when test="$frame='all'">
  268. <xsl:attribute name="border-start-style">
  269. <xsl:value-of select="$table.frame.border.style"/>
  270. </xsl:attribute>
  271. <xsl:attribute name="border-end-style">
  272. <xsl:value-of select="$table.frame.border.style"/>
  273. </xsl:attribute>
  274. <xsl:attribute name="border-top-style">
  275. <xsl:value-of select="$table.frame.border.style"/>
  276. </xsl:attribute>
  277. <xsl:attribute name="border-bottom-style">
  278. <xsl:value-of select="$table.frame.border.style"/>
  279. </xsl:attribute>
  280. <xsl:attribute name="border-start-width">
  281. <xsl:value-of select="$table.frame.border.thickness"/>
  282. </xsl:attribute>
  283. <xsl:attribute name="border-end-width">
  284. <xsl:value-of select="$table.frame.border.thickness"/>
  285. </xsl:attribute>
  286. <xsl:attribute name="border-top-width">
  287. <xsl:value-of select="$table.frame.border.thickness"/>
  288. </xsl:attribute>
  289. <xsl:attribute name="border-bottom-width">
  290. <xsl:value-of select="$table.frame.border.thickness"/>
  291. </xsl:attribute>
  292. <xsl:attribute name="border-start-color">
  293. <xsl:value-of select="$table.frame.border.color"/>
  294. </xsl:attribute>
  295. <xsl:attribute name="border-end-color">
  296. <xsl:value-of select="$table.frame.border.color"/>
  297. </xsl:attribute>
  298. <xsl:attribute name="border-top-color">
  299. <xsl:value-of select="$table.frame.border.color"/>
  300. </xsl:attribute>
  301. <xsl:attribute name="border-bottom-color">
  302. <xsl:value-of select="$table.frame.border.color"/>
  303. </xsl:attribute>
  304. </xsl:when>
  305. <xsl:when test="$frame='bottom'">
  306. <xsl:attribute name="border-start-style">none</xsl:attribute>
  307. <xsl:attribute name="border-end-style">none</xsl:attribute>
  308. <xsl:attribute name="border-top-style">none</xsl:attribute>
  309. <xsl:attribute name="border-bottom-style">
  310. <xsl:value-of select="$table.frame.border.style"/>
  311. </xsl:attribute>
  312. <xsl:attribute name="border-bottom-width">
  313. <xsl:value-of select="$table.frame.border.thickness"/>
  314. </xsl:attribute>
  315. <xsl:attribute name="border-bottom-color">
  316. <xsl:value-of select="$table.frame.border.color"/>
  317. </xsl:attribute>
  318. </xsl:when>
  319. <xsl:when test="$frame='sides'">
  320. <xsl:attribute name="border-start-style">
  321. <xsl:value-of select="$table.frame.border.style"/>
  322. </xsl:attribute>
  323. <xsl:attribute name="border-end-style">
  324. <xsl:value-of select="$table.frame.border.style"/>
  325. </xsl:attribute>
  326. <xsl:attribute name="border-top-style">none</xsl:attribute>
  327. <xsl:attribute name="border-bottom-style">none</xsl:attribute>
  328. <xsl:attribute name="border-start-width">
  329. <xsl:value-of select="$table.frame.border.thickness"/>
  330. </xsl:attribute>
  331. <xsl:attribute name="border-end-width">
  332. <xsl:value-of select="$table.frame.border.thickness"/>
  333. </xsl:attribute>
  334. <xsl:attribute name="border-start-color">
  335. <xsl:value-of select="$table.frame.border.color"/>
  336. </xsl:attribute>
  337. <xsl:attribute name="border-end-color">
  338. <xsl:value-of select="$table.frame.border.color"/>
  339. </xsl:attribute>
  340. </xsl:when>
  341. <xsl:when test="$frame='lhs'">
  342. <xsl:attribute name="border-start-style">
  343. <xsl:value-of select="$table.frame.border.style"/>
  344. </xsl:attribute>
  345. <xsl:attribute name="border-end-style">none</xsl:attribute>
  346. <xsl:attribute name="border-top-style">none</xsl:attribute>
  347. <xsl:attribute name="border-bottom-style">none</xsl:attribute>
  348. <xsl:attribute name="border-start-width">
  349. <xsl:value-of select="$table.frame.border.thickness"/>
  350. </xsl:attribute>
  351. <xsl:attribute name="border-start-color">
  352. <xsl:value-of select="$table.frame.border.color"/>
  353. </xsl:attribute>
  354. </xsl:when>
  355. <xsl:when test="$frame='rhs'">
  356. <xsl:attribute name="border-end-style">
  357. <xsl:value-of select="$table.frame.border.style"/>
  358. </xsl:attribute>
  359. <xsl:attribute name="border-end-style">none</xsl:attribute>
  360. <xsl:attribute name="border-top-style">none</xsl:attribute>
  361. <xsl:attribute name="border-bottom-style">none</xsl:attribute>
  362. <xsl:attribute name="border-end-width">
  363. <xsl:value-of select="$table.frame.border.thickness"/>
  364. </xsl:attribute>
  365. <xsl:attribute name="border-end-color">
  366. <xsl:value-of select="$table.frame.border.color"/>
  367. </xsl:attribute>
  368. </xsl:when>
  369. <xsl:when test="$frame='top'">
  370. <xsl:attribute name="border-start-style">none</xsl:attribute>
  371. <xsl:attribute name="border-end-style">none</xsl:attribute>
  372. <xsl:attribute name="border-top-style">
  373. <xsl:value-of select="$table.frame.border.style"/>
  374. </xsl:attribute>
  375. <xsl:attribute name="border-bottom-style">none</xsl:attribute>
  376. <xsl:attribute name="border-top-width">
  377. <xsl:value-of select="$table.frame.border.thickness"/>
  378. </xsl:attribute>
  379. <xsl:attribute name="border-top-color">
  380. <xsl:value-of select="$table.frame.border.color"/>
  381. </xsl:attribute>
  382. </xsl:when>
  383. <xsl:when test="$frame='topbot'">
  384. <xsl:attribute name="border-start-style">none</xsl:attribute>
  385. <xsl:attribute name="border-end-style">none</xsl:attribute>
  386. <xsl:attribute name="border-top-style">
  387. <xsl:value-of select="$table.frame.border.style"/>
  388. </xsl:attribute>
  389. <xsl:attribute name="border-bottom-style">
  390. <xsl:value-of select="$table.frame.border.style"/>
  391. </xsl:attribute>
  392. <xsl:attribute name="border-top-width">
  393. <xsl:value-of select="$table.frame.border.thickness"/>
  394. </xsl:attribute>
  395. <xsl:attribute name="border-bottom-width">
  396. <xsl:value-of select="$table.frame.border.thickness"/>
  397. </xsl:attribute>
  398. <xsl:attribute name="border-top-color">
  399. <xsl:value-of select="$table.frame.border.color"/>
  400. </xsl:attribute>
  401. <xsl:attribute name="border-bottom-color">
  402. <xsl:value-of select="$table.frame.border.color"/>
  403. </xsl:attribute>
  404. </xsl:when>
  405. <xsl:when test="$frame='none'">
  406. <xsl:attribute name="border-start-style">none</xsl:attribute>
  407. <xsl:attribute name="border-end-style">none</xsl:attribute>
  408. <xsl:attribute name="border-top-style">none</xsl:attribute>
  409. <xsl:attribute name="border-bottom-style">none</xsl:attribute>
  410. </xsl:when>
  411. <xsl:otherwise>
  412. <xsl:message>
  413. <xsl:text>Impossible frame on table: </xsl:text>
  414. <xsl:value-of select="$frame"/>
  415. </xsl:message>
  416. <xsl:attribute name="border-start-style">none</xsl:attribute>
  417. <xsl:attribute name="border-end-style">none</xsl:attribute>
  418. <xsl:attribute name="border-top-style">none</xsl:attribute>
  419. <xsl:attribute name="border-bottom-style">none</xsl:attribute>
  420. </xsl:otherwise>
  421. </xsl:choose>
  422. </xsl:template>
  423. <!-- ==================================================================== -->
  424. <xsl:template name="border">
  425. <xsl:param name="side" select="'start'"/>
  426. <xsl:attribute name="border-{$side}-width">
  427. <xsl:value-of select="$table.cell.border.thickness"/>
  428. </xsl:attribute>
  429. <xsl:attribute name="border-{$side}-style">
  430. <xsl:value-of select="$table.cell.border.style"/>
  431. </xsl:attribute>
  432. <xsl:attribute name="border-{$side}-color">
  433. <xsl:value-of select="$table.cell.border.color"/>
  434. </xsl:attribute>
  435. </xsl:template>
  436. <!-- ==================================================================== -->
  437. <xsl:template match="tgroup" name="tgroup">
  438. <xsl:if test="not(@cols) or @cols = '' or string(number(@cols)) = 'NaN'">
  439. <xsl:message terminate="yes">
  440. <xsl:text>Error: CALS tables must specify the number of columns.</xsl:text>
  441. </xsl:message>
  442. </xsl:if>
  443. <xsl:variable name="table.width">
  444. <xsl:call-template name="table.width"/>
  445. </xsl:variable>
  446. <xsl:variable name="colspecs">
  447. <xsl:choose>
  448. <xsl:when test="$use.extensions != 0
  449. and $tablecolumns.extension != 0">
  450. <xsl:call-template name="generate.colgroup.raw">
  451. <xsl:with-param name="cols" select="@cols"/>
  452. </xsl:call-template>
  453. </xsl:when>
  454. <xsl:otherwise>
  455. <xsl:call-template name="generate.colgroup">
  456. <xsl:with-param name="cols" select="@cols"/>
  457. </xsl:call-template>
  458. </xsl:otherwise>
  459. </xsl:choose>
  460. </xsl:variable>
  461. <xsl:variable name="prop-columns"
  462. select=".//colspec[contains(@colwidth, '*')]"/>
  463. <xsl:if test="count($prop-columns) != 0 or
  464. $fop.extensions != 0 or
  465. $fop1.extensions != 0">
  466. <xsl:attribute name="table-layout">fixed</xsl:attribute>
  467. </xsl:if>
  468. <xsl:attribute name="width">
  469. <xsl:value-of select="$table.width"/>
  470. </xsl:attribute>
  471. <xsl:choose>
  472. <xsl:when test="$use.extensions != 0
  473. and $tablecolumns.extension != 0">
  474. <xsl:choose>
  475. <xsl:when test="function-available('stbl:adjustColumnWidths')">
  476. <xsl:copy-of select="stbl:adjustColumnWidths($colspecs)"/>
  477. </xsl:when>
  478. <xsl:when test="function-available('xtbl:adjustColumnWidths')">
  479. <xsl:copy-of select="xtbl:adjustColumnWidths($colspecs)"/>
  480. </xsl:when>
  481. <xsl:when test="function-available('ptbl:adjustColumnWidths')">
  482. <xsl:copy-of select="ptbl:adjustColumnWidths($colspecs)"/>
  483. </xsl:when>
  484. <xsl:otherwise>
  485. <xsl:message terminate="yes">
  486. <xsl:text>No adjustColumnWidths function available.</xsl:text>
  487. </xsl:message>
  488. </xsl:otherwise>
  489. </xsl:choose>
  490. </xsl:when>
  491. <xsl:otherwise>
  492. <xsl:copy-of select="$colspecs"/>
  493. </xsl:otherwise>
  494. </xsl:choose>
  495. <xsl:apply-templates select="thead"/>
  496. <xsl:apply-templates select="tfoot"/>
  497. <xsl:apply-templates select="tbody"/>
  498. </xsl:template>
  499. <xsl:template match="colspec"></xsl:template>
  500. <xsl:template name="table.width">
  501. <xsl:variable name="numcols">
  502. <xsl:call-template name="widest-html-row">
  503. <xsl:with-param name="rows" select=".//tr"/>
  504. </xsl:call-template>
  505. </xsl:variable>
  506. <xsl:variable name="explicit.table.width">
  507. <xsl:choose>
  508. <xsl:when test="self::entrytbl">
  509. <xsl:call-template name="pi.dbfo_table-width"/>
  510. </xsl:when>
  511. <xsl:when test="self::table or self::informaltable">
  512. <xsl:call-template name="pi.dbfo_table-width"/>
  513. </xsl:when>
  514. <xsl:otherwise>
  515. <!-- * no dbfo@table-width PI as a child of this table, so check -->
  516. <!-- * the parent of this table to see if the table has any -->
  517. <!-- * sibling dbfo@table-width PIs (FIXME: 2007-07 MikeSmith: we -->
  518. <!-- * should really instead be checking here just to see if the -->
  519. <!-- * first preceding sibling of this table is a -->
  520. <!-- * dbfo@table-width PI) -->
  521. <xsl:call-template name="pi.dbfo_table-width">
  522. <xsl:with-param name="node" select=".."/>
  523. </xsl:call-template>
  524. </xsl:otherwise>
  525. </xsl:choose>
  526. </xsl:variable>
  527. <xsl:variable name="column.sum">
  528. <xsl:choose>
  529. <!-- CALS table -->
  530. <xsl:when test="tgroup/@cols">
  531. <!-- change context to the first tgroup -->
  532. <xsl:for-each select="tgroup[1]">
  533. <xsl:if test="count(colspec) = @cols">
  534. <xsl:for-each select="colspec">
  535. <xsl:if test="position() != 1">
  536. <xsl:text> + </xsl:text>
  537. </xsl:if>
  538. <xsl:choose>
  539. <xsl:when test="not(@colwidth)">NOWIDTH</xsl:when>
  540. <xsl:when test="contains(@colwidth, '*')">NOWIDTH</xsl:when>
  541. <xsl:otherwise>
  542. <xsl:value-of select="@colwidth"/>
  543. </xsl:otherwise>
  544. </xsl:choose>
  545. </xsl:for-each>
  546. </xsl:if>
  547. </xsl:for-each>
  548. </xsl:when>
  549. <xsl:otherwise>
  550. <!-- HTML table -->
  551. <xsl:if test="count(col|colgroup/col) = $numcols">
  552. <xsl:for-each select="col|colgroup/col">
  553. <xsl:if test="position() != 1">
  554. <xsl:text> + </xsl:text>
  555. </xsl:if>
  556. <xsl:choose>
  557. <xsl:when test="not(@width)">NOWIDTH</xsl:when>
  558. <xsl:when test="contains(@width, '%')">NOWIDTH</xsl:when>
  559. <xsl:otherwise>
  560. <xsl:value-of select="@width"/>
  561. </xsl:otherwise>
  562. </xsl:choose>
  563. </xsl:for-each>
  564. </xsl:if>
  565. </xsl:otherwise>
  566. </xsl:choose>
  567. </xsl:variable>
  568. <xsl:variable name="column.sum.width">
  569. <xsl:if test="not(contains($column.sum, 'NOWIDTH'))">
  570. <xsl:value-of select="$column.sum"/>
  571. </xsl:if>
  572. </xsl:variable>
  573. <xsl:variable name="prop-columns"
  574. select=".//colspec[contains(@colwidth, '*')]"/>
  575. <xsl:variable name="table.width">
  576. <xsl:choose>
  577. <xsl:when test="$explicit.table.width != ''">
  578. <xsl:value-of select="$explicit.table.width"/>
  579. </xsl:when>
  580. <xsl:when test="$column.sum.width != ''">
  581. <xsl:value-of select="$column.sum.width"/>
  582. </xsl:when>
  583. <xsl:when test="$default.table.width = ''">
  584. <xsl:choose>
  585. <!-- These processors don't support table-layout="auto" -->
  586. <xsl:when test="$fop.extensions != 0 or
  587. $fop1.extensions != 0">
  588. <xsl:text>100%</xsl:text>
  589. </xsl:when>
  590. <!-- Proportional columns imply 100% width -->
  591. <xsl:when test="count($prop-columns) != 0">
  592. <xsl:text>100%</xsl:text>
  593. </xsl:when>
  594. <xsl:otherwise>
  595. <xsl:text>auto</xsl:text>
  596. </xsl:otherwise>
  597. </xsl:choose>
  598. </xsl:when>
  599. <xsl:otherwise>
  600. <xsl:value-of select="$default.table.width"/>
  601. </xsl:otherwise>
  602. </xsl:choose>
  603. </xsl:variable>
  604. <xsl:value-of select="$table.width"/>
  605. </xsl:template>
  606. <xsl:template match="spanspec"></xsl:template>
  607. <xsl:template match="thead">
  608. <xsl:variable name="tgroup" select="parent::*"/>
  609. <fo:table-header start-indent="0pt" end-indent="0pt">
  610. <xsl:choose>
  611. <!-- Use recursion if @morerows is used -->
  612. <xsl:when test="row/entry/@morerows|row/entrytbl/@morerows">
  613. <xsl:apply-templates select="row[1]">
  614. <xsl:with-param name="spans">
  615. <xsl:call-template name="blank.spans">
  616. <xsl:with-param name="cols" select="../@cols"/>
  617. </xsl:call-template>
  618. </xsl:with-param>
  619. <xsl:with-param name="browserows" select="'recurse'"/>
  620. </xsl:apply-templates>
  621. </xsl:when>
  622. <xsl:otherwise>
  623. <xsl:apply-templates select="row">
  624. <xsl:with-param name="spans">
  625. <xsl:call-template name="blank.spans">
  626. <xsl:with-param name="cols" select="../@cols"/>
  627. </xsl:call-template>
  628. </xsl:with-param>
  629. <xsl:with-param name="browserows" select="'loop'" />
  630. </xsl:apply-templates>
  631. </xsl:otherwise>
  632. </xsl:choose>
  633. </fo:table-header>
  634. </xsl:template>
  635. <xsl:template match="tfoot">
  636. <xsl:variable name="tgroup" select="parent::*"/>
  637. <fo:table-footer start-indent="0pt" end-indent="0pt">
  638. <xsl:choose>
  639. <!-- Use recursion if @morerows is used -->
  640. <xsl:when test="row/entry/@morerows|row/entrytbl/@morerows">
  641. <xsl:apply-templates select="row[1]">
  642. <xsl:with-param name="spans">
  643. <xsl:call-template name="blank.spans">
  644. <xsl:with-param name="cols" select="../@cols"/>
  645. </xsl:call-template>
  646. </xsl:with-param>
  647. <xsl:with-param name="browserows" select="'recurse'"/>
  648. </xsl:apply-templates>
  649. </xsl:when>
  650. <xsl:otherwise>
  651. <xsl:apply-templates select="row">
  652. <xsl:with-param name="spans">
  653. <xsl:call-template name="blank.spans">
  654. <xsl:with-param name="cols" select="../@cols"/>
  655. </xsl:call-template>
  656. </xsl:with-param>
  657. <xsl:with-param name="browserows" select="'loop'" />
  658. </xsl:apply-templates>
  659. </xsl:otherwise>
  660. </xsl:choose>
  661. </fo:table-footer>
  662. </xsl:template>
  663. <xsl:template match="tbody">
  664. <xsl:variable name="tgroup" select="parent::*"/>
  665. <fo:table-body start-indent="0pt" end-indent="0pt">
  666. <xsl:choose>
  667. <!-- Use recursion if @morerows is used -->
  668. <xsl:when test="row/entry/@morerows|row/entrytbl/@morerows">
  669. <xsl:apply-templates select="row[1]">
  670. <xsl:with-param name="spans">
  671. <xsl:call-template name="blank.spans">
  672. <xsl:with-param name="cols" select="../@cols"/>
  673. </xsl:call-template>
  674. </xsl:with-param>
  675. <xsl:with-param name="browserows" select="'recurse'"/>
  676. </xsl:apply-templates>
  677. </xsl:when>
  678. <xsl:otherwise>
  679. <xsl:apply-templates select="row">
  680. <xsl:with-param name="spans">
  681. <xsl:call-template name="blank.spans">
  682. <xsl:with-param name="cols" select="../@cols"/>
  683. </xsl:call-template>
  684. </xsl:with-param>
  685. <xsl:with-param name="browserows" select="'loop'" />
  686. </xsl:apply-templates>
  687. </xsl:otherwise>
  688. </xsl:choose>
  689. </fo:table-body>
  690. </xsl:template>
  691. <xsl:template match="row">
  692. <xsl:param name="spans"/>
  693. <xsl:param name="browserows"/>
  694. <xsl:choose>
  695. <xsl:when test="contains($spans, '0')">
  696. <xsl:call-template name="normal-row">
  697. <xsl:with-param name="spans" select="$spans"/>
  698. <xsl:with-param name="browserows" select="$browserows"/>
  699. </xsl:call-template>
  700. </xsl:when>
  701. <xsl:otherwise>
  702. <!--
  703. <xsl:message>
  704. <xsl:text>Ignoring row: </xsl:text>
  705. <xsl:value-of select="$spans"/>
  706. <xsl:text> = </xsl:text>
  707. <xsl:call-template name="consume-row">
  708. <xsl:with-param name="spans" select="$spans"/>
  709. </xsl:call-template>
  710. </xsl:message>
  711. -->
  712. <xsl:if test="normalize-space(.//text()) != ''">
  713. <xsl:message>Warning: overlapped row contains content!</xsl:message>
  714. </xsl:if>
  715. <fo:table-row>
  716. <xsl:comment> This row intentionally left blank </xsl:comment>
  717. <fo:table-cell><fo:block/></fo:table-cell>
  718. </fo:table-row>
  719. <xsl:if test="$browserows = 'recurse'">
  720. <xsl:apply-templates select="following-sibling::row[1]">
  721. <xsl:with-param name="spans">
  722. <xsl:call-template name="consume-row">
  723. <xsl:with-param name="spans" select="$spans"/>
  724. </xsl:call-template>
  725. </xsl:with-param>
  726. </xsl:apply-templates>
  727. </xsl:if>
  728. </xsl:otherwise>
  729. </xsl:choose>
  730. </xsl:template>
  731. <xsl:template name="normal-row">
  732. <xsl:param name="spans"/>
  733. <xsl:param name="browserows"/>
  734. <fo:table-row>
  735. <xsl:call-template name="table.row.properties"/>
  736. <xsl:call-template name="anchor"/>
  737. <xsl:apply-templates select="(entry|entrytbl)[1]">
  738. <xsl:with-param name="spans" select="$spans"/>
  739. </xsl:apply-templates>
  740. </fo:table-row>
  741. <xsl:if test="$browserows = 'recurse'">
  742. <xsl:if test="following-sibling::row">
  743. <xsl:variable name="nextspans">
  744. <xsl:apply-templates select="(entry|entrytbl)[1]" mode="span">
  745. <xsl:with-param name="spans" select="$spans"/>
  746. </xsl:apply-templates>
  747. </xsl:variable>
  748. <xsl:apply-templates select="following-sibling::row[1]">
  749. <xsl:with-param name="spans" select="$nextspans"/>
  750. <xsl:with-param name="browserows" select="$browserows"/>
  751. </xsl:apply-templates>
  752. </xsl:if>
  753. </xsl:if>
  754. </xsl:template>
  755. <!-- customize this template to add row properties -->
  756. <xsl:template name="table.row.properties">
  757. <xsl:variable name="row-height">
  758. <xsl:if test="processing-instruction('dbfo')">
  759. <xsl:call-template name="pi.dbfo_row-height"/>
  760. </xsl:if>
  761. </xsl:variable>
  762. <xsl:if test="$row-height != ''">
  763. <xsl:attribute name="block-progression-dimension">
  764. <xsl:value-of select="$row-height"/>
  765. </xsl:attribute>
  766. </xsl:if>
  767. <xsl:variable name="bgcolor">
  768. <xsl:call-template name="pi.dbfo_bgcolor"/>
  769. </xsl:variable>
  770. <xsl:if test="$bgcolor != ''">
  771. <xsl:attribute name="background-color">
  772. <xsl:value-of select="$bgcolor"/>
  773. </xsl:attribute>
  774. </xsl:if>
  775. <!-- Keep header row with next row -->
  776. <xsl:if test="ancestor::thead">
  777. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  778. </xsl:if>
  779. </xsl:template>
  780. <xsl:template match="entry|entrytbl" name="entry">
  781. <xsl:param name="col" select="1"/>
  782. <xsl:param name="spans"/>
  783. <xsl:variable name="row" select="parent::row"/>
  784. <xsl:variable name="group" select="$row/parent::*[1]"/>
  785. <xsl:variable name="frame" select="ancestor::tgroup/parent::*/@frame"/>
  786. <xsl:variable name="empty.cell" select="count(node()) = 0"/>
  787. <xsl:variable name="named.colnum">
  788. <xsl:call-template name="entry.colnum"/>
  789. </xsl:variable>
  790. <xsl:variable name="entry.colnum">
  791. <xsl:choose>
  792. <xsl:when test="$named.colnum &gt; 0">
  793. <xsl:value-of select="$named.colnum"/>
  794. </xsl:when>
  795. <xsl:otherwise>
  796. <xsl:value-of select="$col"/>
  797. </xsl:otherwise>
  798. </xsl:choose>
  799. </xsl:variable>
  800. <xsl:variable name="entry.colspan">
  801. <xsl:choose>
  802. <xsl:when test="@spanname or @namest">
  803. <xsl:call-template name="calculate.colspan"/>
  804. </xsl:when>
  805. <xsl:otherwise>1</xsl:otherwise>
  806. </xsl:choose>
  807. </xsl:variable>
  808. <xsl:variable name="following.spans">
  809. <xsl:call-template name="calculate.following.spans">
  810. <xsl:with-param name="colspan" select="$entry.colspan"/>
  811. <xsl:with-param name="spans" select="$spans"/>
  812. </xsl:call-template>
  813. </xsl:variable>
  814. <xsl:variable name="rowsep">
  815. <xsl:choose>
  816. <!-- If this is the last row, rowsep never applies (except when
  817. the ancestor tgroup has a following sibling tgroup) -->
  818. <xsl:when test="not(ancestor-or-self::row[1]/following-sibling::row
  819. or ancestor-or-self::thead/following-sibling::tbody
  820. or ancestor-or-self::tbody/preceding-sibling::tfoot)
  821. and not(ancestor::tgroup/following-sibling::tgroup)">
  822. <xsl:value-of select="0"/>
  823. </xsl:when>
  824. <!-- Check for morerows too -->
  825. <xsl:when test="(@morerows and count(ancestor-or-self::row[1]/
  826. following-sibling::row) = @morerows )
  827. and not (ancestor-or-self::thead/following-sibling::tbody
  828. or ancestor-or-self::tbody/preceding-sibling::tfoot)
  829. and not(ancestor::tgroup/following-sibling::tgroup)">
  830. <xsl:value-of select="0"/>
  831. </xsl:when>
  832. <xsl:otherwise>
  833. <xsl:call-template name="inherited.table.attribute">
  834. <xsl:with-param name="entry" select="."/>
  835. <xsl:with-param name="colnum" select="$entry.colnum"/>
  836. <xsl:with-param name="attribute" select="'rowsep'"/>
  837. </xsl:call-template>
  838. </xsl:otherwise>
  839. </xsl:choose>
  840. </xsl:variable>
  841. <!--
  842. <xsl:message><xsl:value-of select="."/>: <xsl:value-of select="$rowsep"/></xsl:message>
  843. -->
  844. <xsl:variable name="colsep">
  845. <xsl:choose>
  846. <!-- If this is the last column, colsep never applies. -->
  847. <xsl:when test="$following.spans = ''">0</xsl:when>
  848. <xsl:otherwise>
  849. <xsl:call-template name="inherited.table.attribute">
  850. <xsl:with-param name="entry" select="."/>
  851. <xsl:with-param name="colnum" select="$entry.colnum"/>
  852. <xsl:with-param name="attribute" select="'colsep'"/>
  853. </xsl:call-template>
  854. </xsl:otherwise>
  855. </xsl:choose>
  856. </xsl:variable>
  857. <xsl:variable name="valign">
  858. <xsl:call-template name="inherited.table.attribute">
  859. <xsl:with-param name="entry" select="."/>
  860. <xsl:with-param name="colnum" select="$entry.colnum"/>
  861. <xsl:with-param name="attribute" select="'valign'"/>
  862. </xsl:call-template>
  863. </xsl:variable>
  864. <xsl:variable name="align">
  865. <xsl:call-template name="inherited.table.attribute">
  866. <xsl:with-param name="entry" select="."/>
  867. <xsl:with-param name="colnum" select="$entry.colnum"/>
  868. <xsl:with-param name="attribute" select="'align'"/>
  869. </xsl:call-template>
  870. </xsl:variable>
  871. <xsl:variable name="char">
  872. <xsl:call-template name="inherited.table.attribute">
  873. <xsl:with-param name="entry" select="."/>
  874. <xsl:with-param name="colnum" select="$entry.colnum"/>
  875. <xsl:with-param name="attribute" select="'char'"/>
  876. </xsl:call-template>
  877. </xsl:variable>
  878. <xsl:variable name="charoff">
  879. <xsl:call-template name="inherited.table.attribute">
  880. <xsl:with-param name="entry" select="."/>
  881. <xsl:with-param name="colnum" select="$entry.colnum"/>
  882. <xsl:with-param name="attribute" select="'charoff'"/>
  883. </xsl:call-template>
  884. </xsl:variable>
  885. <xsl:choose>
  886. <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
  887. <xsl:call-template name="entry">
  888. <xsl:with-param name="col" select="$col+1"/>
  889. <xsl:with-param name="spans" select="substring-after($spans,':')"/>
  890. </xsl:call-template>
  891. </xsl:when>
  892. <xsl:when test="number($entry.colnum) &gt; $col">
  893. <xsl:call-template name="empty.table.cell">
  894. <xsl:with-param name="colnum" select="$col"/>
  895. </xsl:call-template>
  896. <xsl:call-template name="entry">
  897. <xsl:with-param name="col" select="$col+1"/>
  898. <xsl:with-param name="spans" select="substring-after($spans,':')"/>
  899. </xsl:call-template>
  900. </xsl:when>
  901. <xsl:otherwise>
  902. <xsl:variable name="cell.content">
  903. <fo:block>
  904. <xsl:call-template name="table.cell.block.properties"/>
  905. <!-- are we missing any indexterms? -->
  906. <xsl:if test="not(preceding-sibling::entry)
  907. and not(parent::row/preceding-sibling::row)">
  908. <!-- this is the first entry of the first row -->
  909. <xsl:if test="ancestor::thead or
  910. (ancestor::tbody
  911. and not(ancestor::tbody/preceding-sibling::thead
  912. or ancestor::tbody/preceding-sibling::tbody))">
  913. <!-- of the thead or the first tbody -->
  914. <xsl:apply-templates select="ancestor::tgroup/preceding-sibling::indexterm"/>
  915. </xsl:if>
  916. </xsl:if>
  917. <!--
  918. <xsl:text>(</xsl:text>
  919. <xsl:value-of select="$rowsep"/>
  920. <xsl:text>,</xsl:text>
  921. <xsl:value-of select="$colsep"/>
  922. <xsl:text>)</xsl:text>
  923. -->
  924. <xsl:choose>
  925. <xsl:when test="$empty.cell">
  926. <xsl:text>&#160;</xsl:text>
  927. </xsl:when>
  928. <xsl:when test="self::entrytbl">
  929. <xsl:variable name="prop-columns"
  930. select=".//colspec[contains(@colwidth, '*')]"/>
  931. <fo:table xsl:use-attribute-sets="table.table.properties">
  932. <xsl:if test="count($prop-columns) != 0">
  933. <xsl:attribute name="table-layout">fixed</xsl:attribute>
  934. </xsl:if>
  935. <xsl:call-template name="tgroup"/>
  936. </fo:table>
  937. </xsl:when>
  938. <xsl:otherwise>
  939. <xsl:apply-templates/>
  940. </xsl:otherwise>
  941. </xsl:choose>
  942. </fo:block>
  943. </xsl:variable>
  944. <xsl:variable name="cell-orientation">
  945. <xsl:call-template name="pi.dbfo_orientation">
  946. <xsl:with-param name="node" select="ancestor-or-self::entry"/>
  947. </xsl:call-template>
  948. </xsl:variable>
  949. <xsl:variable name="row-orientation">
  950. <xsl:call-template name="pi.dbfo_orientation">
  951. <xsl:with-param name="node" select="ancestor-or-self::row"/>
  952. </xsl:call-template>
  953. </xsl:variable>
  954. <xsl:variable name="cell-width">
  955. <xsl:call-template name="pi.dbfo_rotated-width">
  956. <xsl:with-param name="node" select="ancestor-or-self::entry"/>
  957. </xsl:call-template>
  958. </xsl:variable>
  959. <xsl:variable name="row-width">
  960. <xsl:call-template name="pi.dbfo_rotated-width">
  961. <xsl:with-param name="node" select="ancestor-or-self::row"/>
  962. </xsl:call-template>
  963. </xsl:variable>
  964. <xsl:variable name="orientation">
  965. <xsl:choose>
  966. <xsl:when test="$cell-orientation != ''">
  967. <xsl:value-of select="$cell-orientation"/>
  968. </xsl:when>
  969. <xsl:otherwise>
  970. <xsl:value-of select="$row-orientation"/>
  971. </xsl:otherwise>
  972. </xsl:choose>
  973. </xsl:variable>
  974. <xsl:variable name="rotated-width">
  975. <xsl:choose>
  976. <xsl:when test="$cell-width != ''">
  977. <xsl:value-of select="$cell-width"/>
  978. </xsl:when>
  979. <xsl:otherwise>
  980. <xsl:value-of select="$row-width"/>
  981. </xsl:otherwise>
  982. </xsl:choose>
  983. </xsl:variable>
  984. <xsl:variable name="bgcolor">
  985. <xsl:call-template name="pi.dbfo_bgcolor">
  986. <xsl:with-param name="node" select="ancestor-or-self::entry"/>
  987. </xsl:call-template>
  988. </xsl:variable>
  989. <fo:table-cell xsl:use-attribute-sets="table.cell.padding">
  990. <xsl:call-template name="table.cell.properties">
  991. <xsl:with-param name="bgcolor.pi" select="$bgcolor"/>
  992. <xsl:with-param name="rowsep.inherit" select="$rowsep"/>
  993. <xsl:with-param name="colsep.inherit" select="$colsep"/>
  994. <xsl:with-param name="col" select="$col"/>
  995. <xsl:with-param name="valign.inherit" select="$valign"/>
  996. <xsl:with-param name="align.inherit" select="$align"/>
  997. <xsl:with-param name="char.inherit" select="$char"/>
  998. </xsl:call-template>
  999. <xsl:call-template name="anchor"/>
  1000. <xsl:if test="@morerows">
  1001. <xsl:attribute name="number-rows-spanned">
  1002. <xsl:value-of select="@morerows+1"/>
  1003. </xsl:attribute>
  1004. </xsl:if>
  1005. <xsl:if test="$entry.colspan &gt; 1">
  1006. <xsl:attribute name="number-columns-spanned">
  1007. <xsl:value-of select="$entry.colspan"/>
  1008. </xsl:attribute>
  1009. </xsl:if>
  1010. <!--
  1011. <xsl:if test="@charoff">
  1012. <xsl:attribute name="charoff">
  1013. <xsl:value-of select="@charoff"/>
  1014. </xsl:attribute>
  1015. </xsl:if>
  1016. -->
  1017. <xsl:choose>
  1018. <xsl:when test="$fop.extensions = 0
  1019. and $orientation != ''">
  1020. <fo:block-container reference-orientation="{$orientation}">
  1021. <xsl:if test="$rotated-width != ''">
  1022. <xsl:attribute name="width">
  1023. <xsl:value-of select="$rotated-width"/>
  1024. </xsl:attribute>
  1025. </xsl:if>
  1026. <xsl:copy-of select="$cell.content"/>
  1027. </fo:block-container>
  1028. </xsl:when>
  1029. <xsl:otherwise>
  1030. <xsl:copy-of select="$cell.content"/>
  1031. </xsl:otherwise>
  1032. </xsl:choose>
  1033. </fo:table-cell>
  1034. <xsl:choose>
  1035. <xsl:when test="following-sibling::entry|following-sibling::entrytbl">
  1036. <xsl:apply-templates select="(following-sibling::entry
  1037. |following-sibling::entrytbl)[1]">
  1038. <xsl:with-param name="col" select="$col+$entry.colspan"/>
  1039. <xsl:with-param name="spans" select="$following.spans"/>
  1040. </xsl:apply-templates>
  1041. </xsl:when>
  1042. <xsl:otherwise>
  1043. <xsl:call-template name="finaltd">
  1044. <xsl:with-param name="spans" select="$following.spans"/>
  1045. <xsl:with-param name="col" select="$col+$entry.colspan"/>
  1046. </xsl:call-template>
  1047. </xsl:otherwise>
  1048. </xsl:choose>
  1049. </xsl:otherwise>
  1050. </xsl:choose>
  1051. </xsl:template>
  1052. <!-- Expand this template to add properties to any fo:table-cell -->
  1053. <xsl:template name="table.cell.properties">
  1054. <xsl:param name="bgcolor.pi" select="''"/>
  1055. <xsl:param name="rowsep.inherit" select="1"/>
  1056. <xsl:param name="colsep.inherit" select="1"/>
  1057. <xsl:param name="col" select="1"/>
  1058. <xsl:param name="valign.inherit" select="''"/>
  1059. <xsl:param name="align.inherit" select="''"/>
  1060. <xsl:param name="char.inherit" select="''"/>
  1061. <xsl:choose>
  1062. <xsl:when test="ancestor::tgroup">
  1063. <xsl:if test="$bgcolor.pi != ''">
  1064. <xsl:attribute name="background-color">
  1065. <xsl:value-of select="$bgcolor.pi"/>
  1066. </xsl:attribute>
  1067. </xsl:if>
  1068. <xsl:if test="$rowsep.inherit &gt; 0">
  1069. <xsl:call-template name="border">
  1070. <xsl:with-param name="side" select="'bottom'"/>
  1071. </xsl:call-template>
  1072. </xsl:if>
  1073. <xsl:if test="$colsep.inherit &gt; 0 and
  1074. $col &lt; (ancestor::tgroup/@cols|ancestor::entrytbl/@cols)[last()]">
  1075. <xsl:call-template name="border">
  1076. <xsl:with-param name="side" select="'end'"/>
  1077. </xsl:call-template>
  1078. </xsl:if>
  1079. <xsl:if test="$valign.inherit != ''">
  1080. <xsl:attribute name="display-align">
  1081. <xsl:choose>
  1082. <xsl:when test="$valign.inherit='top'">before</xsl:when>
  1083. <xsl:when test="$valign.inherit='middle'">center</xsl:when>
  1084. <xsl:when test="$valign.inherit='bottom'">after</xsl:when>
  1085. <xsl:otherwise>
  1086. <xsl:message>
  1087. <xsl:text>Unexpected valign value: </xsl:text>
  1088. <xsl:value-of select="$valign.inherit"/>
  1089. <xsl:text>, center used.</xsl:text>
  1090. </xsl:message>
  1091. <xsl:text>center</xsl:text>
  1092. </xsl:otherwise>
  1093. </xsl:choose>
  1094. </xsl:attribute>
  1095. </xsl:if>
  1096. <xsl:choose>
  1097. <xsl:when test="$align.inherit = 'char' and $char.inherit != ''">
  1098. <xsl:attribute name="text-align">
  1099. <xsl:value-of select="$char.inherit"/>
  1100. </xsl:attribute>
  1101. </xsl:when>
  1102. <xsl:when test="$align.inherit != ''">
  1103. <xsl:attribute name="text-align">
  1104. <xsl:value-of select="$align.inherit"/>
  1105. </xsl:attribute>
  1106. </xsl:when>
  1107. </xsl:choose>
  1108. </xsl:when>
  1109. <xsl:otherwise>
  1110. <!-- HTML table -->
  1111. <xsl:if test="$bgcolor.pi != ''">
  1112. <xsl:attribute name="background-color">
  1113. <xsl:value-of select="$bgcolor.pi"/>
  1114. </xsl:attribute>
  1115. </xsl:if>
  1116. <xsl:if test="$align.inherit != ''">
  1117. <xsl:attribute name="text-align">
  1118. <xsl:value-of select="$align.inherit"/>
  1119. </xsl:attribute>
  1120. </xsl:if>
  1121. <xsl:if test="$valign.inherit != ''">
  1122. <xsl:attribute name="display-align">
  1123. <xsl:choose>
  1124. <xsl:when test="$valign.inherit='top'">before</xsl:when>
  1125. <xsl:when test="$valign.inherit='middle'">center</xsl:when>
  1126. <xsl:when test="$valign.inherit='bottom'">after</xsl:when>
  1127. <xsl:otherwise>
  1128. <xsl:message>
  1129. <xsl:text>Unexpected valign value: </xsl:text>
  1130. <xsl:value-of select="$valign.inherit"/>
  1131. <xsl:text>, center used.</xsl:text>
  1132. </xsl:message>
  1133. <xsl:text>center</xsl:text>
  1134. </xsl:otherwise>
  1135. </xsl:choose>
  1136. </xsl:attribute>
  1137. </xsl:if>
  1138. <xsl:call-template name="html.table.cell.rules"/>
  1139. </xsl:otherwise>
  1140. </xsl:choose>
  1141. </xsl:template>
  1142. <!-- Expand this template to add properties to any cell's block -->
  1143. <xsl:template name="table.cell.block.properties">
  1144. <!-- highlight this entry? -->
  1145. <xsl:choose>
  1146. <xsl:when test="ancestor::thead or ancestor::tfoot">
  1147. <xsl:attribute name="font-weight">bold</xsl:attribute>
  1148. </xsl:when>
  1149. <!-- Make row headers bold too -->
  1150. <xsl:when test="ancestor::tbody and
  1151. (ancestor::table[@rowheader = 'firstcol'] or
  1152. ancestor::informaltable[@rowheader = 'firstcol']) and
  1153. ancestor-or-self::entry[1][count(preceding-sibling::entry) = 0]">
  1154. <xsl:attribute name="font-weight">bold</xsl:attribute>
  1155. </xsl:when>
  1156. </xsl:choose>
  1157. </xsl:template>
  1158. <xsl:template match="entry|entrytbl" name="sentry" mode="span">
  1159. <xsl:param name="col" select="1"/>
  1160. <xsl:param name="spans"/>
  1161. <xsl:variable name="entry.colnum">
  1162. <xsl:call-template name="entry.colnum"/>
  1163. </xsl:variable>
  1164. <xsl:variable name="entry.colspan">
  1165. <xsl:choose>
  1166. <xsl:when test="@spanname or @namest">
  1167. <xsl:call-template name="calculate.colspan"/>
  1168. </xsl:when>
  1169. <xsl:otherwise>1</xsl:otherwise>
  1170. </xsl:choose>
  1171. </xsl:variable>
  1172. <xsl:variable name="following.spans">
  1173. <xsl:call-template name="calculate.following.spans">
  1174. <xsl:with-param name="colspan" select="$entry.colspan"/>
  1175. <xsl:with-param name="spans" select="$spans"/>
  1176. </xsl:call-template>
  1177. </xsl:variable>
  1178. <xsl:choose>
  1179. <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
  1180. <xsl:value-of select="substring-before($spans,':')-1"/>
  1181. <xsl:text>:</xsl:text>
  1182. <xsl:call-template name="sentry">
  1183. <xsl:with-param name="col" select="$col+1"/>
  1184. <xsl:with-param name="spans" select="substring-after($spans,':')"/>
  1185. </xsl:call-template>
  1186. </xsl:when>
  1187. <xsl:when test="number($entry.colnum) &gt; $col">
  1188. <xsl:text>0:</xsl:text>
  1189. <xsl:call-template name="sentry">
  1190. <xsl:with-param name="col" select="$col + 1"/>
  1191. <xsl:with-param name="spans" select="substring-after($spans,':')"/>
  1192. </xsl:call-template>
  1193. </xsl:when>
  1194. <xsl:otherwise>
  1195. <xsl:call-template name="copy-string">
  1196. <xsl:with-param name="count" select="$entry.colspan"/>
  1197. <xsl:with-param name="string">
  1198. <xsl:choose>
  1199. <xsl:when test="@morerows">
  1200. <xsl:value-of select="@morerows"/>
  1201. </xsl:when>
  1202. <xsl:otherwise>0</xsl:otherwise>
  1203. </xsl:choose>
  1204. <xsl:text>:</xsl:text>
  1205. </xsl:with-param>
  1206. </xsl:call-template>
  1207. <xsl:choose>
  1208. <xsl:when test="following-sibling::entry|following-sibling::entrytbl">
  1209. <xsl:apply-templates select="(following-sibling::entry
  1210. |following-sibling::entrytbl)[1]"
  1211. mode="span">
  1212. <xsl:with-param name="col" select="$col+$entry.colspan"/>
  1213. <xsl:with-param name="spans" select="$following.spans"/>
  1214. </xsl:apply-templates>
  1215. </xsl:when>
  1216. <xsl:otherwise>
  1217. <xsl:call-template name="sfinaltd">
  1218. <xsl:with-param name="spans" select="$following.spans"/>
  1219. </xsl:call-template>
  1220. </xsl:otherwise>
  1221. </xsl:choose>
  1222. </xsl:otherwise>
  1223. </xsl:choose>
  1224. </xsl:template>
  1225. <xsl:template name="generate.colgroup.raw">
  1226. <xsl:param name="cols" select="1"/>
  1227. <xsl:param name="count" select="1"/>
  1228. <xsl:choose>
  1229. <xsl:when test="$count>$cols"></xsl:when>
  1230. <xsl:otherwise>
  1231. <xsl:call-template name="generate.col.raw">
  1232. <xsl:with-param name="countcol" select="$count"/>
  1233. </xsl:call-template>
  1234. <xsl:call-template name="generate.colgroup.raw">
  1235. <xsl:with-param name="cols" select="$cols"/>
  1236. <xsl:with-param name="count" select="$count+1"/>
  1237. </xsl:call-template>
  1238. </xsl:otherwise>
  1239. </xsl:choose>
  1240. </xsl:template>
  1241. <xsl:template name="generate.colgroup">
  1242. <xsl:param name="cols" select="1"/>
  1243. <xsl:param name="count" select="1"/>
  1244. <xsl:choose>
  1245. <xsl:when test="$count>$cols"></xsl:when>
  1246. <xsl:otherwise>
  1247. <xsl:call-template name="generate.col">
  1248. <xsl:with-param name="countcol" select="$count"/>
  1249. </xsl:call-template>
  1250. <xsl:call-template name="generate.colgroup">
  1251. <xsl:with-param name="cols" select="$cols"/>
  1252. <xsl:with-param name="count" select="$count+1"/>
  1253. </xsl:call-template>
  1254. </xsl:otherwise>
  1255. </xsl:choose>
  1256. </xsl:template>
  1257. <xsl:template name="generate.col.raw">
  1258. <!-- generate the table-column for column countcol -->
  1259. <xsl:param name="countcol">1</xsl:param>
  1260. <xsl:param name="colspecs" select="./colspec"/>
  1261. <xsl:param name="count">1</xsl:param>
  1262. <xsl:param name="colnum">1</xsl:param>
  1263. <xsl:choose>
  1264. <xsl:when test="$count>count($colspecs)">
  1265. <fo:table-column column-number="{$countcol}"/>
  1266. </xsl:when>
  1267. <xsl:otherwise>
  1268. <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
  1269. <xsl:variable name="colspec.colnum">
  1270. <xsl:choose>
  1271. <xsl:when test="$colspec/@colnum">
  1272. <xsl:value-of select="$colspec/@colnum"/>
  1273. </xsl:when>
  1274. <xsl:otherwise>
  1275. <xsl:value-of select="$colnum"/>
  1276. </xsl:otherwise>
  1277. </xsl:choose>
  1278. </xsl:variable>
  1279. <xsl:variable name="colspec.colwidth">
  1280. <xsl:choose>
  1281. <xsl:when test="normalize-space($colspec/@colwidth)='*'">1*</xsl:when>
  1282. <xsl:when test="$colspec/@colwidth">
  1283. <xsl:value-of select="$colspec/@colwidth"/>
  1284. </xsl:when>
  1285. <xsl:otherwise>1*</xsl:otherwise>
  1286. </xsl:choose>
  1287. </xsl:variable>
  1288. <xsl:choose>
  1289. <xsl:when test="$colspec.colnum=$countcol">
  1290. <fo:table-column column-number="{$countcol}">
  1291. <xsl:attribute name="column-width">
  1292. <xsl:value-of select="$colspec.colwidth"/>
  1293. </xsl:attribute>
  1294. </fo:table-column>
  1295. </xsl:when>
  1296. <xsl:otherwise>
  1297. <xsl:call-template name="generate.col.raw">
  1298. <xsl:with-param name="countcol" select="$countcol"/>
  1299. <xsl:with-param name="colspecs" select="$colspecs"/>
  1300. <xsl:with-param name="count" select="$count+1"/>
  1301. <xsl:with-param name="colnum">
  1302. <xsl:choose>
  1303. <xsl:when test="$colspec/@colnum">
  1304. <xsl:value-of select="$colspec/@colnum + 1"/>
  1305. </xsl:when>
  1306. <xsl:otherwise>
  1307. <xsl:value-of select="$colnum + 1"/>
  1308. </xsl:otherwise>
  1309. </xsl:choose>
  1310. </xsl:with-param>
  1311. </xsl:call-template>
  1312. </xsl:otherwise>
  1313. </xsl:choose>
  1314. </xsl:otherwise>
  1315. </xsl:choose>
  1316. </xsl:template>
  1317. <xsl:template name="generate.col">
  1318. <!-- generate the table-column for column countcol -->
  1319. <xsl:param name="countcol">1</xsl:param>
  1320. <xsl:param name="colspecs" select="./colspec"/>
  1321. <xsl:param name="count">1</xsl:param>
  1322. <xsl:param name="colnum">1</xsl:param>
  1323. <xsl:choose>
  1324. <xsl:when test="$count>count($colspecs)">
  1325. <fo:table-column column-number="{$countcol}">
  1326. <xsl:variable name="colwidth">
  1327. <xsl:call-template name="calc.column.width"/>
  1328. </xsl:variable>
  1329. <xsl:attribute name="column-width">
  1330. <xsl:value-of select="$colwidth"/>
  1331. </xsl:attribute>
  1332. </fo:table-column>
  1333. </xsl:when>
  1334. <xsl:otherwise>
  1335. <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
  1336. <xsl:variable name="colspec.colnum">
  1337. <xsl:choose>
  1338. <xsl:when test="$colspec/@colnum">
  1339. <xsl:value-of select="$colspec/@colnum"/>
  1340. </xsl:when>
  1341. <xsl:otherwise>
  1342. <xsl:value-of select="$colnum"/>
  1343. </xsl:otherwise>
  1344. </xsl:choose>
  1345. </xsl:variable>
  1346. <xsl:variable name="colspec.colwidth">
  1347. <xsl:choose>
  1348. <xsl:when test="$colspec/@colwidth">
  1349. <xsl:value-of select="$colspec/@colwidth"/>
  1350. </xsl:when>
  1351. <xsl:otherwise>1*</xsl:otherwise>
  1352. </xsl:choose>
  1353. </xsl:variable>
  1354. <xsl:choose>
  1355. <xsl:when test="$colspec.colnum=$countcol">
  1356. <fo:table-column column-number="{$countcol}">
  1357. <xsl:variable name="colwidth">
  1358. <xsl:call-template name="calc.column.width">
  1359. <xsl:with-param name="colwidth">
  1360. <xsl:value-of select="$colspec.colwidth"/>
  1361. </xsl:with-param>
  1362. </xsl:call-template>
  1363. </xsl:variable>
  1364. <xsl:attribute name="column-width">
  1365. <xsl:value-of select="$colwidth"/>
  1366. </xsl:attribute>
  1367. </fo:table-column>
  1368. </xsl:when>
  1369. <xsl:otherwise>
  1370. <xsl:call-template name="generate.col">
  1371. <xsl:with-param name="countcol" select="$countcol"/>
  1372. <xsl:with-param name="colspecs" select="$colspecs"/>
  1373. <xsl:with-param name="count" select="$count+1"/>
  1374. <xsl:with-param name="colnum">
  1375. <xsl:choose>
  1376. <xsl:when test="$colspec/@colnum">
  1377. <xsl:value-of select="$colspec/@colnum + 1"/>
  1378. </xsl:when>
  1379. <xsl:otherwise>
  1380. <xsl:value-of select="$colnum + 1"/>
  1381. </xsl:otherwise>
  1382. </xsl:choose>
  1383. </xsl:with-param>
  1384. </xsl:call-template>
  1385. </xsl:otherwise>
  1386. </xsl:choose>
  1387. </xsl:otherwise>
  1388. </xsl:choose>
  1389. </xsl:template>
  1390. <doc:template name="calc.column.width" xmlns="">
  1391. <refpurpose>Calculate an XSL FO table column width specification from a
  1392. CALS table column width specification.</refpurpose>
  1393. <refdescription>
  1394. <para>CALS expresses table column widths in the following basic
  1395. forms:</para>
  1396. <itemizedlist>
  1397. <listitem>
  1398. <para><emphasis>99.99units</emphasis>, a fixed length specifier.</para>
  1399. </listitem>
  1400. <listitem>
  1401. <para><emphasis>99.99</emphasis>, a fixed length specifier without any units.</para>
  1402. </listitem>
  1403. <listitem>
  1404. <para><emphasis>99.99*</emphasis>, a relative length specifier.</para>
  1405. </listitem>
  1406. <listitem>
  1407. <para><emphasis>99.99*+99.99units</emphasis>, a combination of both.</para>
  1408. </listitem>
  1409. </itemizedlist>
  1410. <para>The CALS units are points (pt), picas (pi), centimeters (cm),
  1411. millimeters (mm), and inches (in). These are the same units as XSL,
  1412. except that XSL abbreviates picas "pc" instead of "pi". If a length
  1413. specifier has no units, the CALS default unit (pt) is assumed.</para>
  1414. <para>Relative length specifiers are represented in XSL with the
  1415. proportional-column-width() function.</para>
  1416. <para>Here are some examples:</para>
  1417. <itemizedlist>
  1418. <listitem>
  1419. <para>"36pt" becomes "36pt"</para>
  1420. </listitem>
  1421. <listitem>
  1422. <para>"3pi" becomes "3pc"</para>
  1423. </listitem>
  1424. <listitem>
  1425. <para>"36" becomes "36pt"</para>
  1426. </listitem>
  1427. <listitem>
  1428. <para>"3*" becomes "proportional-column-width(3)"</para>
  1429. </listitem>
  1430. <listitem>
  1431. <para>"3*+2pi" becomes "proportional-column-width(3)+2pc"</para>
  1432. </listitem>
  1433. <listitem>
  1434. <para>"1*+2" becomes "proportional-column-width(1)+2pt"</para>
  1435. </listitem>
  1436. </itemizedlist>
  1437. </refdescription>
  1438. <refparameter>
  1439. <variablelist>
  1440. <varlistentry><term>colwidth</term>
  1441. <listitem>
  1442. <para>The CALS column width specification.</para>
  1443. </listitem>
  1444. </varlistentry>
  1445. </variablelist>
  1446. </refparameter>
  1447. <refreturn>
  1448. <para>The XSL column width specification.</para>
  1449. </refreturn>
  1450. </doc:template>
  1451. <xsl:template name="calc.column.width">
  1452. <xsl:param name="colwidth">1*</xsl:param>
  1453. <!-- Ok, the colwidth could have any one of the following forms: -->
  1454. <!-- 1* = proportional width -->
  1455. <!-- * = same as 1* -->
  1456. <!-- 1unit = 1.0 units wide -->
  1457. <!-- 1 = 1pt wide -->
  1458. <!-- 1*+1unit = proportional width + some fixed width -->
  1459. <!-- 1*+1 = proportional width + some fixed width -->
  1460. <!-- If it has a proportional width, translate it to XSL -->
  1461. <xsl:if test="contains($colwidth, '*')">
  1462. <xsl:text>proportional-column-width(</xsl:text>
  1463. <xsl:choose>
  1464. <xsl:when test="substring-before($colwidth, '*') != ''">
  1465. <xsl:value-of select="substring-before($colwidth, '*')"/>
  1466. </xsl:when>
  1467. <xsl:otherwise>
  1468. <xsl:text>1.00</xsl:text>
  1469. </xsl:otherwise>
  1470. </xsl:choose>
  1471. <xsl:text>)</xsl:text>
  1472. </xsl:if>
  1473. <!-- Now grab the non-proportional part of the specification -->
  1474. <xsl:variable name="width-units">
  1475. <xsl:choose>
  1476. <xsl:when test="contains($colwidth, '*')">
  1477. <xsl:value-of
  1478. select="normalize-space(substring-after($colwidth, '*'))"/>
  1479. </xsl:when>
  1480. <xsl:otherwise>
  1481. <xsl:value-of select="normalize-space($colwidth)"/>
  1482. </xsl:otherwise>
  1483. </xsl:choose>
  1484. </xsl:variable>
  1485. <!-- Ok, now the width-units could have any one of the following forms: -->
  1486. <!-- = <empty string> -->
  1487. <!-- 1unit = 1.0 units wide -->
  1488. <!-- 1 = 1pt wide -->
  1489. <!-- with an optional leading sign -->
  1490. <!-- Grab the width part by blanking out the units part and discarding -->
  1491. <!-- whitespace. It's not pretty, but it works. -->
  1492. <xsl:variable name="width"
  1493. select="normalize-space(translate($width-units,
  1494. '+-0123456789.abcdefghijklmnopqrstuvwxyz',
  1495. '+-0123456789.'))"/>
  1496. <!-- Grab the units part by blanking out the width part and discarding -->
  1497. <!-- whitespace. It's not pretty, but it works. -->
  1498. <xsl:variable name="units"
  1499. select="normalize-space(translate($width-units,
  1500. 'abcdefghijklmnopqrstuvwxyz+-0123456789.',
  1501. 'abcdefghijklmnopqrstuvwxyz'))"/>
  1502. <!-- Output the width -->
  1503. <xsl:value-of select="$width"/>
  1504. <!-- Output the units, translated appropriately -->
  1505. <xsl:choose>
  1506. <xsl:when test="$units = 'pi'">pc</xsl:when>
  1507. <xsl:when test="$units = '' and $width != ''">pt</xsl:when>
  1508. <xsl:otherwise><xsl:value-of select="$units"/></xsl:otherwise>
  1509. </xsl:choose>
  1510. </xsl:template>
  1511. <xsl:template match="table/caption">
  1512. <fo:block xsl:use-attribute-sets="table.caption.properties">
  1513. <xsl:apply-templates/>
  1514. </fo:block>
  1515. </xsl:template>
  1516. <!-- ==================================================================== -->
  1517. </xsl:stylesheet>