tables.xsl 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114
  1. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  2. xmlns:opentopic-func="http://www.idiominc.com/opentopic/exsl/function"
  3. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  4. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  5. xmlns:dita2xslfo="http://dita-ot.sourceforge.net/ns/200910/dita2xslfo"
  6. xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
  7. exclude-result-prefixes="opentopic-func xs dita2xslfo dita-ot"
  8. version="2.0">
  9. <xsl:variable name="tableAttrs" select="'../../cfg/fo/attrs/tables-attr.xsl'"/>
  10. <xsl:param name="tableSpecNonProportional" select="'false'"/>
  11. <!-- XML Exchange Table Model Document Type Definition default is all -->
  12. <xsl:variable name="table.frame-default" select="'all'"/>
  13. <!-- XML Exchange Table Model Document Type Definition default is 1 -->
  14. <xsl:variable name="table.rowsep-default" select="'0'"/>
  15. <!-- XML Exchange Table Model Document Type Definition default is 1 -->
  16. <xsl:variable name="table.colsep-default" select="'0'"/>
  17. <!--Definition list-->
  18. <xsl:template match="*[contains(@class, ' topic/dl ')]">
  19. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]" mode="outofline"/>
  20. <fo:table xsl:use-attribute-sets="dl">
  21. <xsl:call-template name="commonattributes"/>
  22. <xsl:apply-templates select="*[contains(@class, ' topic/dlhead ')]"/>
  23. <fo:table-body xsl:use-attribute-sets="dl__body">
  24. <xsl:choose>
  25. <xsl:when test="contains(@otherprops,'sortable')">
  26. <xsl:apply-templates select="*[contains(@class, ' topic/dlentry ')]">
  27. <xsl:sort select="opentopic-func:getSortString(normalize-space( opentopic-func:fetchValueableText(*[contains(@class, ' topic/dt ')]) ))" lang="{$locale}"/>
  28. </xsl:apply-templates>
  29. </xsl:when>
  30. <xsl:otherwise>
  31. <xsl:apply-templates select="*[contains(@class, ' topic/dlentry ')]"/>
  32. </xsl:otherwise>
  33. </xsl:choose>
  34. </fo:table-body>
  35. </fo:table>
  36. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-endprop ')]" mode="outofline"/>
  37. </xsl:template>
  38. <xsl:template match="*[contains(@class, ' topic/dl ')]/*[contains(@class, ' topic/dlhead ')]">
  39. <fo:table-header xsl:use-attribute-sets="dl.dlhead">
  40. <xsl:call-template name="commonattributes"/>
  41. <fo:table-row xsl:use-attribute-sets="dl.dlhead__row">
  42. <xsl:apply-templates/>
  43. </fo:table-row>
  44. </fo:table-header>
  45. </xsl:template>
  46. <xsl:template match="*[contains(@class, ' topic/dlhead ')]/*[contains(@class, ' topic/dthd ')]">
  47. <fo:table-cell xsl:use-attribute-sets="dlhead.dthd__cell">
  48. <xsl:call-template name="commonattributes"/>
  49. <fo:block xsl:use-attribute-sets="dlhead.dthd__content">
  50. <xsl:apply-templates select="../*[contains(@class,' ditaot-d/ditaval-startprop ')]" mode="outofline"/>
  51. <xsl:apply-templates/>
  52. </fo:block>
  53. </fo:table-cell>
  54. </xsl:template>
  55. <xsl:template match="*[contains(@class, ' topic/dlhead ')]/*[contains(@class, ' topic/ddhd ')]">
  56. <fo:table-cell xsl:use-attribute-sets="dlhead.ddhd__cell">
  57. <xsl:call-template name="commonattributes"/>
  58. <fo:block xsl:use-attribute-sets="dlhead.ddhd__content">
  59. <xsl:apply-templates/>
  60. <xsl:apply-templates select="../*[contains(@class,' ditaot-d/ditaval-endprop ')]" mode="outofline"/>
  61. </fo:block>
  62. </fo:table-cell>
  63. </xsl:template>
  64. <xsl:template match="*[contains(@class, ' topic/dlentry ')]">
  65. <fo:table-row xsl:use-attribute-sets="dlentry">
  66. <xsl:call-template name="commonattributes"/>
  67. <fo:table-cell xsl:use-attribute-sets="dlentry.dt">
  68. <xsl:apply-templates select="*[contains(@class, ' topic/dt ')]"/>
  69. </fo:table-cell>
  70. <fo:table-cell xsl:use-attribute-sets="dlentry.dd">
  71. <xsl:apply-templates select="*[contains(@class, ' topic/dd ')]"/>
  72. </fo:table-cell>
  73. </fo:table-row>
  74. </xsl:template>
  75. <xsl:template match="*[contains(@class, ' topic/dt ')]">
  76. <fo:block xsl:use-attribute-sets="dlentry.dt__content">
  77. <xsl:call-template name="commonattributes"/>
  78. <xsl:if test="not(preceding-sibling::*[contains(@class,' topic/dt ')])">
  79. <xsl:apply-templates select="../*[contains(@class,' ditaot-d/ditaval-startprop ')]" mode="outofline"/>
  80. </xsl:if>
  81. <xsl:apply-templates/>
  82. </fo:block>
  83. </xsl:template>
  84. <xsl:template match="*[contains(@class, ' topic/dd ')]">
  85. <fo:block xsl:use-attribute-sets="dlentry.dd__content">
  86. <xsl:call-template name="commonattributes"/>
  87. <xsl:apply-templates/>
  88. <xsl:if test="not(following-sibling::*[contains(@class,' topic/dd ')])">
  89. <xsl:apply-templates select="../*[contains(@class,' ditaot-d/ditaval-endprop ')]" mode="outofline"/>
  90. </xsl:if>
  91. </fo:block>
  92. </xsl:template>
  93. <!-- Map processing -->
  94. <xsl:template match="*[contains(@class, ' map/map ')]/*[contains(@class, ' map/reltable ')]">
  95. <fo:table-and-caption>
  96. <fo:table-caption>
  97. <fo:block xsl:use-attribute-sets="reltable__title">
  98. <xsl:value-of select="@title"/>
  99. </fo:block>
  100. </fo:table-caption>
  101. <fo:table xsl:use-attribute-sets="reltable">
  102. <xsl:call-template name="topicrefAttsNoToc"/>
  103. <xsl:call-template name="selectAtts"/>
  104. <xsl:call-template name="globalAtts"/>
  105. <xsl:apply-templates select="relheader"/>
  106. <fo:table-body>
  107. <xsl:apply-templates select="relrow"/>
  108. </fo:table-body>
  109. </fo:table>
  110. </fo:table-and-caption>
  111. </xsl:template>
  112. <xsl:template match="*[contains(@class, ' map/relheader ')]">
  113. <fo:table-header xsl:use-attribute-sets="relheader">
  114. <xsl:call-template name="globalAtts"/>
  115. <xsl:apply-templates/>
  116. </fo:table-header>
  117. </xsl:template>
  118. <xsl:template match="*[contains(@class, ' map/relcolspec ')]">
  119. <fo:table-cell xsl:use-attribute-sets="relcolspec">
  120. <xsl:apply-templates/>
  121. </fo:table-cell>
  122. </xsl:template>
  123. <xsl:template match="*[contains(@class, ' map/relrow ')]">
  124. <fo:table-row xsl:use-attribute-sets="relrow">
  125. <xsl:call-template name="globalAtts"/>
  126. <xsl:apply-templates/>
  127. </fo:table-row>
  128. </xsl:template>
  129. <xsl:template match="*[contains(@class, ' map/relcell ')]">
  130. <fo:table-cell xsl:use-attribute-sets="relcell">
  131. <xsl:call-template name="globalAtts"/>
  132. <xsl:call-template name="topicrefAtts"/>
  133. <xsl:apply-templates/>
  134. </fo:table-cell>
  135. </xsl:template>
  136. <!-- DITA-OT flagging preprocess may add flag info directly into simpletable; account for that and
  137. skip to next row. Currently known to match ditaval-startprop when flagging used on simpletable
  138. as well as suitesol:changebar-start when revision bar used on sthead or stentry. -->
  139. <xsl:template match="*" mode="count-max-simpletable-cells" as="xs:integer">
  140. <xsl:param name="maxcount" select="0" as="xs:integer"/>
  141. <xsl:apply-templates select="following-sibling::*[1]" mode="count-max-simpletable-cells">
  142. <xsl:with-param name="maxcount" select="$maxcount"/>
  143. </xsl:apply-templates>
  144. </xsl:template>
  145. <!-- Count the max number of cells in any row of a simpletable -->
  146. <xsl:template match="*[contains(@class, ' topic/sthead ')] | *[contains(@class, ' topic/strow ')]" mode="count-max-simpletable-cells" as="xs:integer">
  147. <xsl:param name="maxcount" select="0" as="xs:integer"/>
  148. <xsl:variable name="newmaxcount" as="xs:integer">
  149. <xsl:variable name="row-cell-count" select="count(*[contains(@class, ' topic/stentry ')])" as="xs:integer"/>
  150. <xsl:sequence select="max(($row-cell-count, $maxcount))"/>
  151. </xsl:variable>
  152. <xsl:choose>
  153. <xsl:when test="not(following-sibling::*[contains(@class, ' topic/strow ')])">
  154. <xsl:sequence select="$newmaxcount"/>
  155. </xsl:when>
  156. <xsl:otherwise>
  157. <xsl:apply-templates select="following-sibling::*[contains(@class, ' topic/strow ')][1]" mode="count-max-simpletable-cells">
  158. <xsl:with-param name="maxcount" select="$newmaxcount"/>
  159. </xsl:apply-templates>
  160. </xsl:otherwise>
  161. </xsl:choose>
  162. </xsl:template>
  163. <!-- If there are more cells in any row than there are relcolwidth values,
  164. add 1* for each missing cell, otherwise the FO processor may crash. -->
  165. <xsl:template match="*" mode="fix-relcolwidth">
  166. <xsl:param name="number-cells" as="xs:integer"/>
  167. <xsl:variable name="relcolwidth-tokens" select="tokenize(normalize-space(@relcolwidth), '\s+')" as="xs:string*"/>
  168. <xsl:variable name="number-relwidths" select="count($relcolwidth-tokens)" as="xs:integer"/>
  169. <xsl:variable name="result" as="xs:string*">
  170. <xsl:sequence select="$relcolwidth-tokens"/>
  171. <xsl:for-each select="1 to ($number-cells - $number-relwidths)">1*</xsl:for-each>
  172. </xsl:variable>
  173. <xsl:value-of select="$result" separator=" "/>
  174. </xsl:template>
  175. <xsl:function name="dita-ot:get-length">
  176. <xsl:param name="width" as="xs:string"/>
  177. <xsl:value-of select="normalize-space(translate($width,
  178. '+-0123456789.abcdefghijklmnopqrstuvwxyz%',
  179. '+-0123456789.'))"/>
  180. </xsl:function>
  181. <xsl:function name="dita-ot:get-unit">
  182. <xsl:param name="width" as="xs:string"/>
  183. <xsl:value-of select="normalize-space(translate($width,
  184. 'abcdefghijklmnopqrstuvwxyz%+-0123456789.',
  185. 'abcdefghijklmnopqrstuvwxyz%'))"/>
  186. </xsl:function>
  187. <xsl:template name="univAttrs">
  188. <xsl:apply-templates select="@platform | @product | @audience | @otherprops | @importance | @rev | @status"/>
  189. </xsl:template>
  190. <xsl:function name="opentopic-func:getSortString" as="xs:string">
  191. <xsl:param name="text" as="xs:string"/>
  192. <xsl:choose>
  193. <xsl:when test="contains($text, '[') and contains($text, ']')">
  194. <xsl:value-of select="substring-before(substring-after($text, '['),']')"/>
  195. </xsl:when>
  196. <xsl:otherwise>
  197. <xsl:value-of select="$text"/>
  198. </xsl:otherwise>
  199. </xsl:choose>
  200. </xsl:function>
  201. <xsl:function name="opentopic-func:fetchValueableText" as="xs:string">
  202. <xsl:param name="node" as="element()*"/>
  203. <xsl:value-of>
  204. <xsl:apply-templates select="$node" mode="insert-text"/>
  205. </xsl:value-of>
  206. </xsl:function>
  207. <xsl:template match="*" mode="insert-text">
  208. <xsl:apply-templates mode="insert-text"/>
  209. </xsl:template>
  210. <xsl:template match="*[contains(@class, ' topic/indexterm ')]" mode="insert-text"/>
  211. <xsl:template match="text()[contains(., '[') and contains(., ']')][ancestor::*[contains(@class, ' topic/dl ')][contains(@otherprops,'sortable')]]" priority="10">
  212. <xsl:value-of select="substring-before(.,'[')"/>
  213. </xsl:template>
  214. <xsl:template match="*[contains(@class, ' topic/table ')]">
  215. <!-- FIXME, empty value -->
  216. <xsl:variable name="scale" as="xs:string?">
  217. <xsl:call-template name="getTableScale"/>
  218. </xsl:variable>
  219. <fo:block-container xsl:use-attribute-sets="table__container">
  220. <fo:block xsl:use-attribute-sets="table">
  221. <xsl:call-template name="commonattributes"/>
  222. <xsl:if test="not(@id)">
  223. <xsl:attribute name="id">
  224. <xsl:call-template name="get-id"/>
  225. </xsl:attribute>
  226. </xsl:if>
  227. <xsl:if test="exists($scale)">
  228. <xsl:attribute name="font-size" select="concat($scale, '%')"/>
  229. </xsl:if>
  230. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]" mode="outofline"/>
  231. <xsl:apply-templates/>
  232. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-endprop ')]" mode="outofline"/>
  233. </fo:block>
  234. </fo:block-container>
  235. </xsl:template>
  236. <xsl:template match="*[contains(@class, ' topic/table ')]/*[contains(@class, ' topic/title ')]">
  237. <fo:block xsl:use-attribute-sets="table.title">
  238. <xsl:call-template name="commonattributes"/>
  239. <xsl:call-template name="getVariable">
  240. <xsl:with-param name="id" select="'Table.title'"/>
  241. <xsl:with-param name="params">
  242. <number>
  243. <xsl:apply-templates select="." mode="table.title-number"/>
  244. </number>
  245. <title>
  246. <xsl:apply-templates/>
  247. </title>
  248. </xsl:with-param>
  249. </xsl:call-template>
  250. </fo:block>
  251. </xsl:template>
  252. <xsl:template match="*[contains(@class, ' topic/table ')]/*[contains(@class, ' topic/title ')]" mode="table.title-number">
  253. <xsl:value-of select="count(key('enumerableByClass', 'topic/table')[. &lt;&lt; current()])"/>
  254. </xsl:template>
  255. <xsl:template match="*[contains(@class, ' topic/tgroup ')]" name="tgroup">
  256. <xsl:if test="not(@cols)">
  257. <xsl:call-template name="output-message">
  258. <xsl:with-param name="id" select="'PDFX006E'"/>
  259. </xsl:call-template>
  260. </xsl:if>
  261. <xsl:variable name="scale" as="xs:string?">
  262. <xsl:call-template name="getTableScale"/>
  263. </xsl:variable>
  264. <xsl:variable name="table" as="element()">
  265. <fo:table xsl:use-attribute-sets="table.tgroup">
  266. <xsl:call-template name="commonattributes"/>
  267. <xsl:call-template name="displayAtts">
  268. <xsl:with-param name="element" select=".."/>
  269. </xsl:call-template>
  270. <xsl:if test="(parent::*/@pgwide) = '1'">
  271. <xsl:attribute name="start-indent">0</xsl:attribute>
  272. <xsl:attribute name="end-indent">0</xsl:attribute>
  273. <xsl:attribute name="width">auto</xsl:attribute>
  274. </xsl:if>
  275. <xsl:apply-templates/>
  276. </fo:table>
  277. </xsl:variable>
  278. <xsl:choose>
  279. <xsl:when test="exists($scale)">
  280. <xsl:apply-templates select="$table" mode="setTableEntriesScale"/>
  281. </xsl:when>
  282. <xsl:otherwise>
  283. <xsl:copy-of select="$table"/>
  284. </xsl:otherwise>
  285. </xsl:choose>
  286. </xsl:template>
  287. <xsl:template match="*[contains(@class, ' topic/tgroup ')][empty(*[contains(@class, ' topic/tbody ')]//*[contains(@class, ' topic/row ')])]" priority="10"/>
  288. <xsl:template match="*[contains(@class, ' topic/colspec ')]">
  289. <fo:table-column>
  290. <xsl:attribute name="column-number" select="@colnum"/>
  291. <xsl:if test="normalize-space(@colwidth)">
  292. <xsl:attribute name="column-width">
  293. <xsl:choose>
  294. <xsl:when test="not(normalize-space(@colwidth))">
  295. <xsl:call-template name="calculateColumnWidth.Proportional">
  296. <xsl:with-param name="colwidth" select="'1*'"/>
  297. </xsl:call-template>
  298. </xsl:when>
  299. <xsl:when test="contains(@colwidth, '*')">
  300. <xsl:call-template name="calculateColumnWidth.Proportional">
  301. <xsl:with-param name="colwidth" select="@colwidth"/>
  302. </xsl:call-template>
  303. </xsl:when>
  304. <xsl:otherwise>
  305. <xsl:call-template name="calculateColumnWidth.nonProportional">
  306. <xsl:with-param name="colwidth" select="@colwidth"/>
  307. </xsl:call-template>
  308. </xsl:otherwise>
  309. </xsl:choose>
  310. </xsl:attribute>
  311. </xsl:if>
  312. <xsl:call-template name="applyAlignAttrs"/>
  313. </fo:table-column>
  314. </xsl:template>
  315. <xsl:template match="*[contains(@class, ' topic/thead ')]">
  316. <fo:table-header xsl:use-attribute-sets="tgroup.thead">
  317. <xsl:call-template name="commonattributes"/>
  318. <xsl:apply-templates/>
  319. </fo:table-header>
  320. </xsl:template>
  321. <xsl:template match="*[contains(@class, ' topic/tbody ')]">
  322. <fo:table-body xsl:use-attribute-sets="tgroup.tbody">
  323. <xsl:call-template name="commonattributes"/>
  324. <xsl:apply-templates/>
  325. </fo:table-body>
  326. </xsl:template>
  327. <xsl:template match="*[contains(@class, ' topic/thead ')]/*[contains(@class, ' topic/row ')]">
  328. <fo:table-row xsl:use-attribute-sets="thead.row">
  329. <xsl:call-template name="commonattributes"/>
  330. <xsl:apply-templates/>
  331. </fo:table-row>
  332. </xsl:template>
  333. <xsl:template match="*[contains(@class, ' topic/tbody ')]/*[contains(@class, ' topic/row ')]">
  334. <fo:table-row xsl:use-attribute-sets="tbody.row">
  335. <xsl:call-template name="commonattributes"/>
  336. <xsl:apply-templates/>
  337. </fo:table-row>
  338. </xsl:template>
  339. <xsl:template match="*[contains(@class, ' topic/thead ')]/*[contains(@class, ' topic/row ')]/*[contains(@class, ' topic/entry ')]">
  340. <fo:table-cell xsl:use-attribute-sets="thead.row.entry">
  341. <xsl:call-template name="commonattributes"/>
  342. <xsl:call-template name="applySpansAttrs"/>
  343. <xsl:call-template name="applyAlignAttrs"/>
  344. <xsl:call-template name="generateTableEntryBorder"/>
  345. <fo:block xsl:use-attribute-sets="thead.row.entry__content">
  346. <xsl:apply-templates select="." mode="ancestor-start-flag"/>
  347. <xsl:call-template name="processEntryContent"/>
  348. <xsl:apply-templates select="." mode="ancestor-end-flag"/>
  349. </fo:block>
  350. </fo:table-cell>
  351. </xsl:template>
  352. <xsl:template match="*[contains(@class, ' topic/tbody ')]/*[contains(@class, ' topic/row ')]/*[contains(@class, ' topic/entry ')]">
  353. <xsl:choose>
  354. <xsl:when test="ancestor::*[contains(@class, ' topic/table ')][1]/@rowheader = 'firstcol'
  355. and empty(preceding-sibling::*[contains(@class, ' topic/entry ')])">
  356. <fo:table-cell xsl:use-attribute-sets="tbody.row.entry__firstcol">
  357. <xsl:apply-templates select="." mode="processTableEntry"/>
  358. </fo:table-cell>
  359. </xsl:when>
  360. <xsl:otherwise>
  361. <fo:table-cell xsl:use-attribute-sets="tbody.row.entry">
  362. <xsl:apply-templates select="." mode="processTableEntry"/>
  363. </fo:table-cell>
  364. </xsl:otherwise>
  365. </xsl:choose>
  366. </xsl:template>
  367. <xsl:template match="*" mode="processTableEntry">
  368. <xsl:call-template name="commonattributes"/>
  369. <xsl:call-template name="applySpansAttrs"/>
  370. <xsl:call-template name="applyAlignAttrs"/>
  371. <xsl:call-template name="generateTableEntryBorder"/>
  372. <fo:block xsl:use-attribute-sets="tbody.row.entry__content">
  373. <xsl:apply-templates select="." mode="ancestor-start-flag"/>
  374. <xsl:call-template name="processEntryContent"/>
  375. <xsl:apply-templates select="." mode="ancestor-end-flag"/>
  376. </fo:block>
  377. </xsl:template>
  378. <xsl:template name="processEntryContent">
  379. <xsl:variable name="entryNumber" select="@dita-ot:x" as="xs:integer"/>
  380. <xsl:variable name="colspec" select="ancestor::*[contains(@class, ' topic/tgroup ')][1]/*[contains(@class, ' topic/colspec ')][position() = $entryNumber]"/>
  381. <xsl:variable name="char" as="xs:string?">
  382. <xsl:choose>
  383. <xsl:when test="@char">
  384. <xsl:value-of select="@char"/>
  385. </xsl:when>
  386. <xsl:when test="$colspec/@char">
  387. <xsl:value-of select="$colspec/@char"/>
  388. </xsl:when>
  389. </xsl:choose>
  390. </xsl:variable>
  391. <xsl:variable name="charoff" as="xs:integer">
  392. <xsl:choose>
  393. <xsl:when test="@charoff">
  394. <xsl:sequence select="xs:integer(@charoff)"/>
  395. </xsl:when>
  396. <xsl:when test="$colspec/@charoff">
  397. <xsl:sequence select="xs:integer($colspec/@charoff)"/>
  398. </xsl:when>
  399. <xsl:otherwise>
  400. <xsl:sequence select="xs:integer(50)"/>
  401. </xsl:otherwise>
  402. </xsl:choose>
  403. </xsl:variable>
  404. <xsl:choose>
  405. <xsl:when test="exists($char) and string-length($char) ne 0">
  406. <xsl:call-template name="processCharAlignment">
  407. <xsl:with-param name="char" select="$char"/>
  408. <xsl:with-param name="charoff" select="$charoff"/>
  409. </xsl:call-template>
  410. </xsl:when>
  411. <xsl:otherwise>
  412. <xsl:apply-templates/>
  413. </xsl:otherwise>
  414. </xsl:choose>
  415. </xsl:template>
  416. <xsl:template name="processCharAlignment">
  417. <xsl:param name="char" as="xs:string"/>
  418. <xsl:param name="charoff" as="xs:integer"/>
  419. <xsl:choose>
  420. <xsl:when test="not(descendant::*)">
  421. <xsl:variable name="text-before" select="substring-before(text(), $char)"/>
  422. <xsl:variable name="text-after" select="substring-after(text(), $text-before)"/>
  423. <fo:list-block start-indent="0pt"
  424. provisional-label-separation="0pt"
  425. provisional-distance-between-starts="{concat($charoff, '%')}">
  426. <fo:list-item>
  427. <fo:list-item-label end-indent="label-end()">
  428. <fo:block text-align="right">
  429. <xsl:copy-of select="$text-before"/>
  430. </fo:block>
  431. </fo:list-item-label>
  432. <fo:list-item-body start-indent="body-start()">
  433. <fo:block text-align="left">
  434. <xsl:copy-of select="$text-after"/>
  435. </fo:block>
  436. </fo:list-item-body>
  437. </fo:list-item>
  438. </fo:list-block>
  439. </xsl:when>
  440. </xsl:choose>
  441. </xsl:template>
  442. <xsl:template name="calculateColumnWidth.Proportional">
  443. <xsl:param name="colwidth" as="xs:string"/>
  444. <xsl:text>proportional-column-width(</xsl:text>
  445. <xsl:choose>
  446. <xsl:when test="substring-before($colwidth, '*') != ''">
  447. <xsl:value-of select="normalize-space(substring-before($colwidth, '*'))"/>
  448. </xsl:when>
  449. <xsl:otherwise>
  450. <xsl:text>1.00</xsl:text>
  451. </xsl:otherwise>
  452. </xsl:choose>
  453. <xsl:text>)</xsl:text>
  454. </xsl:template>
  455. <xsl:template name="calculateColumnWidth.nonProportional">
  456. <xsl:param name="colwidth" as="xs:string"/>
  457. <xsl:variable name="width-units" as="xs:string">
  458. <xsl:choose>
  459. <!-- XXX: This should never occur -->
  460. <xsl:when test="contains($colwidth, '*')">
  461. <xsl:value-of select="normalize-space(substring-after($colwidth, '*'))"/>
  462. </xsl:when>
  463. <xsl:otherwise>
  464. <xsl:value-of select="normalize-space($colwidth)"/>
  465. </xsl:otherwise>
  466. </xsl:choose>
  467. </xsl:variable>
  468. <xsl:variable name="width" select="dita-ot:get-length($width-units)"/>
  469. <xsl:variable name="units" select="dita-ot:get-unit($width-units)"/>
  470. <xsl:value-of select="$width"/>
  471. <xsl:choose>
  472. <xsl:when test="$units = 'pi'">pc</xsl:when>
  473. <xsl:when test="$units = '' and $width != ''">pt</xsl:when>
  474. <xsl:otherwise>
  475. <xsl:value-of select="$units"/>
  476. </xsl:otherwise>
  477. </xsl:choose>
  478. </xsl:template>
  479. <xsl:template name="applySpansAttrs">
  480. <xsl:if test="exists(@morerows) and xs:integer(@morerows) gt 0">
  481. <xsl:attribute name="number-rows-spanned">
  482. <xsl:value-of select="xs:integer(@morerows) + 1"/>
  483. </xsl:attribute>
  484. </xsl:if>
  485. <xsl:if test="exists(@dita-ot:morecols) and xs:integer(@dita-ot:morecols) gt 0">
  486. <xsl:attribute name="number-columns-spanned">
  487. <xsl:value-of select="xs:integer(@dita-ot:morecols) + 1"/>
  488. </xsl:attribute>
  489. </xsl:if>
  490. </xsl:template>
  491. <xsl:template name="applyAlignAttrs">
  492. <xsl:variable name="align" as="xs:string?">
  493. <xsl:choose>
  494. <xsl:when test="@align">
  495. <xsl:value-of select="@align"/>
  496. </xsl:when>
  497. <xsl:when test="ancestor::*[contains(@class, ' topic/tbody ')][1][@align]">
  498. <xsl:value-of select="ancestor::*[contains(@class, ' topic/tbody ')][1]/@align"/>
  499. </xsl:when>
  500. <xsl:when test="ancestor::*[contains(@class, ' topic/thead ')][1][@align]">
  501. <xsl:value-of select="ancestor::*[contains(@class, ' topic/thead ')][1]/@align"/>
  502. </xsl:when>
  503. <xsl:when test="ancestor::*[contains(@class, ' topic/tgroup ')][1][@align]">
  504. <xsl:value-of select="ancestor::*[contains(@class, ' topic/tgroup ')][1]/@align"/>
  505. </xsl:when>
  506. </xsl:choose>
  507. </xsl:variable>
  508. <xsl:variable name="valign" as="xs:string?">
  509. <xsl:choose>
  510. <xsl:when test="@valign">
  511. <xsl:value-of select="@valign"/>
  512. </xsl:when>
  513. <xsl:when test="parent::*[contains(@class, ' topic/row ')][@valign]">
  514. <xsl:value-of select="parent::*[contains(@class, ' topic/row ')]/@valign"/>
  515. </xsl:when>
  516. </xsl:choose>
  517. </xsl:variable>
  518. <xsl:choose>
  519. <xsl:when test="not(normalize-space($align) = '')">
  520. <xsl:attribute name="text-align">
  521. <xsl:value-of select="$align"/>
  522. </xsl:attribute>
  523. </xsl:when>
  524. <xsl:when test="(normalize-space($align) = '') and contains(@class, ' topic/colspec ')"/>
  525. <xsl:otherwise>
  526. <xsl:attribute name="text-align">from-table-column()</xsl:attribute>
  527. </xsl:otherwise>
  528. </xsl:choose>
  529. <xsl:choose>
  530. <xsl:when test="$valign='top'">
  531. <xsl:attribute name="display-align">
  532. <xsl:value-of select="'before'"/>
  533. </xsl:attribute>
  534. </xsl:when>
  535. <xsl:when test="$valign='middle'">
  536. <xsl:attribute name="display-align">
  537. <xsl:value-of select="'center'"/>
  538. </xsl:attribute>
  539. </xsl:when>
  540. <xsl:when test="$valign='bottom'">
  541. <xsl:attribute name="display-align">
  542. <xsl:value-of select="'after'"/>
  543. </xsl:attribute>
  544. </xsl:when>
  545. </xsl:choose>
  546. </xsl:template>
  547. <xsl:template name="generateTableEntryBorder">
  548. <xsl:variable name="colsep" as="xs:string">
  549. <xsl:call-template name="getTableColsep"/>
  550. </xsl:variable>
  551. <xsl:variable name="rowsep" as="xs:string">
  552. <xsl:call-template name="getTableRowsep"/>
  553. </xsl:variable>
  554. <xsl:variable name="frame" as="xs:string">
  555. <xsl:variable name="f" select="ancestor::*[contains(@class, ' topic/table ')][1]/@frame"/>
  556. <xsl:choose>
  557. <xsl:when test="$f">
  558. <xsl:value-of select="$f"/>
  559. </xsl:when>
  560. <xsl:otherwise>
  561. <xsl:value-of select="$table.frame-default"/>
  562. </xsl:otherwise>
  563. </xsl:choose>
  564. </xsl:variable>
  565. <xsl:variable name="needTopBorderOnBreak" as="xs:boolean">
  566. <xsl:choose>
  567. <xsl:when test="$frame = 'all' or $frame = 'topbot' or $frame = 'top'">
  568. <xsl:choose>
  569. <xsl:when test="../parent::node()[contains(@class, ' topic/thead ')]">
  570. <xsl:sequence select="true()"/>
  571. </xsl:when>
  572. <xsl:when test="(../parent::node()[contains(@class, ' topic/tbody ')]) and not(../preceding-sibling::*[contains(@class, ' topic/row ')])">
  573. <xsl:sequence select="true()"/>
  574. </xsl:when>
  575. <xsl:when test="../parent::node()[contains(@class, ' topic/tbody ')]">
  576. <xsl:variable name="entryNum" select="count(preceding-sibling::*[contains(@class, ' topic/entry ')]) + 1"/>
  577. <xsl:variable name="prevEntryRowsep" as="xs:string?">
  578. <xsl:for-each select="../preceding-sibling::*[contains(@class, ' topic/row ')][1]/*[contains(@class, ' topic/entry ')][$entryNum]">
  579. <xsl:call-template name="getTableRowsep"/>
  580. </xsl:for-each>
  581. </xsl:variable>
  582. <xsl:choose>
  583. <xsl:when test="$prevEntryRowsep != '0'">
  584. <xsl:sequence select="true()"/>
  585. </xsl:when>
  586. <xsl:otherwise>
  587. <xsl:sequence select="false()"/>
  588. </xsl:otherwise>
  589. </xsl:choose>
  590. </xsl:when>
  591. <xsl:otherwise>
  592. <xsl:sequence select="false()"/>
  593. </xsl:otherwise>
  594. </xsl:choose>
  595. </xsl:when>
  596. <xsl:otherwise>
  597. <xsl:sequence select="false()"/>
  598. </xsl:otherwise>
  599. </xsl:choose>
  600. </xsl:variable>
  601. <xsl:if test="number($rowsep) = 1 and (../parent::node()[contains(@class, ' topic/thead ')])">
  602. <xsl:call-template name="processAttrSetReflection">
  603. <xsl:with-param name="attrSet" select="'thead__tableframe__bottom'"/>
  604. <xsl:with-param name="path" select="$tableAttrs"/>
  605. </xsl:call-template>
  606. </xsl:if>
  607. <xsl:if test="number($rowsep) = 1 and ((../following-sibling::*[contains(@class, ' topic/row ')]) or (../parent::node()[contains(@class, ' topic/tbody ')] and ancestor::*[contains(@class, ' topic/tgroup ')][1]/*[contains(@class, ' topic/tfoot ')]))">
  608. <xsl:call-template name="processAttrSetReflection">
  609. <xsl:with-param name="attrSet" select="'__tableframe__bottom'"/>
  610. <xsl:with-param name="path" select="$tableAttrs"/>
  611. </xsl:call-template>
  612. </xsl:if>
  613. <xsl:if test="$needTopBorderOnBreak">
  614. <xsl:call-template name="processAttrSetReflection">
  615. <xsl:with-param name="attrSet" select="'__tableframe__top'"/>
  616. <xsl:with-param name="path" select="$tableAttrs"/>
  617. </xsl:call-template>
  618. </xsl:if>
  619. <xsl:if test="number($colsep) = 1 and following-sibling::*[contains(@class, ' topic/entry ')]">
  620. <xsl:call-template name="processAttrSetReflection">
  621. <xsl:with-param name="attrSet" select="'__tableframe__right'"/>
  622. <xsl:with-param name="path" select="$tableAttrs"/>
  623. </xsl:call-template>
  624. </xsl:if>
  625. <xsl:if test="number($colsep) = 1 and not(following-sibling::*[contains(@class, ' topic/entry ')]) and ((count(preceding-sibling::*) + 1) &lt; ancestor::*[contains(@class, ' topic/tgroup ')][1]/@cols)">
  626. <xsl:call-template name="processAttrSetReflection">
  627. <xsl:with-param name="attrSet" select="'__tableframe__right'"/>
  628. <xsl:with-param name="path" select="$tableAttrs"/>
  629. </xsl:call-template>
  630. </xsl:if>
  631. </xsl:template>
  632. <!-- DITA spec prose defines as either 0 or 1, but DTD as NMTOKENS. However, OASIS Table Exchange model uses 0 or anything else. -->
  633. <xsl:template name="getTableColsep" as="xs:string">
  634. <xsl:variable name="colname" select="@colname"/>
  635. <xsl:choose>
  636. <xsl:when test="@colsep">
  637. <xsl:value-of select="@colsep"/>
  638. </xsl:when>
  639. <xsl:when test="ancestor::*[contains(@class, ' topic/tgroup ')][1]/*[contains(@class, ' topic/colspec ')][@colname = $colname]/@colsep">
  640. <xsl:value-of select="ancestor::*[contains(@class, ' topic/tgroup ')][1]/*[contains(@class, ' topic/colspec ')][@colname = $colname]/@colsep"/>
  641. </xsl:when>
  642. <xsl:when test="ancestor::*[contains(@class, ' topic/tgroup ')][1]/@colsep">
  643. <xsl:value-of select="ancestor::*[contains(@class, ' topic/tgroup ')][1]/@colsep"/>
  644. </xsl:when>
  645. <xsl:when test="ancestor::*[contains(@class, ' topic/table ')][1]/@colsep">
  646. <xsl:value-of select="ancestor::*[contains(@class, ' topic/table ')][1]/@colsep"/>
  647. </xsl:when>
  648. <xsl:otherwise>
  649. <xsl:value-of select="$table.colsep-default"/>
  650. </xsl:otherwise>
  651. </xsl:choose>
  652. </xsl:template>
  653. <xsl:template name="getTableRowsep" as="xs:string">
  654. <xsl:variable name="colname" select="@colname"/>
  655. <xsl:choose>
  656. <xsl:when test="@rowsep">
  657. <xsl:value-of select="@rowsep"/>
  658. </xsl:when>
  659. <xsl:when test="ancestor::*[contains(@class, ' topic/row ')][1]/@rowsep">
  660. <xsl:value-of select="ancestor::*[contains(@class, ' topic/row ')][1]/@rowsep"/>
  661. </xsl:when>
  662. <xsl:when test="ancestor::*[contains(@class, ' topic/tgroup ')][1]/*[contains(@class, ' topic/colspec ')][@colname = $colname]/@rowsep">
  663. <xsl:value-of select="ancestor::*[contains(@class, ' topic/tgroup ')][1]/*[contains(@class, ' topic/colspec ')][@colname = $colname]/@rowsep"/>
  664. </xsl:when>
  665. <xsl:when test="ancestor::*[contains(@class, ' topic/tgroup ')][1]/@rowsep">
  666. <xsl:value-of select="ancestor::*[contains(@class, ' topic/tgroup ')][1]/@rowsep"/>
  667. </xsl:when>
  668. <xsl:when test="ancestor::*[contains(@class, ' topic/table ')][1]/@rowsep">
  669. <xsl:value-of select="ancestor::*[contains(@class, ' topic/table ')][1]/@rowsep"/>
  670. </xsl:when>
  671. <xsl:otherwise>
  672. <xsl:value-of select="$table.rowsep-default"/>
  673. </xsl:otherwise>
  674. </xsl:choose>
  675. </xsl:template>
  676. <xsl:template name="displayAtts">
  677. <xsl:param name="element" as="element()"/>
  678. <xsl:variable name="frame" as="xs:string">
  679. <xsl:choose>
  680. <xsl:when test="$element/@frame">
  681. <xsl:value-of select="$element/@frame"/>
  682. </xsl:when>
  683. <xsl:otherwise>
  684. <xsl:value-of select="$table.frame-default"/>
  685. </xsl:otherwise>
  686. </xsl:choose>
  687. </xsl:variable>
  688. <xsl:if test="$element/@expanse">
  689. <xsl:for-each select="$element">
  690. <xsl:call-template name="setExpanse"/>
  691. </xsl:for-each>
  692. </xsl:if>
  693. <xsl:choose>
  694. <xsl:when test="$frame = 'all'">
  695. <xsl:call-template name="processAttrSetReflection">
  696. <xsl:with-param name="attrSet" select="'table__tableframe__all'"/>
  697. <xsl:with-param name="path" select="$tableAttrs"/>
  698. </xsl:call-template>
  699. </xsl:when>
  700. <xsl:when test="$frame = 'topbot'">
  701. <xsl:call-template name="processAttrSetReflection">
  702. <xsl:with-param name="attrSet" select="'table__tableframe__topbot'"/>
  703. <xsl:with-param name="path" select="$tableAttrs"/>
  704. </xsl:call-template>
  705. </xsl:when>
  706. <xsl:when test="$frame = 'top'">
  707. <xsl:call-template name="processAttrSetReflection">
  708. <xsl:with-param name="attrSet" select="'table__tableframe__top'"/>
  709. <xsl:with-param name="path" select="$tableAttrs"/>
  710. </xsl:call-template>
  711. </xsl:when>
  712. <xsl:when test="$frame = 'bottom'">
  713. <xsl:call-template name="processAttrSetReflection">
  714. <xsl:with-param name="attrSet" select="'table__tableframe__bottom'"/>
  715. <xsl:with-param name="path" select="$tableAttrs"/>
  716. </xsl:call-template>
  717. </xsl:when>
  718. <xsl:when test="$frame = 'sides'">
  719. <xsl:call-template name="processAttrSetReflection">
  720. <xsl:with-param name="attrSet" select="'table__tableframe__sides'"/>
  721. <xsl:with-param name="path" select="$tableAttrs"/>
  722. </xsl:call-template>
  723. </xsl:when>
  724. </xsl:choose>
  725. </xsl:template>
  726. <xsl:template name="getTableScale" as="xs:string?">
  727. <xsl:sequence select="ancestor-or-self::*[contains(@class, ' topic/table ')][1]/@scale"/>
  728. </xsl:template>
  729. <xsl:template match="@*" mode="setTableEntriesScale">
  730. <xsl:choose>
  731. <xsl:when test="name() = 'font-size'">
  732. </xsl:when>
  733. <xsl:otherwise>
  734. <xsl:copy-of select="."/>
  735. </xsl:otherwise>
  736. </xsl:choose>
  737. </xsl:template>
  738. <xsl:template match="node() | text()" mode="setTableEntriesScale">
  739. <xsl:copy>
  740. <xsl:apply-templates select="node() | @* | text()" mode="setTableEntriesScale"/>
  741. </xsl:copy>
  742. </xsl:template>
  743. <!-- Simpletable processing -->
  744. <xsl:template match="*[contains(@class, ' topic/simpletable ')]">
  745. <xsl:variable name="number-cells" as="xs:integer">
  746. <!-- Contains the number of cells in the widest row -->
  747. <xsl:apply-templates select="*[1]" mode="count-max-simpletable-cells"/>
  748. </xsl:variable>
  749. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]" mode="outofline"/>
  750. <fo:table xsl:use-attribute-sets="simpletable">
  751. <xsl:call-template name="commonattributes"/>
  752. <xsl:call-template name="globalAtts"/>
  753. <xsl:call-template name="displayAtts">
  754. <xsl:with-param name="element" select="."/>
  755. </xsl:call-template>
  756. <xsl:if test="@relcolwidth">
  757. <xsl:variable name="fix-relcolwidth" as="xs:string">
  758. <xsl:apply-templates select="." mode="fix-relcolwidth">
  759. <xsl:with-param name="number-cells" select="$number-cells"/>
  760. </xsl:apply-templates>
  761. </xsl:variable>
  762. <xsl:call-template name="createSimpleTableColumns">
  763. <xsl:with-param name="theColumnWidthes" select="$fix-relcolwidth"/>
  764. </xsl:call-template>
  765. </xsl:if>
  766. <!-- Toss processing to another template to process the simpletable
  767. heading, and/or create a default table heading row. -->
  768. <xsl:apply-templates select="." mode="dita2xslfo:simpletable-heading">
  769. <xsl:with-param name="number-cells" select="$number-cells"/>
  770. </xsl:apply-templates>
  771. <fo:table-body xsl:use-attribute-sets="simpletable__body">
  772. <xsl:choose>
  773. <xsl:when test="empty(*[contains(@class, ' topic/strow ')])">
  774. <fo:table-row>
  775. <fo:table-cell>
  776. <fo:block/>
  777. </fo:table-cell>
  778. </fo:table-row>
  779. </xsl:when>
  780. <xsl:otherwise>
  781. <xsl:apply-templates select="*[contains(@class, ' topic/strow ')]">
  782. <xsl:with-param name="number-cells" select="$number-cells"/>
  783. </xsl:apply-templates>
  784. </xsl:otherwise>
  785. </xsl:choose>
  786. </fo:table-body>
  787. </fo:table>
  788. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-endprop ')]" mode="outofline"/>
  789. </xsl:template>
  790. <xsl:template match="*[contains(@class, ' topic/simpletable ')][empty(*)]" priority="10"/>
  791. <xsl:template name="createSimpleTableColumns">
  792. <xsl:param name="theColumnWidthes" as="xs:string"/>
  793. <xsl:for-each select="tokenize(normalize-space($theColumnWidthes), '\s+')">
  794. <fo:table-column>
  795. <xsl:attribute name="column-width">
  796. <xsl:call-template name="calculateColumnWidth.Proportional">
  797. <xsl:with-param name="colwidth" select="."/>
  798. </xsl:call-template>
  799. </xsl:attribute>
  800. </fo:table-column>
  801. </xsl:for-each>
  802. </xsl:template>
  803. <!-- Fill in empty cells when one is missing from strow or sthead.
  804. Context for this call is strow or sthead. -->
  805. <xsl:template match="*" mode="fillInMissingSimpletableCells">
  806. <xsl:param name="fill-in-count" select="0" as="xs:integer"/>
  807. <xsl:variable name="current" select="."/>
  808. <xsl:for-each select="1 to $fill-in-count">
  809. <xsl:for-each select="$current">
  810. <fo:table-cell xsl:use-attribute-sets="strow.stentry">
  811. <xsl:call-template name="commonattributes"/>
  812. <xsl:variable name="frame" as="xs:string">
  813. <xsl:choose>
  814. <xsl:when test="../@frame">
  815. <xsl:value-of select="../@frame"/>
  816. </xsl:when>
  817. <xsl:otherwise>
  818. <xsl:value-of select="$table.frame-default"/>
  819. </xsl:otherwise>
  820. </xsl:choose>
  821. </xsl:variable>
  822. <xsl:if test="following-sibling::*[contains(@class, ' topic/strow ')]">
  823. <xsl:call-template name="generateSimpleTableHorizontalBorders">
  824. <xsl:with-param name="frame" select="$frame"/>
  825. </xsl:call-template>
  826. </xsl:if>
  827. <xsl:if test="$frame = 'all' or $frame = 'topbot' or $frame = 'top'">
  828. <xsl:call-template name="processAttrSetReflection">
  829. <xsl:with-param name="attrSet" select="'__tableframe__top'"/>
  830. <xsl:with-param name="path" select="$tableAttrs"/>
  831. </xsl:call-template>
  832. </xsl:if>
  833. <xsl:if test="($frame = 'all') or ($frame = 'topbot') or ($frame = 'sides')">
  834. <xsl:call-template name="processAttrSetReflection">
  835. <xsl:with-param name="attrSet" select="'__tableframe__left'"/>
  836. <xsl:with-param name="path" select="$tableAttrs"/>
  837. </xsl:call-template>
  838. <xsl:call-template name="processAttrSetReflection">
  839. <xsl:with-param name="attrSet" select="'__tableframe__right'"/>
  840. <xsl:with-param name="path" select="$tableAttrs"/>
  841. </xsl:call-template>
  842. </xsl:if>
  843. <fo:block>
  844. <fo:inline>&#160;</fo:inline>
  845. </fo:block>
  846. </fo:table-cell>
  847. </xsl:for-each>
  848. </xsl:for-each>
  849. </xsl:template>
  850. <!-- Specialized simpletable elements may override this rule to add
  851. default headings for the table. By default, the existing sthead
  852. element is used when specified. -->
  853. <xsl:template match="*[contains(@class, ' topic/simpletable ')]" mode="dita2xslfo:simpletable-heading">
  854. <xsl:param name="number-cells" as="xs:integer">
  855. <xsl:apply-templates select="*[1]" mode="count-max-simpletable-cells"/>
  856. </xsl:param>
  857. <xsl:apply-templates select="*[contains(@class, ' topic/sthead ')]">
  858. <xsl:with-param name="number-cells" select="$number-cells"/>
  859. </xsl:apply-templates>
  860. </xsl:template>
  861. <xsl:template match="*[contains(@class, ' topic/sthead ')]">
  862. <xsl:param name="number-cells" as="xs:integer">
  863. <xsl:apply-templates select="../*[1]" mode="count-max-simpletable-cells"/>
  864. </xsl:param>
  865. <fo:table-header xsl:use-attribute-sets="sthead">
  866. <xsl:call-template name="commonattributes"/>
  867. <fo:table-row xsl:use-attribute-sets="sthead__row">
  868. <xsl:apply-templates select="*[contains(@class, ' topic/stentry ')]"/>
  869. <xsl:variable name="row-cell-count" select="count(*[contains(@class, ' topic/stentry ')])" as="xs:integer"/>
  870. <xsl:if test="$row-cell-count &lt; $number-cells">
  871. <xsl:apply-templates select="." mode="fillInMissingSimpletableCells">
  872. <xsl:with-param name="fill-in-count" select="$number-cells - $row-cell-count"/>
  873. </xsl:apply-templates>
  874. </xsl:if>
  875. </fo:table-row>
  876. </fo:table-header>
  877. </xsl:template>
  878. <xsl:template match="*[contains(@class, ' topic/strow ')]">
  879. <xsl:param name="number-cells" as="xs:integer">
  880. <xsl:apply-templates select="../*[1]" mode="count-max-simpletable-cells"/>
  881. </xsl:param>
  882. <fo:table-row xsl:use-attribute-sets="strow">
  883. <xsl:call-template name="commonattributes"/>
  884. <xsl:apply-templates select="*[contains(@class, ' topic/stentry ')]"/>
  885. <xsl:variable name="row-cell-count" select="count(*[contains(@class, ' topic/stentry ')])" as="xs:integer"/>
  886. <xsl:if test="$row-cell-count &lt; $number-cells">
  887. <xsl:apply-templates select="." mode="fillInMissingSimpletableCells">
  888. <xsl:with-param name="fill-in-count" select="$number-cells - $row-cell-count"/>
  889. </xsl:apply-templates>
  890. </xsl:if>
  891. </fo:table-row>
  892. </xsl:template>
  893. <xsl:template match="*[contains(@class, ' topic/sthead ')]/*[contains(@class, ' topic/stentry ')]">
  894. <fo:table-cell xsl:use-attribute-sets="sthead.stentry">
  895. <xsl:call-template name="commonattributes"/>
  896. <xsl:variable name="entryCol" select="count(preceding-sibling::*[contains(@class, ' topic/stentry ')]) + 1"/>
  897. <xsl:variable name="frame" as="xs:string">
  898. <xsl:variable name="f" select="ancestor::*[contains(@class, ' topic/simpletable ')][1]/@frame"/>
  899. <xsl:choose>
  900. <xsl:when test="$f">
  901. <xsl:value-of select="$f"/>
  902. </xsl:when>
  903. <xsl:otherwise>
  904. <xsl:value-of select="$table.frame-default"/>
  905. </xsl:otherwise>
  906. </xsl:choose>
  907. </xsl:variable>
  908. <xsl:call-template name="generateSimpleTableHorizontalBorders">
  909. <xsl:with-param name="frame" select="$frame"/>
  910. </xsl:call-template>
  911. <xsl:if test="$frame = 'all' or $frame = 'topbot' or $frame = 'top'">
  912. <xsl:call-template name="processAttrSetReflection">
  913. <xsl:with-param name="attrSet" select="'__tableframe__top'"/>
  914. <xsl:with-param name="path" select="$tableAttrs"/>
  915. </xsl:call-template>
  916. </xsl:if>
  917. <xsl:if test="following-sibling::*[contains(@class, ' topic/stentry ')]">
  918. <xsl:call-template name="generateSimpleTableVerticalBorders">
  919. <xsl:with-param name="frame" select="$frame"/>
  920. </xsl:call-template>
  921. </xsl:if>
  922. <xsl:choose>
  923. <xsl:when test="number(ancestor::*[contains(@class, ' topic/simpletable ')][1]/@keycol) = $entryCol">
  924. <fo:block xsl:use-attribute-sets="sthead.stentry__keycol-content">
  925. <xsl:apply-templates select="." mode="ancestor-start-flag"/>
  926. <xsl:apply-templates/>
  927. <xsl:apply-templates select="." mode="ancestor-end-flag"/>
  928. </fo:block>
  929. </xsl:when>
  930. <xsl:otherwise>
  931. <fo:block xsl:use-attribute-sets="sthead.stentry__content">
  932. <xsl:apply-templates select="." mode="ancestor-start-flag"/>
  933. <xsl:apply-templates/>
  934. <xsl:apply-templates select="." mode="ancestor-end-flag"/>
  935. </fo:block>
  936. </xsl:otherwise>
  937. </xsl:choose>
  938. </fo:table-cell>
  939. </xsl:template>
  940. <xsl:template match="*[contains(@class, ' topic/strow ')]/*[contains(@class, ' topic/stentry ')]">
  941. <fo:table-cell xsl:use-attribute-sets="strow.stentry">
  942. <xsl:call-template name="commonattributes"/>
  943. <xsl:variable name="entryCol" select="count(preceding-sibling::*[contains(@class, ' topic/stentry ')]) + 1"/>
  944. <xsl:variable name="frame" as="xs:string">
  945. <xsl:variable name="f" select="ancestor::*[contains(@class, ' topic/simpletable ')][1]/@frame"/>
  946. <xsl:choose>
  947. <xsl:when test="$f">
  948. <xsl:value-of select="$f"/>
  949. </xsl:when>
  950. <xsl:otherwise>
  951. <xsl:value-of select="$table.frame-default"/>
  952. </xsl:otherwise>
  953. </xsl:choose>
  954. </xsl:variable>
  955. <xsl:if test="../following-sibling::*[contains(@class, ' topic/strow ')]">
  956. <xsl:call-template name="generateSimpleTableHorizontalBorders">
  957. <xsl:with-param name="frame" select="$frame"/>
  958. </xsl:call-template>
  959. </xsl:if>
  960. <xsl:if test="following-sibling::*[contains(@class, ' topic/stentry ')]">
  961. <xsl:call-template name="generateSimpleTableVerticalBorders">
  962. <xsl:with-param name="frame" select="$frame"/>
  963. </xsl:call-template>
  964. </xsl:if>
  965. <xsl:choose>
  966. <xsl:when test="number(ancestor::*[contains(@class, ' topic/simpletable ')][1]/@keycol) = $entryCol">
  967. <fo:block xsl:use-attribute-sets="strow.stentry__keycol-content">
  968. <xsl:apply-templates select="." mode="ancestor-start-flag"/>
  969. <xsl:apply-templates/>
  970. <xsl:apply-templates select="." mode="ancestor-end-flag"/>
  971. </fo:block>
  972. </xsl:when>
  973. <xsl:otherwise>
  974. <fo:block xsl:use-attribute-sets="strow.stentry__content">
  975. <xsl:apply-templates select="." mode="ancestor-start-flag"/>
  976. <xsl:apply-templates/>
  977. <xsl:apply-templates select="." mode="ancestor-end-flag"/>
  978. </fo:block>
  979. </xsl:otherwise>
  980. </xsl:choose>
  981. </fo:table-cell>
  982. </xsl:template>
  983. <xsl:template name="generateSimpleTableHorizontalBorders">
  984. <xsl:param name="frame" as="xs:string?"/>
  985. <xsl:choose>
  986. <xsl:when test="($frame = 'all') or ($frame = 'topbot') or ($frame = 'sides') or not($frame)">
  987. <xsl:call-template name="processAttrSetReflection">
  988. <xsl:with-param name="attrSet" select="'__tableframe__bottom'"/>
  989. <xsl:with-param name="path" select="$tableAttrs"/>
  990. </xsl:call-template>
  991. </xsl:when>
  992. </xsl:choose>
  993. </xsl:template>
  994. <xsl:template name="generateSimpleTableVerticalBorders">
  995. <xsl:param name="frame" as="xs:string?"/>
  996. <xsl:choose>
  997. <xsl:when test="($frame = 'all') or ($frame = 'topbot') or ($frame = 'sides') or not($frame)">
  998. <xsl:call-template name="processAttrSetReflection">
  999. <xsl:with-param name="attrSet" select="'__tableframe__right'"/>
  1000. <xsl:with-param name="path" select="$tableAttrs"/>
  1001. </xsl:call-template>
  1002. </xsl:when>
  1003. </xsl:choose>
  1004. </xsl:template>
  1005. <xsl:template name="topicrefAttsNoToc">
  1006. <!--TODO-->
  1007. </xsl:template>
  1008. <xsl:template name="topicrefAtts">
  1009. <!--TODO-->
  1010. </xsl:template>
  1011. <xsl:template name="selectAtts">
  1012. <!--TODO-->
  1013. </xsl:template>
  1014. <xsl:template name="globalAtts">
  1015. <!--TODO-->
  1016. </xsl:template>
  1017. </xsl:stylesheet>