| 1 |
<?xml version='1.0' encoding="utf-8" ?> |
| 2 |
|
| 3 |
<xsl:stylesheet |
| 4 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 5 |
xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" |
| 6 |
xmlns:exsl="http://exslt.org/common" |
| 7 |
exclude-result-prefixes="doc exsl" version='1.0'> |
| 8 |
|
| 9 |
<!--==================== newtbl table handling ========================--> |
| 10 |
<!--= =--> |
| 11 |
<!--= Copyright (C) 2004-2006 Vistair Systems Ltd (www.vistair.com) =--> |
| 12 |
<!--= =--> |
| 13 |
<!--= Released under the GNU General Public Licence (GPL) =--> |
| 14 |
<!--= (Commercial and other licences by arrangement) =--> |
| 15 |
<!--= =--> |
| 16 |
<!--= Release 23/04/2006 by DCRH =--> |
| 17 |
<!--= =--> |
| 18 |
<!--= Email [email protected] with bugs, comments etc =--> |
| 19 |
<!--= =--> |
| 20 |
<!--===================================================================--> |
| 21 |
|
| 22 |
<!-- Step though each column, generating a colspec entry for it. If a --> |
| 23 |
<!-- colspec was given in the xml, then use it, otherwise generate a --> |
| 24 |
<!-- default one --> |
| 25 |
<xsl:template name="tbl.defcolspec"> |
| 26 |
<xsl:param name="colnum" select="1"/> |
| 27 |
<xsl:param name="colspec"/> |
| 28 |
<xsl:param name="align"/> |
| 29 |
<xsl:param name="rowsep"/> |
| 30 |
<xsl:param name="colsep"/> |
| 31 |
<xsl:param name="cols"/> |
| 32 |
<xsl:param name="autowidth"/> |
| 33 |
|
| 34 |
<xsl:if test="$colnum <= $cols"> |
| 35 |
<xsl:choose> |
| 36 |
<xsl:when test="$colspec/colspec[@colnum = $colnum]"> |
| 37 |
<xsl:copy-of select="$colspec/colspec[@colnum = $colnum]"/> |
| 38 |
</xsl:when> |
| 39 |
<xsl:otherwise> |
| 40 |
<xsl:variable name="natwidth"> |
| 41 |
<xsl:call-template name="natural-width"> |
| 42 |
<xsl:with-param name="autowidth" select="$autowidth"/> |
| 43 |
<xsl:with-param name="colnum" select="$colnum"/> |
| 44 |
</xsl:call-template> |
| 45 |
</xsl:variable> |
| 46 |
|
| 47 |
<colspec colnum='{$colnum}' align='{$align}' star='1' |
| 48 |
rowsep='{$rowsep}' colsep='{$colsep}' |
| 49 |
colwidth='\newtblstarfactor'> |
| 50 |
<xsl:if test="$natwidth = 1"> |
| 51 |
<xsl:attribute name="autowidth">1</xsl:attribute> |
| 52 |
</xsl:if> |
| 53 |
</colspec> |
| 54 |
</xsl:otherwise> |
| 55 |
</xsl:choose> |
| 56 |
<xsl:call-template name="tbl.defcolspec"> |
| 57 |
<xsl:with-param name="colnum" select="$colnum + 1"/> |
| 58 |
<xsl:with-param name="align" select="$align"/> |
| 59 |
<xsl:with-param name="rowsep" select="$rowsep"/> |
| 60 |
<xsl:with-param name="colsep" select="$colsep"/> |
| 61 |
<xsl:with-param name="cols" select="$cols"/> |
| 62 |
<xsl:with-param name="autowidth" select="$autowidth"/> |
| 63 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 64 |
</xsl:call-template> |
| 65 |
</xsl:if> |
| 66 |
</xsl:template> |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
<!-- replace-string function as XSLT doesn't have one built in. --> |
| 71 |
<xsl:template name="replace-string"> |
| 72 |
<xsl:param name="text"/> |
| 73 |
<xsl:param name="replace"/> |
| 74 |
<xsl:param name="with"/> |
| 75 |
<xsl:choose> |
| 76 |
<xsl:when test="contains($text,$replace)"> |
| 77 |
<xsl:value-of select="substring-before($text,$replace)"/> |
| 78 |
<xsl:value-of select="$with"/> |
| 79 |
<xsl:call-template name="replace-string"> |
| 80 |
<xsl:with-param name="text" |
| 81 |
select="substring-after($text,$replace)"/> |
| 82 |
<xsl:with-param name="replace" select="$replace"/> |
| 83 |
<xsl:with-param name="with" select="$with"/> |
| 84 |
</xsl:call-template> |
| 85 |
</xsl:when> |
| 86 |
<xsl:otherwise> |
| 87 |
<xsl:value-of select="$text"/> |
| 88 |
</xsl:otherwise> |
| 89 |
</xsl:choose> |
| 90 |
</xsl:template> |
| 91 |
|
| 92 |
<!-- This template extracts the fixed part of a colwidth specification. |
| 93 |
It should be able to do this: |
| 94 |
a+b+c+d*+e+f -> a+b+c+e+f |
| 95 |
a+b+c+d* -> a+b+c |
| 96 |
d*+e+f -> e+f |
| 97 |
--> |
| 98 |
<xsl:template name="colfixed.get"> |
| 99 |
<xsl:param name="width" select="@colwidth"/> |
| 100 |
<xsl:param name="stared" select="'0'"/> |
| 101 |
|
| 102 |
<xsl:choose> |
| 103 |
<xsl:when test="contains($width, '*')"> |
| 104 |
<xsl:variable name="after" |
| 105 |
select="substring-after(substring-after($width, '*'), '+')"/> |
| 106 |
<xsl:if test="contains(substring-before($width, '*'), '+')"> |
| 107 |
<xsl:call-template name="colfixed.get"> |
| 108 |
<xsl:with-param name="width" select="substring-before($width, '*')"/> |
| 109 |
<xsl:with-param name="stared" select="'1'"/> |
| 110 |
</xsl:call-template> |
| 111 |
<xsl:if test="$after!=''"> |
| 112 |
<xsl:text>+</xsl:text> |
| 113 |
</xsl:if> |
| 114 |
</xsl:if> |
| 115 |
<xsl:value-of select="$after"/> |
| 116 |
</xsl:when> |
| 117 |
<xsl:when test="$stared='1'"> |
| 118 |
<xsl:value-of select="substring-before($width, '+')"/> |
| 119 |
<xsl:if test="contains(substring-after($width, '+'), '+')"> |
| 120 |
<xsl:text>+</xsl:text> |
| 121 |
<xsl:call-template name="colfixed.get"> |
| 122 |
<xsl:with-param name="width" select="substring-after($width, '+')"/> |
| 123 |
<xsl:with-param name="stared" select="'1'"/> |
| 124 |
</xsl:call-template> |
| 125 |
</xsl:if> |
| 126 |
</xsl:when> |
| 127 |
<xsl:otherwise> |
| 128 |
<xsl:value-of select="$width"/> |
| 129 |
</xsl:otherwise> |
| 130 |
</xsl:choose> |
| 131 |
</xsl:template> |
| 132 |
|
| 133 |
|
| 134 |
<xsl:template name="colstar.get"> |
| 135 |
<xsl:param name="width"/> |
| 136 |
<xsl:choose> |
| 137 |
<xsl:when test="contains($width, '+')"> |
| 138 |
<xsl:call-template name="colstar.get"> |
| 139 |
<xsl:with-param name="width" select="substring-after($width, '+')"/> |
| 140 |
</xsl:call-template> |
| 141 |
</xsl:when> |
| 142 |
<xsl:otherwise> |
| 143 |
<xsl:choose> |
| 144 |
<xsl:when test="string(number($width))='NaN'">1</xsl:when> |
| 145 |
<xsl:otherwise> |
| 146 |
<!-- Use number() to ensure to have something well formatted --> |
| 147 |
<xsl:value-of select="number($width)"/> |
| 148 |
</xsl:otherwise> |
| 149 |
</xsl:choose> |
| 150 |
</xsl:otherwise> |
| 151 |
</xsl:choose> |
| 152 |
</xsl:template> |
| 153 |
|
| 154 |
|
| 155 |
<!-- Evaluate from the autowidth statement if the current column width |
| 156 |
is its natural size determined by the column cells contents --> |
| 157 |
<xsl:template name="natural-width"> |
| 158 |
<xsl:param name="autowidth"/> |
| 159 |
<xsl:param name="colnum" select="1"/> |
| 160 |
|
| 161 |
<xsl:choose> |
| 162 |
<xsl:when test="not(string(@colwidth)) and |
| 163 |
(contains($autowidth,'default') or |
| 164 |
contains($autowidth,'all'))">1</xsl:when> |
| 165 |
<xsl:when test="contains(@colwidth,'*') and |
| 166 |
contains($autowidth,'all')">1</xsl:when> |
| 167 |
<xsl:when test="contains(concat($autowidth,' '),concat(' ',$colnum,' ')) and |
| 168 |
contains($autowidth,'column')">1</xsl:when> |
| 169 |
<xsl:otherwise>0</xsl:otherwise> |
| 170 |
</xsl:choose> |
| 171 |
</xsl:template> |
| 172 |
|
| 173 |
|
| 174 |
<!-- Ensure each column has a colspec and each colspec has a valid column --> |
| 175 |
<!-- number, width, alignment, colsep, rowsep --> |
| 176 |
<xsl:template match="colspec" mode="newtbl"> |
| 177 |
<xsl:param name="colnum" select="1"/> |
| 178 |
<xsl:param name="align"/> |
| 179 |
<xsl:param name="colsep"/> |
| 180 |
<xsl:param name="rowsep"/> |
| 181 |
<xsl:param name="autowidth"/> |
| 182 |
|
| 183 |
<xsl:variable name="natwidth"> |
| 184 |
<xsl:call-template name="natural-width"> |
| 185 |
<xsl:with-param name="autowidth" select="$autowidth"/> |
| 186 |
<xsl:with-param name="colnum"> |
| 187 |
<xsl:choose><xsl:when test="@colnum"> |
| 188 |
<xsl:value-of select="@colnum"/> |
| 189 |
</xsl:when> |
| 190 |
<xsl:otherwise> |
| 191 |
<xsl:value-of select="$colnum"/> |
| 192 |
</xsl:otherwise></xsl:choose> |
| 193 |
</xsl:with-param> |
| 194 |
</xsl:call-template> |
| 195 |
</xsl:variable> |
| 196 |
|
| 197 |
<xsl:copy> |
| 198 |
<xsl:for-each select="@*"><xsl:copy/></xsl:for-each> |
| 199 |
<xsl:if test="$natwidth = 1"> |
| 200 |
<xsl:attribute name="autowidth">1</xsl:attribute> |
| 201 |
</xsl:if> |
| 202 |
<xsl:if test="not(@colnum)"> |
| 203 |
<xsl:attribute name="colnum"><xsl:value-of select="$colnum"/> |
| 204 |
</xsl:attribute> |
| 205 |
</xsl:if> |
| 206 |
<!-- Find out if the column width contains fixed width --> |
| 207 |
<xsl:variable name="fixed"> |
| 208 |
<xsl:call-template name="colfixed.get"/> |
| 209 |
</xsl:variable> |
| 210 |
|
| 211 |
<xsl:if test="$fixed!=''"> |
| 212 |
<xsl:attribute name="fixedwidth"> |
| 213 |
<xsl:value-of select="$fixed"/> |
| 214 |
</xsl:attribute> |
| 215 |
</xsl:if> |
| 216 |
<!-- Replace '*' with our to-be-computed factor --> |
| 217 |
<xsl:if test="contains(@colwidth,'*')"> |
| 218 |
<xsl:attribute name="colwidth"> |
| 219 |
<xsl:call-template name="replace-string"> |
| 220 |
<xsl:with-param name="text" select="@colwidth"/> |
| 221 |
<xsl:with-param name="replace">*</xsl:with-param> |
| 222 |
<xsl:with-param name="with">\newtblstarfactor</xsl:with-param> |
| 223 |
</xsl:call-template> |
| 224 |
</xsl:attribute> |
| 225 |
<xsl:attribute name="star"> |
| 226 |
<xsl:call-template name="colstar.get"> |
| 227 |
<xsl:with-param name="width" select="substring-before(@colwidth, '*')"/> |
| 228 |
</xsl:call-template> |
| 229 |
</xsl:attribute> |
| 230 |
</xsl:if> |
| 231 |
<!-- No colwidth specified? Assume '*' --> |
| 232 |
<xsl:if test="not(string(@colwidth))"> |
| 233 |
<xsl:attribute name="colwidth">\newtblstarfactor</xsl:attribute> |
| 234 |
<xsl:attribute name="star">1</xsl:attribute> |
| 235 |
</xsl:if> |
| 236 |
<xsl:if test="not(@align)"> |
| 237 |
<xsl:attribute name="align"><xsl:value-of select="$align"/> |
| 238 |
</xsl:attribute> |
| 239 |
</xsl:if> |
| 240 |
<xsl:if test="not(@rowsep)"> |
| 241 |
<xsl:attribute name="rowsep"><xsl:value-of select="$rowsep"/> |
| 242 |
</xsl:attribute> |
| 243 |
</xsl:if> |
| 244 |
<xsl:if test="not(@colsep)"> |
| 245 |
<xsl:attribute name="colsep"><xsl:value-of select="$colsep"/> |
| 246 |
</xsl:attribute> |
| 247 |
</xsl:if> |
| 248 |
<!-- bgcolor specified via a PI --> |
| 249 |
<xsl:variable name="bgcolor"> |
| 250 |
<xsl:call-template name="pi.dblatex_bgcolor"/> |
| 251 |
</xsl:variable> |
| 252 |
<xsl:if test="$bgcolor != ''"> |
| 253 |
<xsl:attribute name="bgcolor"><xsl:value-of select="$bgcolor"/> |
| 254 |
</xsl:attribute> |
| 255 |
</xsl:if> |
| 256 |
|
| 257 |
</xsl:copy> |
| 258 |
|
| 259 |
<xsl:variable name="nextcolnum"> |
| 260 |
<xsl:choose> |
| 261 |
<xsl:when test="@colnum"><xsl:value-of select="@colnum + 1"/></xsl:when> |
| 262 |
<xsl:otherwise><xsl:value-of select="$colnum + 1"/></xsl:otherwise> |
| 263 |
</xsl:choose> |
| 264 |
</xsl:variable> |
| 265 |
|
| 266 |
<xsl:apply-templates mode="newtbl" |
| 267 |
select="following-sibling::colspec[1]"> |
| 268 |
<xsl:with-param name="colnum" select="$nextcolnum"/> |
| 269 |
<xsl:with-param name="align" select="$align"/> |
| 270 |
<xsl:with-param name="colsep" select="$colsep"/> |
| 271 |
<xsl:with-param name="rowsep" select="$rowsep"/> |
| 272 |
<xsl:with-param name="autowidth" select="$autowidth"/> |
| 273 |
</xsl:apply-templates> |
| 274 |
</xsl:template> |
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
<!-- Generate a complete set of colspecs for each column in the table --> |
| 279 |
<xsl:template name="tbl.colspec"> |
| 280 |
<xsl:param name="autowidth"/> |
| 281 |
<xsl:param name="align"/> |
| 282 |
<xsl:param name="rowsep"/> |
| 283 |
<xsl:param name="colsep"/> |
| 284 |
<xsl:param name="cols"/> |
| 285 |
|
| 286 |
<!-- First, get the colspecs that have been specified --> |
| 287 |
<xsl:variable name="givencolspec"> |
| 288 |
<xsl:apply-templates mode="newtbl" select="colspec[1]"> |
| 289 |
<xsl:with-param name="align" select="$align"/> |
| 290 |
<xsl:with-param name="rowsep" select="$rowsep"/> |
| 291 |
<xsl:with-param name="colsep" select="$colsep"/> |
| 292 |
<xsl:with-param name="autowidth" select="$autowidth"/> |
| 293 |
</xsl:apply-templates> |
| 294 |
</xsl:variable> |
| 295 |
|
| 296 |
<!-- Now generate colspecs for each missing column --> |
| 297 |
<xsl:call-template name="tbl.defcolspec"> |
| 298 |
<xsl:with-param name="colspec" select="exsl:node-set($givencolspec)"/> |
| 299 |
<xsl:with-param name="cols" select="$cols"/> |
| 300 |
<xsl:with-param name="align" select="$align"/> |
| 301 |
<xsl:with-param name="rowsep" select="$rowsep"/> |
| 302 |
<xsl:with-param name="colsep" select="$colsep"/> |
| 303 |
<xsl:with-param name="autowidth" select="$autowidth"/> |
| 304 |
</xsl:call-template> |
| 305 |
</xsl:template> |
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
<!-- Create a blank entry element. We check the 'entries' node-set --> |
| 310 |
<!-- to see if we should copy an entry from the row above instead --> |
| 311 |
<xsl:template name="tbl.blankentry"> |
| 312 |
<xsl:param name="colnum"/> |
| 313 |
<xsl:param name="colend"/> |
| 314 |
<xsl:param name="rownum"/> |
| 315 |
<xsl:param name="colspec"/> |
| 316 |
<xsl:param name="entries"/> |
| 317 |
<xsl:param name="rowcolor"/> |
| 318 |
|
| 319 |
<xsl:if test="$colnum <= $colend"> |
| 320 |
<xsl:variable name="entry" |
| 321 |
select="$entries/*[self::entry or self::entrytbl] |
| 322 |
[@colstart=$colnum and @rowend >= $rownum]"/> |
| 323 |
<xsl:choose> |
| 324 |
<xsl:when test="$entry"> |
| 325 |
<!-- Just copy this entry then --> |
| 326 |
<xsl:copy-of select="$entry"/> |
| 327 |
</xsl:when> |
| 328 |
<xsl:otherwise> |
| 329 |
<xsl:variable name="bgcolor"> |
| 330 |
<xsl:choose> |
| 331 |
<xsl:when test="$rowcolor != ''"> |
| 332 |
<xsl:value-of select="$rowcolor"/> |
| 333 |
</xsl:when> |
| 334 |
<xsl:otherwise> |
| 335 |
<xsl:value-of select="$colspec/colspec[@colnum=$colnum]/@bgcolor"/> |
| 336 |
</xsl:otherwise> |
| 337 |
</xsl:choose> |
| 338 |
</xsl:variable> |
| 339 |
<!-- No rowspan entry found from the row above, so create a blank --> |
| 340 |
<entry colstart='{$colnum}' colend='{$colnum}' |
| 341 |
rowstart='{$rownum}' rowend='{$rownum}' |
| 342 |
colsep='{$colspec/colspec[@colnum=$colnum]/@colsep}' |
| 343 |
defrowsep='{$colspec/colspec[@colnum=$colnum]/@rowsep}' |
| 344 |
align='{$colspec/colspec[@colnum=$colnum]/@align}' |
| 345 |
bgcolor='{$bgcolor}'/> |
| 346 |
</xsl:otherwise> |
| 347 |
</xsl:choose> |
| 348 |
<xsl:variable name="nextcol"> |
| 349 |
<xsl:choose> |
| 350 |
<xsl:when test="$entry"> |
| 351 |
<xsl:value-of select="$entry/@colend"/> |
| 352 |
</xsl:when> |
| 353 |
<xsl:otherwise> |
| 354 |
<xsl:value-of select="$colnum"/> |
| 355 |
</xsl:otherwise> |
| 356 |
</xsl:choose> |
| 357 |
</xsl:variable> |
| 358 |
<xsl:call-template name="tbl.blankentry"> |
| 359 |
<xsl:with-param name="colnum" select="$nextcol + 1"/> |
| 360 |
<xsl:with-param name="colend" select="$colend"/> |
| 361 |
<xsl:with-param name="rownum" select="$rownum"/> |
| 362 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 363 |
<xsl:with-param name="rowcolor" select="$rowcolor"/> |
| 364 |
<xsl:with-param name="entries" select="$entries"/> |
| 365 |
</xsl:call-template> |
| 366 |
</xsl:if> |
| 367 |
</xsl:template> |
| 368 |
|
| 369 |
|
| 370 |
<!-- Check the entry column range is valid --> |
| 371 |
<xsl:template name="check-colrange"> |
| 372 |
<xsl:param name="colnum"/> |
| 373 |
<xsl:param name="rownum"/> |
| 374 |
<xsl:param name="colend"/> |
| 375 |
<xsl:param name="colstart"/> |
| 376 |
|
| 377 |
<xsl:variable name="msg"> |
| 378 |
<xsl:text>Invalid table entry row=</xsl:text> |
| 379 |
<xsl:value-of select="$rownum"/> |
| 380 |
<xsl:text>/column=</xsl:text> |
| 381 |
<xsl:value-of select="$colnum"/> |
| 382 |
</xsl:variable> |
| 383 |
<xsl:if test="string(number($colend))='NaN'"> |
| 384 |
<xsl:message terminate="yes"> |
| 385 |
<xsl:value-of select="$msg"/> |
| 386 |
<xsl:text> (@colend)</xsl:text> |
| 387 |
</xsl:message> |
| 388 |
</xsl:if> |
| 389 |
<xsl:if test="string(number($colstart))='NaN'"> |
| 390 |
<xsl:message terminate="yes"> |
| 391 |
<xsl:value-of select="$msg"/> |
| 392 |
<xsl:text> (@colstart)</xsl:text> |
| 393 |
</xsl:message> |
| 394 |
</xsl:if> |
| 395 |
</xsl:template> |
| 396 |
|
| 397 |
|
| 398 |
<!-- Returns a RTF of entry elements. rowsep, colsep and align are all --> |
| 399 |
<!-- extracted from spanspec/colspec as required --> |
| 400 |
<!-- Skipped columns have blank entry elements created --> |
| 401 |
<!-- Existing entry elements in the given entries node-set are checked to --> |
| 402 |
<!-- see if they should extend into this row and are copied if so --> |
| 403 |
<!-- Each element is given additional attributes: --> |
| 404 |
<!-- rowstart = The top row number of the table this entry --> |
| 405 |
<!-- rowend = The bottom row number of the table this entry --> |
| 406 |
<!-- colstart = The starting column number of this entry --> |
| 407 |
<!-- colend = The ending column number of this entry --> |
| 408 |
<!-- defrowsep = The default rowsep value inherited from the entry's span --> |
| 409 |
<!-- or colspec --> |
| 410 |
<xsl:template match="entry|entrytbl" mode="newtbl.buildentries"> |
| 411 |
<xsl:param name="colnum"/> |
| 412 |
<xsl:param name="rownum"/> |
| 413 |
<xsl:param name="colspec"/> |
| 414 |
<xsl:param name="spanspec"/> |
| 415 |
<xsl:param name="frame"/> |
| 416 |
<xsl:param name="rowcolor"/> |
| 417 |
<xsl:param name="entries"/> |
| 418 |
<xsl:param name="tabletype"/> |
| 419 |
|
| 420 |
<xsl:variable name="cols" select="count($colspec/*)"/> |
| 421 |
|
| 422 |
<xsl:if test="$colnum <= $cols"> |
| 423 |
|
| 424 |
<xsl:variable name="entry" |
| 425 |
select="$entries/*[self::entry or self::entrytbl] |
| 426 |
[@colstart=$colnum and @rowend >= $rownum]"/> |
| 427 |
<!-- Do we have an existing entry element from a previous row that --> |
| 428 |
<!-- should be copied into this row? --> |
| 429 |
<xsl:choose><xsl:when test="$entry"> |
| 430 |
<!-- Just copy this entry then --> |
| 431 |
<xsl:copy-of select="$entry"/> |
| 432 |
|
| 433 |
<!-- Process the next column using this current entry --> |
| 434 |
<xsl:apply-templates mode="newtbl.buildentries" select="."> |
| 435 |
<xsl:with-param name="colnum" |
| 436 |
select="$entries/entry[@colstart=$colnum]/@colend + 1"/> |
| 437 |
<xsl:with-param name="rownum" select="$rownum"/> |
| 438 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 439 |
<xsl:with-param name="spanspec" select="$spanspec"/> |
| 440 |
<xsl:with-param name="frame" select="$frame"/> |
| 441 |
<xsl:with-param name="rowcolor" select="$rowcolor"/> |
| 442 |
<xsl:with-param name="entries" select="$entries"/> |
| 443 |
<xsl:with-param name="tabletype" select="$tabletype"/> |
| 444 |
</xsl:apply-templates> |
| 445 |
</xsl:when><xsl:otherwise> |
| 446 |
<!-- Get any span for this entry --> |
| 447 |
<xsl:variable name="span"> |
| 448 |
<xsl:if test="@spanname and $spanspec[@spanname=current()/@spanname]"> |
| 449 |
<xsl:copy-of select="$spanspec[@spanname=current()/@spanname]"/> |
| 450 |
</xsl:if> |
| 451 |
</xsl:variable> |
| 452 |
|
| 453 |
<!-- Get the starting column number for this cell --> |
| 454 |
<xsl:variable name="colstart"> |
| 455 |
<xsl:choose> |
| 456 |
<!-- Check colname first --> |
| 457 |
<xsl:when test="$colspec/colspec[@colname=current()/@colname]"> |
| 458 |
<xsl:value-of |
| 459 |
select="$colspec/colspec[@colname=current()/@colname]/@colnum"/> |
| 460 |
</xsl:when> |
| 461 |
<!-- Now check span --> |
| 462 |
<xsl:when test="exsl:node-set($span)/spanspec/@namest"> |
| 463 |
<xsl:value-of select="$colspec/colspec[@colname= |
| 464 |
exsl:node-set($span)/spanspec/@namest]/@colnum"/> |
| 465 |
</xsl:when> |
| 466 |
<!-- Now check namest attribute --> |
| 467 |
<xsl:when test="@namest"> |
| 468 |
<xsl:value-of select="$colspec/colspec[@colname= |
| 469 |
current()/@namest]/@colnum"/> |
| 470 |
</xsl:when> |
| 471 |
<xsl:otherwise> |
| 472 |
<xsl:value-of select="$colnum"/> |
| 473 |
</xsl:otherwise> |
| 474 |
</xsl:choose> |
| 475 |
</xsl:variable> |
| 476 |
|
| 477 |
<!-- Get the ending column number for this cell --> |
| 478 |
<xsl:variable name="colend"> |
| 479 |
<xsl:choose> |
| 480 |
<!-- Check span --> |
| 481 |
<xsl:when test="exsl:node-set($span)/spanspec/@nameend"> |
| 482 |
<xsl:value-of select="$colspec/colspec[@colname= |
| 483 |
exsl:node-set($span)/spanspec/@nameend]/@colnum"/> |
| 484 |
</xsl:when> |
| 485 |
<!-- Check nameend attribute --> |
| 486 |
<xsl:when test="@nameend"> |
| 487 |
<xsl:value-of select="$colspec/colspec[@colname= |
| 488 |
current()/@nameend]/@colnum"/> |
| 489 |
</xsl:when> |
| 490 |
<!-- Otherwise end == start --> |
| 491 |
<xsl:otherwise> |
| 492 |
<xsl:value-of select="$colstart"/> |
| 493 |
</xsl:otherwise> |
| 494 |
</xsl:choose> |
| 495 |
</xsl:variable> |
| 496 |
|
| 497 |
<!-- Check column consistency --> |
| 498 |
<xsl:call-template name="check-colrange"> |
| 499 |
<xsl:with-param name="colnum" select="$colnum"/> |
| 500 |
<xsl:with-param name="rownum" select="$rownum"/> |
| 501 |
<xsl:with-param name="colstart" select="$colstart"/> |
| 502 |
<xsl:with-param name="colend" select="$colend"/> |
| 503 |
</xsl:call-template> |
| 504 |
|
| 505 |
<!-- No offset between column and cell content for entrytbl --> |
| 506 |
<xsl:variable name="coloff"> |
| 507 |
<xsl:choose> |
| 508 |
<xsl:when test="self::entrytbl">0</xsl:when> |
| 509 |
<xsl:otherwise>1</xsl:otherwise> |
| 510 |
</xsl:choose> |
| 511 |
</xsl:variable> |
| 512 |
|
| 513 |
<!-- Does this entry want to start at a later column? --> |
| 514 |
<xsl:if test="$colnum < $colstart"> |
| 515 |
<!-- If so, create some blank entries to fill in the gap --> |
| 516 |
<xsl:call-template name="tbl.blankentry"> |
| 517 |
<xsl:with-param name="colnum" select="$colnum"/> |
| 518 |
<xsl:with-param name="colend" select="$colstart - 1"/> |
| 519 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 520 |
<xsl:with-param name="rownum" select="$rownum"/> |
| 521 |
<xsl:with-param name="rowcolor" select="$rowcolor"/> |
| 522 |
<xsl:with-param name="entries" select="$entries"/> |
| 523 |
</xsl:call-template> |
| 524 |
</xsl:if> |
| 525 |
|
| 526 |
<!-- Get the colsep override from this entry or its span --> |
| 527 |
<xsl:variable name="colsep"> |
| 528 |
<xsl:choose> |
| 529 |
<!-- Entry element override --> |
| 530 |
<xsl:when test="@colsep"><xsl:value-of select="@colsep"/></xsl:when> |
| 531 |
<!-- Then any span present --> |
| 532 |
<xsl:when test="exsl:node-set($span)/spanspec/@colsep"> |
| 533 |
<xsl:value-of select="exsl:node-set($span)/spanspec/@colsep"/> |
| 534 |
</xsl:when> |
| 535 |
<xsl:otherwise> |
| 536 |
<!-- Otherwise take from colspec --> |
| 537 |
<xsl:value-of select="$colspec/colspec[@colnum=$colstart]/@colsep"/> |
| 538 |
</xsl:otherwise> |
| 539 |
</xsl:choose> |
| 540 |
</xsl:variable> |
| 541 |
|
| 542 |
<!-- Get the default rowsep for this entry --> |
| 543 |
<xsl:variable name="defrowsep"> |
| 544 |
<xsl:choose> |
| 545 |
<!-- Check any span present --> |
| 546 |
<xsl:when test="exsl:node-set($span)/spanspec/@rowsep"> |
| 547 |
<xsl:value-of select="exsl:node-set($span)/spanspec/@rowsep"/> |
| 548 |
</xsl:when> |
| 549 |
<xsl:otherwise> |
| 550 |
<!-- Otherwise take from colspec --> |
| 551 |
<xsl:value-of select="$colspec/colspec[@colnum=$colstart]/@rowsep"/> |
| 552 |
</xsl:otherwise> |
| 553 |
</xsl:choose> |
| 554 |
</xsl:variable> |
| 555 |
|
| 556 |
<!-- Generate cell alignment --> |
| 557 |
<xsl:variable name="align"> |
| 558 |
<xsl:choose> |
| 559 |
<!-- Entry element attribute first --> |
| 560 |
<xsl:when test="string(@align)"> |
| 561 |
<xsl:value-of select="@align"/> |
| 562 |
</xsl:when> |
| 563 |
<!-- Then any span present --> |
| 564 |
<xsl:when test="exsl:node-set($span)/spanspec/@align"> |
| 565 |
<xsl:value-of select="exsl:node-set($span)/spanspec/@align"/> |
| 566 |
</xsl:when> |
| 567 |
<xsl:otherwise> |
| 568 |
<!-- Otherwise take from colspec --> |
| 569 |
<xsl:value-of select="$colspec/colspec[@colnum=$colstart]/@align"/> |
| 570 |
</xsl:otherwise> |
| 571 |
</xsl:choose> |
| 572 |
</xsl:variable> |
| 573 |
|
| 574 |
<!-- Vertical cell alignment --> |
| 575 |
<xsl:variable name="valign"> |
| 576 |
<xsl:choose> |
| 577 |
<!-- Entry element attribute first --> |
| 578 |
<xsl:when test="string(@valign)"> |
| 579 |
<xsl:value-of select="@valign"/> |
| 580 |
</xsl:when> |
| 581 |
<!-- Then parent row --> |
| 582 |
<xsl:when test="../@valign"> |
| 583 |
<xsl:value-of select="../@valign"/> |
| 584 |
</xsl:when> |
| 585 |
<!-- Then parent tbody|thead --> |
| 586 |
<xsl:when test="../../@valign"> |
| 587 |
<xsl:value-of select="../../@valign"/> |
| 588 |
</xsl:when> |
| 589 |
</xsl:choose> |
| 590 |
</xsl:variable> |
| 591 |
|
| 592 |
<xsl:variable name="cellcolor"> |
| 593 |
<xsl:call-template name="pi.dblatex_bgcolor"/> |
| 594 |
</xsl:variable> |
| 595 |
|
| 596 |
<xsl:variable name="bgcolor"> |
| 597 |
<xsl:choose> |
| 598 |
<xsl:when test="$cellcolor != ''"> |
| 599 |
<xsl:value-of select="$cellcolor"/> |
| 600 |
</xsl:when> |
| 601 |
<xsl:when test="$rowcolor != ''"> |
| 602 |
<xsl:value-of select="$rowcolor"/> |
| 603 |
</xsl:when> |
| 604 |
<xsl:when test="$colspec/colspec[@colnum=$colstart]/@bgcolor"> |
| 605 |
<xsl:value-of select="$colspec/colspec[@colnum=$colstart]/@bgcolor"/> |
| 606 |
</xsl:when> |
| 607 |
<xsl:when test="ancestor::*[self::table or self::informaltable]/@bgcolor"> |
| 608 |
<xsl:value-of select="ancestor::*[self::table or |
| 609 |
self::informaltable]/@bgcolor"/> |
| 610 |
</xsl:when> |
| 611 |
</xsl:choose> |
| 612 |
</xsl:variable> |
| 613 |
|
| 614 |
<xsl:copy> |
| 615 |
<xsl:for-each select="@*"><xsl:copy/></xsl:for-each> |
| 616 |
<xsl:attribute name="colstart"> |
| 617 |
<xsl:value-of select="$colstart"/> |
| 618 |
</xsl:attribute> |
| 619 |
<xsl:attribute name="colend"> |
| 620 |
<xsl:value-of select="$colend"/> |
| 621 |
</xsl:attribute> |
| 622 |
<xsl:attribute name="coloff"> |
| 623 |
<xsl:value-of select="$coloff"/> |
| 624 |
</xsl:attribute> |
| 625 |
<xsl:attribute name="rowstart"> |
| 626 |
<xsl:value-of select="$rownum"/> |
| 627 |
</xsl:attribute> |
| 628 |
<xsl:attribute name="rowend"> |
| 629 |
<xsl:choose> |
| 630 |
<xsl:when test="@morerows and @morerows > 0"> |
| 631 |
<xsl:value-of select="@morerows + $rownum"/> |
| 632 |
</xsl:when> |
| 633 |
<xsl:otherwise> |
| 634 |
<xsl:value-of select="$rownum"/> |
| 635 |
</xsl:otherwise> |
| 636 |
</xsl:choose> |
| 637 |
</xsl:attribute> |
| 638 |
<xsl:attribute name="colsep"> |
| 639 |
<xsl:value-of select="$colsep"/> |
| 640 |
</xsl:attribute> |
| 641 |
<xsl:attribute name="defrowsep"> |
| 642 |
<xsl:value-of select="$defrowsep"/> |
| 643 |
</xsl:attribute> |
| 644 |
<xsl:attribute name="align"> |
| 645 |
<xsl:value-of select="$align"/> |
| 646 |
</xsl:attribute> |
| 647 |
<xsl:attribute name="valign"> |
| 648 |
<xsl:value-of select="$valign"/> |
| 649 |
</xsl:attribute> |
| 650 |
<xsl:if test="$bgcolor != ''"> |
| 651 |
<xsl:attribute name="bgcolor"> |
| 652 |
<xsl:value-of select="$bgcolor"/> |
| 653 |
</xsl:attribute> |
| 654 |
</xsl:if> |
| 655 |
<xsl:attribute name="tabletype"> |
| 656 |
<xsl:value-of select="$tabletype"/> |
| 657 |
</xsl:attribute> |
| 658 |
<!-- Process the output here, to stay in the document context. --> |
| 659 |
<!-- In RTF entries the document links/refs are lost --> |
| 660 |
<xsl:element name="output"> |
| 661 |
<xsl:apply-templates select="." mode="output"/> |
| 662 |
</xsl:element> |
| 663 |
</xsl:copy> |
| 664 |
|
| 665 |
<!-- See if we've run out of entries for the current row --> |
| 666 |
<xsl:if test="$colend < $cols and |
| 667 |
not(following-sibling::*[self::entry or self::entrytbl][1])"> |
| 668 |
<!-- Create more blank entries to pad the row --> |
| 669 |
<xsl:call-template name="tbl.blankentry"> |
| 670 |
<xsl:with-param name="colnum" select="$colend + 1"/> |
| 671 |
<xsl:with-param name="colend" select="$cols"/> |
| 672 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 673 |
<xsl:with-param name="rownum" select="$rownum"/> |
| 674 |
<xsl:with-param name="rowcolor" select="$rowcolor"/> |
| 675 |
<xsl:with-param name="entries" select="$entries"/> |
| 676 |
<xsl:with-param name="tabletype" select="$tabletype"/> |
| 677 |
</xsl:call-template> |
| 678 |
</xsl:if> |
| 679 |
|
| 680 |
<xsl:apply-templates mode="newtbl.buildentries" |
| 681 |
select="following-sibling::*[self::entry or self::entrytbl][1]"> |
| 682 |
<xsl:with-param name="colnum" select="$colend + 1"/> |
| 683 |
<xsl:with-param name="rownum" select="$rownum"/> |
| 684 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 685 |
<xsl:with-param name="spanspec" select="$spanspec"/> |
| 686 |
<xsl:with-param name="frame" select="$frame"/> |
| 687 |
<xsl:with-param name="rowcolor" select="$rowcolor"/> |
| 688 |
<xsl:with-param name="entries" select="$entries"/> |
| 689 |
<xsl:with-param name="tabletype" select="$tabletype"/> |
| 690 |
</xsl:apply-templates> |
| 691 |
</xsl:otherwise></xsl:choose> |
| 692 |
</xsl:if> <!-- $colnum <= $cols --> |
| 693 |
</xsl:template> |
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
<!-- Output the current entry node --> |
| 698 |
<xsl:template match="entry|entrytbl" mode="newtbl"> |
| 699 |
<xsl:param name="colspec"/> |
| 700 |
<xsl:param name="context"/> |
| 701 |
<xsl:param name="frame"/> |
| 702 |
<xsl:param name="rownum"/> |
| 703 |
|
| 704 |
<xsl:variable name="cols" select="count($colspec/*)"/> |
| 705 |
<!-- |
| 706 |
<xsl:if test="@colstart > $cols"> |
| 707 |
<xsl:message>BANG</xsl:message> |
| 708 |
</xsl:if> |
| 709 |
--> |
| 710 |
<xsl:if test="@colstart <= $cols"> |
| 711 |
|
| 712 |
<!-- Should this column be sized by latex? --> |
| 713 |
<xsl:variable name="autowidth" |
| 714 |
select="$colspec/colspec[@colnum=current()/@colstart]/@autowidth"/> |
| 715 |
|
| 716 |
<xsl:variable name="moreprint" |
| 717 |
select="not($autowidth and (@rowstart != $rownum))"/> |
| 718 |
|
| 719 |
<!-- Generate the column spec for this column --> |
| 720 |
<xsl:text>\multicolumn{</xsl:text> |
| 721 |
<xsl:value-of select="@colend - @colstart + 1"/> |
| 722 |
<xsl:text>}{</xsl:text> |
| 723 |
<xsl:apply-templates select="." mode="tbl.colfmt"> |
| 724 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 725 |
<xsl:with-param name="frame" select="$frame"/> |
| 726 |
<xsl:with-param name="autowidth" select="$autowidth"/> |
| 727 |
</xsl:apply-templates> |
| 728 |
<xsl:text>}{</xsl:text> |
| 729 |
|
| 730 |
<!-- Put everything inside a multirow if required --> |
| 731 |
<xsl:if test="@morerows and @morerows > 0 and $moreprint"> |
| 732 |
<!-- Multirow doesn't use setlength and hence our calc stuff doesn't --> |
| 733 |
<!-- work. Do it manually then --> |
| 734 |
<xsl:if test="not($autowidth)"> |
| 735 |
<xsl:text>\setlength{\newtblcolwidth}{</xsl:text> |
| 736 |
<!-- Put the column width here for line wrapping --> |
| 737 |
<xsl:call-template name="tbl.colwidth"> |
| 738 |
<xsl:with-param name="col" select="@colstart"/> |
| 739 |
<xsl:with-param name="colend" select="@colend"/> |
| 740 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 741 |
</xsl:call-template> |
| 742 |
<xsl:text>}</xsl:text> |
| 743 |
</xsl:if> |
| 744 |
<xsl:text>\multirowii</xsl:text> |
| 745 |
|
| 746 |
<!-- Vertical alignment done by custom multirow --> |
| 747 |
<xsl:if test="@valign and @valign!=''"> |
| 748 |
<xsl:choose> |
| 749 |
<xsl:when test="@valign = 'top'"><xsl:text>[p]</xsl:text></xsl:when> |
| 750 |
<xsl:when test="@valign = 'bottom'"><xsl:text>[b]</xsl:text></xsl:when> |
| 751 |
<xsl:otherwise><xsl:text>[m]</xsl:text></xsl:otherwise> |
| 752 |
</xsl:choose> |
| 753 |
</xsl:if> |
| 754 |
|
| 755 |
<xsl:text>{</xsl:text> |
| 756 |
<xsl:value-of select="@morerows + 1"/> |
| 757 |
<xsl:choose> |
| 758 |
<xsl:when test="not($autowidth)"> |
| 759 |
<xsl:text>}{</xsl:text> |
| 760 |
<!-- Only output the contents of this row if it's on the correct --> |
| 761 |
<!-- row -ve width means don't output the cell contents, but maybe --> |
| 762 |
<!-- just output a height spacer. --> |
| 763 |
<xsl:if test="@rowstart != $rownum"> |
| 764 |
<xsl:text>-</xsl:text> |
| 765 |
</xsl:if> |
| 766 |
<xsl:text>\newtblcolwidth}{</xsl:text> |
| 767 |
</xsl:when> |
| 768 |
<xsl:otherwise> |
| 769 |
<xsl:text>}{*}{</xsl:text> |
| 770 |
</xsl:otherwise> |
| 771 |
</xsl:choose> |
| 772 |
</xsl:if> |
| 773 |
|
| 774 |
<!-- Do rotate if required. What to do about line wrapping though?? --> |
| 775 |
<xsl:if test="@rotate and @rotate != 0"> |
| 776 |
<xsl:text>\rotatebox{90}{</xsl:text> |
| 777 |
</xsl:if> |
| 778 |
|
| 779 |
<xsl:if test="not($autowidth)"> |
| 780 |
<xsl:choose> |
| 781 |
<xsl:when test="@align = 'left'"> |
| 782 |
<xsl:text>\raggedright</xsl:text> |
| 783 |
</xsl:when> |
| 784 |
<xsl:when test="@align = 'right'"> |
| 785 |
<xsl:text>\raggedleft</xsl:text> |
| 786 |
</xsl:when> |
| 787 |
<xsl:when test="@align = 'center'"> |
| 788 |
<xsl:text>\centering</xsl:text> |
| 789 |
</xsl:when> |
| 790 |
<xsl:when test="@align = 'justify'"></xsl:when> |
| 791 |
<xsl:when test="@align != ''"> |
| 792 |
<xsl:message>Word-wrapped alignment <xsl:value-of |
| 793 |
select="@align"/> not supported</xsl:message> |
| 794 |
</xsl:when> |
| 795 |
</xsl:choose> |
| 796 |
</xsl:if> |
| 797 |
|
| 798 |
<!-- Apply some default formatting depending on context --> |
| 799 |
<xsl:choose> |
| 800 |
<xsl:when test="$context = 'thead'"> |
| 801 |
<xsl:value-of select="$newtbl.format.thead"/> |
| 802 |
</xsl:when> |
| 803 |
<xsl:when test="$context = 'tbody'"> |
| 804 |
<xsl:value-of select="$newtbl.format.tbody"/> |
| 805 |
</xsl:when> |
| 806 |
<xsl:when test="$context = 'tfoot'"> |
| 807 |
<xsl:value-of select="$newtbl.format.tfoot"/> |
| 808 |
</xsl:when> |
| 809 |
<xsl:otherwise> |
| 810 |
<xsl:message>Unknown context <xsl:value-of select="$context"/> |
| 811 |
</xsl:message> |
| 812 |
</xsl:otherwise> |
| 813 |
</xsl:choose> |
| 814 |
|
| 815 |
<!-- Dump out the entry contents --> |
| 816 |
<xsl:if test="$moreprint"> |
| 817 |
<xsl:text>% </xsl:text> |
| 818 |
<xsl:choose> |
| 819 |
<xsl:when test="output"> |
| 820 |
<xsl:value-of select="output"/> |
| 821 |
</xsl:when> |
| 822 |
<xsl:otherwise> |
| 823 |
<xsl:apply-templates select="." mode="output"/> |
| 824 |
</xsl:otherwise> |
| 825 |
</xsl:choose> |
| 826 |
<xsl:text>% </xsl:text> |
| 827 |
</xsl:if> |
| 828 |
|
| 829 |
<!-- Close off multirow if required --> |
| 830 |
<xsl:if test="@morerows and @morerows > 0 and $moreprint"> |
| 831 |
<xsl:text>}</xsl:text> |
| 832 |
</xsl:if> |
| 833 |
|
| 834 |
<!-- Close off rotate if required --> |
| 835 |
<xsl:if test="@rotate and @rotate != 0"> |
| 836 |
<xsl:text>}</xsl:text> |
| 837 |
</xsl:if> |
| 838 |
|
| 839 |
<!-- End of the multicolumn --> |
| 840 |
<xsl:text>}</xsl:text> |
| 841 |
|
| 842 |
<!-- Put in the column separator --> |
| 843 |
<xsl:if test="@colend != $cols"> |
| 844 |
<xsl:text>&</xsl:text> |
| 845 |
</xsl:if> |
| 846 |
|
| 847 |
</xsl:if> <!-- colstart > cols --> |
| 848 |
|
| 849 |
</xsl:template> |
| 850 |
|
| 851 |
|
| 852 |
<!-- Process the entry content, and remove spurious empty lines --> |
| 853 |
<xsl:template match="entry" mode="output"> |
| 854 |
<xsl:call-template name="normalize-border"> |
| 855 |
<xsl:with-param name="string"> |
| 856 |
<xsl:apply-templates/> |
| 857 |
</xsl:with-param> |
| 858 |
</xsl:call-template> |
| 859 |
</xsl:template> |
| 860 |
|
| 861 |
|
| 862 |
<!-- Actually build the embedded table like tgroup does --> |
| 863 |
<xsl:template match="entrytbl" mode="output"> |
| 864 |
<xsl:call-template name="tgroup"> |
| 865 |
<xsl:with-param name="tablewidth" select="'\linewidth-2\arrayrulewidth'"/> |
| 866 |
<xsl:with-param name="tableframe" select="'none'"/> |
| 867 |
</xsl:call-template> |
| 868 |
</xsl:template> |
| 869 |
|
| 870 |
|
| 871 |
<!-- Rowsep building using \cline - done within a row --> |
| 872 |
<xsl:template name="clines.build"> |
| 873 |
<xsl:param name="entries"/> |
| 874 |
<xsl:param name="rownum"/> |
| 875 |
|
| 876 |
<!-- Store any rowsep for this row --> |
| 877 |
<xsl:variable name="thisrowsep" select="@rowsep"/> |
| 878 |
|
| 879 |
<xsl:for-each select="$entries/*"> |
| 880 |
<!-- Only do rowsep for this col if it's not spanning this row --> |
| 881 |
<xsl:if test="@rowend = $rownum"> |
| 882 |
<xsl:variable name="dorowsep"> |
| 883 |
<xsl:choose> |
| 884 |
<!-- Entry rowsep override --> |
| 885 |
<xsl:when test="@rowsep"> |
| 886 |
<xsl:value-of select="@rowsep"/> |
| 887 |
</xsl:when> |
| 888 |
<!-- Row rowsep override --> |
| 889 |
<xsl:when test="$thisrowsep"> |
| 890 |
<xsl:value-of select="$thisrowsep"/> |
| 891 |
</xsl:when> |
| 892 |
<!-- Else use the default for this column --> |
| 893 |
<xsl:otherwise> |
| 894 |
<xsl:value-of select="@defrowsep"/> |
| 895 |
</xsl:otherwise> |
| 896 |
</xsl:choose> |
| 897 |
</xsl:variable> |
| 898 |
<xsl:if test="$dorowsep = 1"> |
| 899 |
<xsl:text>\cline{</xsl:text> |
| 900 |
<xsl:value-of select="@colstart"/> |
| 901 |
<xsl:text>-</xsl:text> |
| 902 |
<xsl:value-of select="@colend"/> |
| 903 |
<xsl:text>}</xsl:text> |
| 904 |
</xsl:if> |
| 905 |
</xsl:if> |
| 906 |
</xsl:for-each> |
| 907 |
</xsl:template> |
| 908 |
|
| 909 |
<!-- Rowsep building using \hhline - done within a row --> |
| 910 |
<xsl:template name="hhline.build"> |
| 911 |
<xsl:param name="entries"/> |
| 912 |
<xsl:param name="rownum"/> |
| 913 |
|
| 914 |
<!-- Store any rowsep for this row --> |
| 915 |
<xsl:variable name="thisrowsep" select="@rowsep"/> |
| 916 |
|
| 917 |
<xsl:text>\hhline{</xsl:text> |
| 918 |
<xsl:for-each select="$entries/*"> |
| 919 |
<xsl:variable name="dorowsep"> |
| 920 |
<xsl:choose> |
| 921 |
<!-- Only do rowsep for this col if it's not spanning this row --> |
| 922 |
<xsl:when test="@rowend != $rownum"> |
| 923 |
<xsl:value-of select="0"/> |
| 924 |
</xsl:when> |
| 925 |
<!-- Entry rowsep override --> |
| 926 |
<xsl:when test="@rowsep"> |
| 927 |
<xsl:value-of select="@rowsep"/> |
| 928 |
</xsl:when> |
| 929 |
<!-- Row rowsep override --> |
| 930 |
<xsl:when test="$thisrowsep"> |
| 931 |
<xsl:value-of select="$thisrowsep"/> |
| 932 |
</xsl:when> |
| 933 |
<!-- Else use the default for this column --> |
| 934 |
<xsl:otherwise> |
| 935 |
<xsl:value-of select="@defrowsep"/> |
| 936 |
</xsl:otherwise> |
| 937 |
</xsl:choose> |
| 938 |
</xsl:variable> |
| 939 |
<!-- hhline separator value --> |
| 940 |
<xsl:variable name="hsep"> |
| 941 |
<xsl:choose> |
| 942 |
<xsl:when test="$dorowsep = 1">-</xsl:when> |
| 943 |
<xsl:otherwise>~</xsl:otherwise> |
| 944 |
</xsl:choose> |
| 945 |
</xsl:variable> |
| 946 |
<xsl:choose> |
| 947 |
<xsl:when test="@colstart = @colend"> |
| 948 |
<xsl:value-of select="$hsep"/> |
| 949 |
</xsl:when> |
| 950 |
<xsl:otherwise> |
| 951 |
<xsl:text>*{</xsl:text> |
| 952 |
<xsl:value-of select="@colend - @colstart + 1"/> |
| 953 |
<xsl:text>}{</xsl:text> |
| 954 |
<xsl:value-of select="$hsep"/> |
| 955 |
<xsl:text>}</xsl:text> |
| 956 |
</xsl:otherwise> |
| 957 |
</xsl:choose> |
| 958 |
</xsl:for-each> |
| 959 |
<xsl:text>}</xsl:text> |
| 960 |
</xsl:template> |
| 961 |
|
| 962 |
|
| 963 |
<!-- Process each row in turn --> |
| 964 |
<xsl:template match="row" mode="newtbl"> |
| 965 |
<xsl:param name="tabletype"/> |
| 966 |
<xsl:param name="rownum"/> |
| 967 |
<xsl:param name="rows"/> |
| 968 |
<xsl:param name="colspec"/> |
| 969 |
<xsl:param name="spanspec"/> |
| 970 |
<xsl:param name="frame"/> |
| 971 |
<xsl:param name="oldentries"><nop/></xsl:param> |
| 972 |
<xsl:param name="rowstack"/> |
| 973 |
|
| 974 |
<xsl:variable name="bgcolor.pi"> |
| 975 |
<xsl:call-template name="pi.dblatex_bgcolor"/> |
| 976 |
</xsl:variable> |
| 977 |
|
| 978 |
<xsl:variable name="rowcolor"> |
| 979 |
<xsl:choose> |
| 980 |
<xsl:when test="$bgcolor.pi!=''"> |
| 981 |
<xsl:value-of select="$bgcolor.pi"/> |
| 982 |
</xsl:when> |
| 983 |
<xsl:when test="ancestor::thead"> |
| 984 |
<xsl:value-of select="$newtbl.bgcolor.thead"/> |
| 985 |
</xsl:when> |
| 986 |
</xsl:choose> |
| 987 |
</xsl:variable> |
| 988 |
|
| 989 |
<!-- Build the entry node-set --> |
| 990 |
<xsl:variable name="entries"> |
| 991 |
<xsl:choose> |
| 992 |
<xsl:when test="(entry|entrytbl)[1]"> |
| 993 |
<xsl:apply-templates mode="newtbl.buildentries" select="(entry|entrytbl)[1]"> |
| 994 |
<xsl:with-param name="colnum" select="1"/> |
| 995 |
<xsl:with-param name="rownum" select="$rownum"/> |
| 996 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 997 |
<xsl:with-param name="spanspec" select="$spanspec"/> |
| 998 |
<xsl:with-param name="frame" select="$frame"/> |
| 999 |
<xsl:with-param name="rowcolor" select="$rowcolor"/> |
| 1000 |
<xsl:with-param name="entries" select="exsl:node-set($oldentries)"/> |
| 1001 |
<xsl:with-param name="tabletype" select="$tabletype"/> |
| 1002 |
</xsl:apply-templates> |
| 1003 |
</xsl:when> |
| 1004 |
<xsl:otherwise> |
| 1005 |
<xsl:copy-of select="exsl:node-set($oldentries)"/> |
| 1006 |
</xsl:otherwise> |
| 1007 |
</xsl:choose> |
| 1008 |
</xsl:variable> |
| 1009 |
|
| 1010 |
<!-- Now output each entry --> |
| 1011 |
<xsl:variable name="context" select="local-name(..)"/> |
| 1012 |
<xsl:variable name="row-output"> |
| 1013 |
<xsl:if test="$context = 'thead'"> |
| 1014 |
<xsl:value-of select="$rowstack"/> |
| 1015 |
</xsl:if> |
| 1016 |
|
| 1017 |
<xsl:if test="$rownum = 1"> |
| 1018 |
<!-- Need a top line? --> |
| 1019 |
<xsl:if test="$frame = 'all' or $frame = 'top' or $frame = 'topbot'"> |
| 1020 |
<xsl:text>\hline</xsl:text> |
| 1021 |
</xsl:if> |
| 1022 |
<xsl:text> </xsl:text> |
| 1023 |
</xsl:if> |
| 1024 |
|
| 1025 |
<xsl:apply-templates select="exsl:node-set($entries)/*" mode="newtbl"> |
| 1026 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 1027 |
<xsl:with-param name="frame" select="$frame"/> |
| 1028 |
<xsl:with-param name="context" select="$context"/> |
| 1029 |
<xsl:with-param name="rownum" select="$rownum"/> |
| 1030 |
</xsl:apply-templates> |
| 1031 |
|
| 1032 |
<!-- End this row --> |
| 1033 |
<xsl:text>\tabularnewline </xsl:text> |
| 1034 |
|
| 1035 |
<!-- Now process rowseps only if not the last row --> |
| 1036 |
<xsl:if test="$rownum != $rows"> |
| 1037 |
<xsl:choose> |
| 1038 |
<xsl:when test="$newtbl.use.hhline='1'"> |
| 1039 |
<xsl:call-template name="hhline.build"> |
| 1040 |
<xsl:with-param name="entries" select="exsl:node-set($entries)"/> |
| 1041 |
<xsl:with-param name="rownum" select="$rownum"/> |
| 1042 |
</xsl:call-template> |
| 1043 |
</xsl:when> |
| 1044 |
<xsl:otherwise> |
| 1045 |
<xsl:call-template name="clines.build"> |
| 1046 |
<xsl:with-param name="entries" select="exsl:node-set($entries)"/> |
| 1047 |
<xsl:with-param name="rownum" select="$rownum"/> |
| 1048 |
</xsl:call-template> |
| 1049 |
</xsl:otherwise> |
| 1050 |
</xsl:choose> |
| 1051 |
</xsl:if> |
| 1052 |
</xsl:variable> |
| 1053 |
|
| 1054 |
<!-- Head rows must be buffered --> |
| 1055 |
<xsl:if test="$context != 'thead'"> |
| 1056 |
<xsl:value-of select="$row-output"/> |
| 1057 |
</xsl:if> |
| 1058 |
|
| 1059 |
<xsl:choose> |
| 1060 |
<xsl:when test="following-sibling::row[1]"> |
| 1061 |
<xsl:apply-templates mode="newtbl" select="following-sibling::row[1]"> |
| 1062 |
<xsl:with-param name="tabletype" select="$tabletype"/> |
| 1063 |
<xsl:with-param name="rownum" select="$rownum + 1"/> |
| 1064 |
<xsl:with-param name="rows" select="$rows"/> |
| 1065 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 1066 |
<xsl:with-param name="spanspec" select="$spanspec"/> |
| 1067 |
<xsl:with-param name="frame" select="$frame"/> |
| 1068 |
<xsl:with-param name="oldentries" select="$entries"/> |
| 1069 |
<xsl:with-param name="rowstack" select="$row-output"/> |
| 1070 |
</xsl:apply-templates> |
| 1071 |
</xsl:when> |
| 1072 |
<xsl:when test="$context = 'tfoot'"> |
| 1073 |
</xsl:when> |
| 1074 |
<xsl:otherwise> |
| 1075 |
<!-- Ask to table to end the head --> |
| 1076 |
<xsl:if test="$context = 'thead'"> |
| 1077 |
<xsl:apply-templates select="(ancestor::table |
| 1078 |
|ancestor::informaltable)[last()]" |
| 1079 |
mode="newtbl.endhead"> |
| 1080 |
<xsl:with-param name="tabletype" select="$tabletype"/> |
| 1081 |
<xsl:with-param name="headrows" select="$row-output"/> |
| 1082 |
</xsl:apply-templates> |
| 1083 |
</xsl:if> |
| 1084 |
|
| 1085 |
<xsl:apply-templates mode="newtbl" |
| 1086 |
select="(../following-sibling::tbody/row)[1]"> |
| 1087 |
<xsl:with-param name="tabletype" select="$tabletype"/> |
| 1088 |
<xsl:with-param name="rownum" select="$rownum + 1"/> |
| 1089 |
<xsl:with-param name="rows" select="$rows"/> |
| 1090 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 1091 |
<xsl:with-param name="spanspec" select="$spanspec"/> |
| 1092 |
<xsl:with-param name="frame" select="$frame"/> |
| 1093 |
<xsl:with-param name="oldentries" select="$entries"/> |
| 1094 |
</xsl:apply-templates> |
| 1095 |
</xsl:otherwise> |
| 1096 |
</xsl:choose> |
| 1097 |
</xsl:template> |
| 1098 |
|
| 1099 |
|
| 1100 |
|
| 1101 |
<!-- Calculate column width between two columns --> |
| 1102 |
<xsl:template name="tbl.colwidth"> |
| 1103 |
<xsl:param name="col"/> |
| 1104 |
<xsl:param name="colend"/> |
| 1105 |
<xsl:param name="colspec"/> |
| 1106 |
|
| 1107 |
<xsl:value-of select="$colspec/colspec[@colnum=$col]/@colwidth"/> |
| 1108 |
|
| 1109 |
<xsl:if test="$col < $colend"> |
| 1110 |
<xsl:text>+2\tabcolsep+\arrayrulewidth+</xsl:text> |
| 1111 |
<xsl:call-template name="tbl.colwidth"> |
| 1112 |
<xsl:with-param name="col" select="$col + 1"/> |
| 1113 |
<xsl:with-param name="colend" select="$colend"/> |
| 1114 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 1115 |
</xsl:call-template> |
| 1116 |
</xsl:if> |
| 1117 |
</xsl:template> |
| 1118 |
|
| 1119 |
<xsl:template name="tbl.colwidth2"> |
| 1120 |
<xsl:param name="col"/> |
| 1121 |
<xsl:param name="colend"/> |
| 1122 |
<xsl:param name="colspec"/> |
| 1123 |
|
| 1124 |
<xsl:value-of select="$colspec/colspec[@colnum=$col]/@fixedwidth"/> |
| 1125 |
|
| 1126 |
<xsl:if test="$col < $colend"> |
| 1127 |
<xsl:text>+</xsl:text> |
| 1128 |
<xsl:call-template name="tbl.colwidth2"> |
| 1129 |
<xsl:with-param name="col" select="$col + 1"/> |
| 1130 |
<xsl:with-param name="colend" select="$colend"/> |
| 1131 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 1132 |
</xsl:call-template> |
| 1133 |
</xsl:if> |
| 1134 |
</xsl:template> |
| 1135 |
|
| 1136 |
|
| 1137 |
<xsl:template match="entry|entrytbl" mode="width.colfmt"> |
| 1138 |
<xsl:param name="colspec"/> |
| 1139 |
<xsl:param name="color"/> |
| 1140 |
<xsl:param name="rsep"/> |
| 1141 |
|
| 1142 |
<!-- Color in pre-command --> |
| 1143 |
<xsl:if test="$color != ''"> |
| 1144 |
<xsl:value-of select="concat('>{',$color,'}')"/> |
| 1145 |
</xsl:if> |
| 1146 |
|
| 1147 |
<!-- Get the column width --> |
| 1148 |
<xsl:variable name="width"> |
| 1149 |
<xsl:call-template name="tbl.colwidth"> |
| 1150 |
<xsl:with-param name="col" select="@colstart"/> |
| 1151 |
<xsl:with-param name="colend" select="@colend"/> |
| 1152 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 1153 |
</xsl:call-template> |
| 1154 |
<xsl:if test="$rsep = ''"> |
| 1155 |
<xsl:text>+\arrayrulewidth</xsl:text> |
| 1156 |
</xsl:if> |
| 1157 |
<xsl:if test="@coloff = 0"> |
| 1158 |
<xsl:text>+2\tabcolsep</xsl:text> |
| 1159 |
</xsl:if> |
| 1160 |
</xsl:variable> |
| 1161 |
|
| 1162 |
<xsl:choose> |
| 1163 |
<xsl:when test="@valign = 'top'"> |
| 1164 |
<xsl:text>p</xsl:text> |
| 1165 |
</xsl:when> |
| 1166 |
<xsl:when test="@valign = 'bottom'"> |
| 1167 |
<xsl:text>b</xsl:text> |
| 1168 |
</xsl:when> |
| 1169 |
<xsl:otherwise> |
| 1170 |
<xsl:text>m</xsl:text> |
| 1171 |
</xsl:otherwise> |
| 1172 |
</xsl:choose> |
| 1173 |
|
| 1174 |
<xsl:text>{</xsl:text> |
| 1175 |
<xsl:value-of select="$width"/> |
| 1176 |
<xsl:text>}</xsl:text> |
| 1177 |
</xsl:template> |
| 1178 |
|
| 1179 |
<xsl:template match="entry|entrytbl" mode="widthx.colfmt"> |
| 1180 |
<xsl:param name="colspec"/> |
| 1181 |
<xsl:param name="color"/> |
| 1182 |
|
| 1183 |
<xsl:variable name="stars" |
| 1184 |
select="sum(exsl:node-set($colspec)/colspec |
| 1185 |
[@colnum >= current()/@colstart and |
| 1186 |
@colnum <= current()/@colend]/@star)"/> |
| 1187 |
|
| 1188 |
<!-- Get the column fixed width part --> |
| 1189 |
<xsl:variable name="width"> |
| 1190 |
<xsl:call-template name="tbl.colwidth2"> |
| 1191 |
<xsl:with-param name="col" select="@colstart"/> |
| 1192 |
<xsl:with-param name="colend" select="@colend"/> |
| 1193 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 1194 |
</xsl:call-template> |
| 1195 |
</xsl:variable> |
| 1196 |
|
| 1197 |
<xsl:choose> |
| 1198 |
<xsl:when test="$stars = 0"> |
| 1199 |
<xsl:if test="$color != ''"> |
| 1200 |
<xsl:value-of select="concat('>{',$color,'}')"/> |
| 1201 |
</xsl:if> |
| 1202 |
<!-- Only a fixed width --> |
| 1203 |
<xsl:choose> |
| 1204 |
<xsl:when test="@valign = 'top'"> |
| 1205 |
<xsl:text>p</xsl:text> |
| 1206 |
</xsl:when> |
| 1207 |
<xsl:when test="@valign = 'bottom'"> |
| 1208 |
<xsl:text>b</xsl:text> |
| 1209 |
</xsl:when> |
| 1210 |
<xsl:otherwise> |
| 1211 |
<xsl:text>m</xsl:text> |
| 1212 |
</xsl:otherwise> |
| 1213 |
</xsl:choose> |
| 1214 |
|
| 1215 |
<xsl:text>{</xsl:text> |
| 1216 |
<xsl:value-of select="$width"/> |
| 1217 |
<xsl:text>}</xsl:text> |
| 1218 |
</xsl:when> |
| 1219 |
<xsl:otherwise> |
| 1220 |
<xsl:text>>{</xsl:text> |
| 1221 |
<xsl:value-of select="$color"/> |
| 1222 |
<xsl:text>\setlength\hsize{</xsl:text> |
| 1223 |
<xsl:if test="$width != ''"> |
| 1224 |
<xsl:value-of select="$width"/> |
| 1225 |
<xsl:text>+</xsl:text> |
| 1226 |
</xsl:if> |
| 1227 |
<xsl:value-of select="$stars"/> |
| 1228 |
<xsl:text>\hsize}}X</xsl:text> |
| 1229 |
</xsl:otherwise> |
| 1230 |
</xsl:choose> |
| 1231 |
</xsl:template> |
| 1232 |
|
| 1233 |
|
| 1234 |
<!-- Convert a frame tag to a CALS frame equivalent --> |
| 1235 |
<xsl:template name="cals.frame"> |
| 1236 |
<xsl:param name="frame"/> |
| 1237 |
|
| 1238 |
<xsl:choose> |
| 1239 |
<xsl:when test="$frame='void'">none</xsl:when> |
| 1240 |
<xsl:when test="$frame='above'">top</xsl:when> |
| 1241 |
<xsl:when test="$frame='below'">bottom</xsl:when> |
| 1242 |
<xsl:when test="$frame='hsides'">topbot</xsl:when> |
| 1243 |
<xsl:when test="$frame='vsides'">sides</xsl:when> |
| 1244 |
<xsl:when test="$frame='box'">all</xsl:when> |
| 1245 |
<xsl:when test="$frame='border'">all</xsl:when> |
| 1246 |
<xsl:otherwise> |
| 1247 |
<xsl:value-of select="$frame"/> |
| 1248 |
</xsl:otherwise> |
| 1249 |
</xsl:choose> |
| 1250 |
</xsl:template> |
| 1251 |
|
| 1252 |
|
| 1253 |
<!-- Generate a latex column specifier, possibly surrounded by '|' --> |
| 1254 |
<xsl:template match="entry|entrytbl" mode="tbl.colfmt"> |
| 1255 |
<xsl:param name="frame"/> |
| 1256 |
<xsl:param name="colspec"/> |
| 1257 |
<xsl:param name="autowidth"/> |
| 1258 |
|
| 1259 |
<xsl:variable name="cols" select="count($colspec/*)"/> |
| 1260 |
|
| 1261 |
<!-- Need a colsep to the left? - only if first column and frame says so --> |
| 1262 |
<xsl:if test="@colstart = 1 and ($frame = 'all' or $frame = 'sides')"> |
| 1263 |
<xsl:text>|</xsl:text> |
| 1264 |
</xsl:if> |
| 1265 |
|
| 1266 |
<!-- Need a colsep to the right? - only if last column and frame says --> |
| 1267 |
<!-- so, or we are not the last column and colsep says so --> |
| 1268 |
<xsl:variable name="rsep"> |
| 1269 |
<xsl:if test="(@colend = $cols and ($frame = 'all' or $frame = 'sides')) or |
| 1270 |
(@colend != $cols and @colsep = 1)"> |
| 1271 |
<xsl:text>|</xsl:text> |
| 1272 |
</xsl:if> |
| 1273 |
</xsl:variable> |
| 1274 |
|
| 1275 |
<!-- Remove the offset between column and cell content? --> |
| 1276 |
<xsl:if test="@coloff = 0"> |
| 1277 |
<xsl:text>@{}</xsl:text> |
| 1278 |
</xsl:if> |
| 1279 |
|
| 1280 |
<!-- Column color? --> |
| 1281 |
<xsl:variable name="color"> |
| 1282 |
<xsl:if test="@bgcolor != ''"> |
| 1283 |
<xsl:text>\columncolor</xsl:text> |
| 1284 |
<xsl:call-template name="get-color"> |
| 1285 |
<xsl:with-param name="color" select="@bgcolor"/> |
| 1286 |
</xsl:call-template> |
| 1287 |
</xsl:if> |
| 1288 |
</xsl:variable> |
| 1289 |
|
| 1290 |
<xsl:choose> |
| 1291 |
<xsl:when test="not($autowidth)"> |
| 1292 |
<xsl:choose> |
| 1293 |
<xsl:when test="@tabletype = 'tabularx'"> |
| 1294 |
<xsl:apply-templates select="." mode="widthx.colfmt"> |
| 1295 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 1296 |
<xsl:with-param name="color" select="$color"/> |
| 1297 |
</xsl:apply-templates> |
| 1298 |
</xsl:when> |
| 1299 |
<xsl:otherwise> |
| 1300 |
<xsl:apply-templates select="." mode="width.colfmt"> |
| 1301 |
<xsl:with-param name="colspec" select="$colspec"/> |
| 1302 |
<xsl:with-param name="color" select="$color"/> |
| 1303 |
<xsl:with-param name="rsep" select="$rsep"/> |
| 1304 |
</xsl:apply-templates> |
| 1305 |
</xsl:otherwise> |
| 1306 |
</xsl:choose> |
| 1307 |
</xsl:when> |
| 1308 |
<xsl:otherwise> |
| 1309 |
<xsl:if test="$color != ''"> |
| 1310 |
<xsl:value-of select="concat('>{',$color,'}')"/> |
| 1311 |
</xsl:if> |
| 1312 |
<xsl:choose> |
| 1313 |
<xsl:when test="@align = 'left'">l</xsl:when> |
| 1314 |
<xsl:when test="@align = 'right'">r</xsl:when> |
| 1315 |
<xsl:when test="@align = 'center'">c</xsl:when> |
| 1316 |
<xsl:otherwise>c</xsl:otherwise> |
| 1317 |
</xsl:choose> |
| 1318 |
</xsl:otherwise> |
| 1319 |
</xsl:choose> |
| 1320 |
|
| 1321 |
<xsl:if test="@coloff = 0"> |
| 1322 |
<xsl:text>@{}</xsl:text> |
| 1323 |
</xsl:if> |
| 1324 |
|
| 1325 |
<xsl:value-of select="$rsep"/> |
| 1326 |
</xsl:template> |
| 1327 |
|
| 1328 |
|
| 1329 |
<xsl:template name="table.width"> |
| 1330 |
<xsl:param name="fullwidth"/> |
| 1331 |
<xsl:param name="exclude"/> |
| 1332 |
|
| 1333 |
<xsl:variable name="piwidth"> |
| 1334 |
<xsl:call-template name="pi.dblatex_table-width"> |
| 1335 |
<xsl:with-param name="node" select=".."/> |
| 1336 |
</xsl:call-template> |
| 1337 |
</xsl:variable> |
| 1338 |
|
| 1339 |
<!-- precedence between table-widths specifications --> |
| 1340 |
<xsl:variable name="width"> |
| 1341 |
<xsl:choose> |
| 1342 |
<xsl:when test="$piwidth != '' and |
| 1343 |
($exclude='' or not(contains($piwidth,$exclude)))"> |
| 1344 |
<xsl:value-of select="$piwidth"/> |
| 1345 |
</xsl:when> |
| 1346 |
<xsl:when test="(@width or ../@width) and |
| 1347 |
($exclude='' or not(contains(../@width,$exclude)))"> |
| 1348 |
<xsl:value-of select="(@width|../@width)[last()]"/> |
| 1349 |
</xsl:when> |
| 1350 |
<xsl:when test="$default.table.width != '' and |
| 1351 |
($exclude='' or |
| 1352 |
not(contains($default.table.width,$exclude)))"> |
| 1353 |
<xsl:value-of select="$default.table.width"/> |
| 1354 |
</xsl:when> |
| 1355 |
<xsl:otherwise> |
| 1356 |
<xsl:value-of select="$fullwidth"/> |
| 1357 |
</xsl:otherwise> |
| 1358 |
</xsl:choose> |
| 1359 |
</xsl:variable> |
| 1360 |
|
| 1361 |
<!-- convert percentage to real width --> |
| 1362 |
<xsl:choose> |
| 1363 |
<xsl:when test="contains($width, '%')"> |
| 1364 |
<xsl:value-of select="number(substring-before($width, '%')) div 100"/> |
| 1365 |
<xsl:value-of select="$fullwidth"/> |
| 1366 |
</xsl:when> |
| 1367 |
<xsl:otherwise> |
| 1368 |
<xsl:value-of select="$width"/> |
| 1369 |
</xsl:otherwise> |
| 1370 |
</xsl:choose> |
| 1371 |
|
| 1372 |
</xsl:template> |
| 1373 |
|
| 1374 |
|
| 1375 |
<xsl:template name="tbl.sizes"> |
| 1376 |
<xsl:param name="colspec"/> |
| 1377 |
<xsl:param name="width"/> |
| 1378 |
|
| 1379 |
<!-- Now get latex to calculate the 'spare' width of the table --> |
| 1380 |
<!-- (Table width - widths of all specified columns - gaps between columns)--> |
| 1381 |
<xsl:text>\setlength{\newtblsparewidth}{</xsl:text> |
| 1382 |
<xsl:value-of select="$width"/> |
| 1383 |
<xsl:for-each select="$colspec/*"> |
| 1384 |
<xsl:if test="@fixedwidth"> |
| 1385 |
<xsl:text>-</xsl:text> |
| 1386 |
<xsl:value-of select="translate(@fixedwidth,'+','-')"/> |
| 1387 |
</xsl:if> |
| 1388 |
<xsl:text>-2\tabcolsep</xsl:text> |
| 1389 |
</xsl:for-each> |
| 1390 |
<xsl:text>}% </xsl:text> |
| 1391 |
|
| 1392 |
<!-- Now get latex to calculate widths of cols with starred colwidths --> |
| 1393 |
|
| 1394 |
<xsl:variable name="numunknown" |
| 1395 |
select="sum($colspec/colspec/@star)"/> |
| 1396 |
<!-- If we have at least one such col, then work out how wide it should --> |
| 1397 |
<!-- be --> |
| 1398 |
<xsl:if test="$numunknown > 0"> |
| 1399 |
<xsl:text>\setlength{\newtblstarfactor}{\newtblsparewidth / \real{</xsl:text> |
| 1400 |
<xsl:value-of select="$numunknown"/> |
| 1401 |
<xsl:text>}}% </xsl:text> |
| 1402 |
</xsl:if> |
| 1403 |
</xsl:template> |
| 1404 |
|
| 1405 |
|
| 1406 |
<!-- tabularx vertical alignment setup, global to the whole table --> |
| 1407 |
<xsl:template name="tbl.valign.x"> |
| 1408 |
<xsl:param name="valign"/> |
| 1409 |
|
| 1410 |
<xsl:variable name="valign.param"> |
| 1411 |
<xsl:choose> |
| 1412 |
<xsl:when test="$valign = 'top'"><xsl:text>p</xsl:text></xsl:when> |
| 1413 |
<xsl:when test="$valign = 'bottom'"><xsl:text>b</xsl:text></xsl:when> |
| 1414 |
<!-- default vertical alignment --> |
| 1415 |
<xsl:otherwise><xsl:text>m</xsl:text></xsl:otherwise> |
| 1416 |
</xsl:choose> |
| 1417 |
</xsl:variable> |
| 1418 |
|
| 1419 |
<xsl:text>\def\tabularxcolumn#1{</xsl:text> |
| 1420 |
<xsl:value-of select="$valign.param"/> |
| 1421 |
<xsl:text>{#1}}</xsl:text> |
| 1422 |
</xsl:template> |
| 1423 |
|
| 1424 |
|
| 1425 |
<xsl:template name="tbl.begin"> |
| 1426 |
<xsl:param name="colspec"/> |
| 1427 |
<xsl:param name="tabletype"/> |
| 1428 |
<xsl:param name="width"/> |
| 1429 |
|
| 1430 |
<xsl:text>\begin{</xsl:text> |
| 1431 |
<xsl:value-of select="$tabletype"/> |
| 1432 |
<xsl:text>}</xsl:text> |
| 1433 |
|
| 1434 |
<xsl:choose> |
| 1435 |
<xsl:when test="$tabletype = 'tabularx'"> |
| 1436 |
<xsl:text>{</xsl:text> |
| 1437 |
<xsl:value-of select="$width"/> |
| 1438 |
<xsl:text>}{</xsl:text> |
| 1439 |
<xsl:for-each select="$colspec/*"> |
| 1440 |
<xsl:choose> |
| 1441 |
<xsl:when test="@star"> |
| 1442 |
<xsl:text>>{\hsize=</xsl:text> |
| 1443 |
<xsl:if test="@fixedwidth"> |
| 1444 |
<xsl:value-of select="@fixedwidth"/> |
| 1445 |
<xsl:text>+</xsl:text> |
| 1446 |
</xsl:if> |
| 1447 |
<xsl:value-of select="@star"/> |
| 1448 |
<xsl:text>\hsize}X</xsl:text> |
| 1449 |
</xsl:when> |
| 1450 |
<xsl:otherwise> |
| 1451 |
<xsl:text>l</xsl:text> |
| 1452 |
</xsl:otherwise> |
| 1453 |
</xsl:choose> |
| 1454 |
</xsl:for-each> |
| 1455 |
<xsl:text>}</xsl:text> |
| 1456 |
</xsl:when> |
| 1457 |
<xsl:otherwise> |
| 1458 |
<xsl:text>{</xsl:text> |
| 1459 |
<!-- The initial column definition --> |
| 1460 |
<xsl:for-each select="$colspec/*"> |
| 1461 |
<xsl:text>l</xsl:text> |
| 1462 |
</xsl:for-each> |
| 1463 |
<xsl:text>}</xsl:text> |
| 1464 |
</xsl:otherwise> |
| 1465 |
</xsl:choose> |
| 1466 |
</xsl:template> |
| 1467 |
|
| 1468 |
|
| 1469 |
<!-- The main starting point of the table handling --> |
| 1470 |
<xsl:template match="tgroup" mode="newtbl" name="tgroup"> |
| 1471 |
<xsl:param name="tabletype">tabular</xsl:param> |
| 1472 |
<xsl:param name="tablewidth">\linewidth-2\tabcolsep</xsl:param> |
| 1473 |
<xsl:param name="tableframe">all</xsl:param> |
| 1474 |
|
| 1475 |
<!-- First, save the table verbatim data, but only at tgroup level --> |
| 1476 |
<xsl:if test="not(self::entrytbl)"> |
| 1477 |
<xsl:apply-templates mode="save.verbatim"/> |
| 1478 |
</xsl:if> |
| 1479 |
<xsl:text>\begingroup% </xsl:text> |
| 1480 |
|
| 1481 |
<!-- Set cellpadding --> |
| 1482 |
<xsl:if test="../@cellpadding"> |
| 1483 |
<xsl:text>\setlength{\tabcolsep}{</xsl:text> |
| 1484 |
<xsl:value-of select="../@cellpadding"/> |
| 1485 |
<xsl:text>}% </xsl:text> |
| 1486 |
</xsl:if> |
| 1487 |
|
| 1488 |
<!-- Get the number of columns --> |
| 1489 |
<xsl:variable name="cols"> |
| 1490 |
<xsl:choose> |
| 1491 |
<xsl:when test="@cols"> |
| 1492 |
<xsl:value-of select="@cols"/> |
| 1493 |
</xsl:when> |
| 1494 |
<xsl:otherwise> |
| 1495 |
<xsl:value-of select="count(tbody/row[1]/*[self::entry or |
| 1496 |
self::entrytbl])"/> |
| 1497 |
<xsl:message>Warning: table's tgroup lacks cols attribute. |
| 1498 |
Assuming <xsl:value-of select="count(tbody/row[1]/*)"/>. |
| 1499 |
</xsl:message> |
| 1500 |
</xsl:otherwise> |
| 1501 |
</xsl:choose> |
| 1502 |
</xsl:variable> |
| 1503 |
|
| 1504 |
<!-- Get the number of rows --> |
| 1505 |
<xsl:variable name="rows" select="count(*/row)"/> |
| 1506 |
|
| 1507 |
<xsl:if test="$rows = 0"> |
| 1508 |
<xsl:message>Warning: 0 rows</xsl:message> |
| 1509 |
</xsl:if> |
| 1510 |
|
| 1511 |
<!-- Get the specified table width --> |
| 1512 |
<xsl:variable name="table.width"> |
| 1513 |
<xsl:call-template name="table.width"> |
| 1514 |
<xsl:with-param name="fullwidth" select="$tablewidth"/> |
| 1515 |
</xsl:call-template> |
| 1516 |
</xsl:variable> |
| 1517 |
|
| 1518 |
<!-- Find the table width --> |
| 1519 |
<xsl:variable name="width"> |
| 1520 |
<xsl:choose> |
| 1521 |
<xsl:when test="not(contains($table.width,'auto'))"> |
| 1522 |
<xsl:value-of select="$table.width"/> |
| 1523 |
</xsl:when> |
| 1524 |
<xsl:otherwise> |
| 1525 |
<xsl:call-template name="table.width"> |
| 1526 |
<xsl:with-param name="fullwidth" select="$tablewidth"/> |
| 1527 |
<xsl:with-param name="exclude" select="'auto'"/> |
| 1528 |
</xsl:call-template> |
| 1529 |
</xsl:otherwise> |
| 1530 |
</xsl:choose> |
| 1531 |
</xsl:variable> |
| 1532 |
|
| 1533 |
<!-- Get the autowidth option --> |
| 1534 |
<xsl:variable name="autowidth"> |
| 1535 |
<xsl:choose> |
| 1536 |
<xsl:when test="contains($table.width,'auto')"> |
| 1537 |
<!-- Expect something like 'autowidth.all' or 'autowidth.default' --> |
| 1538 |
<xsl:value-of select="$table.width"/> |
| 1539 |
</xsl:when> |
| 1540 |
<xsl:otherwise><xsl:value-of select="$newtbl.autowidth"/></xsl:otherwise> |
| 1541 |
</xsl:choose> |
| 1542 |
</xsl:variable> |
| 1543 |
|
| 1544 |
<!-- Get default align --> |
| 1545 |
<xsl:variable name="align" |
| 1546 |
select="@align|parent::node()[not(*/@align)]/@align"/> |
| 1547 |
|
| 1548 |
<!-- Get default colsep --> |
| 1549 |
<xsl:variable name="colsep" |
| 1550 |
select="@colsep|parent::node()[not(*/@colsep)]/@colsep"/> |
| 1551 |
|
| 1552 |
<!-- Get default rowsep --> |
| 1553 |
<xsl:variable name="rowsep" |
| 1554 |
select="@rowsep|parent::node()[not(*/@rowsep)]/@rowsep"/> |
| 1555 |
|
| 1556 |
<!-- Now the frame style --> |
| 1557 |
<xsl:variable name="frame"> |
| 1558 |
<xsl:choose> |
| 1559 |
<xsl:when test="../@frame"> |
| 1560 |
<xsl:value-of select="../@frame"/> |
| 1561 |
</xsl:when> |
| 1562 |
<xsl:otherwise><xsl:value-of select="$tableframe"/></xsl:otherwise> |
| 1563 |
</xsl:choose> |
| 1564 |
</xsl:variable> |
| 1565 |
|
| 1566 |
<!-- Build up a complete colspec for each column --> |
| 1567 |
<xsl:variable name="colspec"> |
| 1568 |
<xsl:call-template name="tbl.colspec"> |
| 1569 |
<xsl:with-param name="autowidth" select="$autowidth"/> |
| 1570 |
<xsl:with-param name="cols" select="$cols"/> |
| 1571 |
<xsl:with-param name="rowsep"> |
| 1572 |
<xsl:choose> |
| 1573 |
<xsl:when test="$rowsep"><xsl:value-of select="$rowsep"/> |
| 1574 |
</xsl:when> |
| 1575 |
<xsl:when test="$newtbl.default.rowsep"> |
| 1576 |
<xsl:value-of select="$newtbl.default.rowsep"/> |
| 1577 |
</xsl:when> |
| 1578 |
<xsl:otherwise>1</xsl:otherwise> |
| 1579 |
</xsl:choose> |
| 1580 |
</xsl:with-param> |
| 1581 |
<xsl:with-param name="colsep"> |
| 1582 |
<xsl:choose> |
| 1583 |
<xsl:when test="$colsep"><xsl:value-of select="$colsep"/> |
| 1584 |
</xsl:when> |
| 1585 |
<xsl:when test="$newtbl.default.colsep"> |
| 1586 |
<xsl:value-of select="$newtbl.default.colsep"/> |
| 1587 |
</xsl:when> |
| 1588 |
<xsl:otherwise>1</xsl:otherwise> |
| 1589 |
</xsl:choose> |
| 1590 |
</xsl:with-param> |
| 1591 |
<xsl:with-param name="align"> |
| 1592 |
<xsl:choose> |
| 1593 |
<xsl:when test="$align"><xsl:value-of select="$align"/> |
| 1594 |
</xsl:when> |
| 1595 |
<xsl:otherwise>left</xsl:otherwise> |
| 1596 |
</xsl:choose> |
| 1597 |
</xsl:with-param> |
| 1598 |
</xsl:call-template> |
| 1599 |
</xsl:variable> |
| 1600 |
|
| 1601 |
<!-- Get all the spanspecs as an RTF --> |
| 1602 |
<xsl:variable name="spanspec" select="spanspec"/> |
| 1603 |
|
| 1604 |
<xsl:if test="$tabletype != 'tabularx'"> |
| 1605 |
<xsl:call-template name="tbl.sizes"> |
| 1606 |
<xsl:with-param name="colspec" select="exsl:node-set($colspec)"/> |
| 1607 |
<xsl:with-param name="width" select="$width"/> |
| 1608 |
</xsl:call-template> |
| 1609 |
</xsl:if> |
| 1610 |
|
| 1611 |
<xsl:if test="$tabletype = 'tabularx'"> |
| 1612 |
<xsl:call-template name="tbl.valign.x"> |
| 1613 |
<xsl:with-param name="valign" select="tbody/@valign"/> |
| 1614 |
</xsl:call-template> |
| 1615 |
</xsl:if> |
| 1616 |
|
| 1617 |
<!-- Start the next table on a new line --> |
| 1618 |
<xsl:if test="preceding::tgroup"> |
| 1619 |
<xsl:text> </xsl:text> |
| 1620 |
</xsl:if> |
| 1621 |
|
| 1622 |
<!-- Start the table declaration --> |
| 1623 |
<xsl:call-template name="tbl.begin"> |
| 1624 |
<xsl:with-param name="colspec" select="exsl:node-set($colspec)"/> |
| 1625 |
<xsl:with-param name="tabletype" select="$tabletype"/> |
| 1626 |
<xsl:with-param name="width" select="$width"/> |
| 1627 |
</xsl:call-template> |
| 1628 |
|
| 1629 |
<xsl:if test="not(thead)"> |
| 1630 |
<xsl:apply-templates select="(ancestor::table |
| 1631 |
|ancestor::informaltable)[last()]" |
| 1632 |
mode="newtbl.endhead"> |
| 1633 |
<xsl:with-param name="tabletype" select="$tabletype"/> |
| 1634 |
</xsl:apply-templates> |
| 1635 |
</xsl:if> |
| 1636 |
|
| 1637 |
<!-- Go through each row, starting with the header --> |
| 1638 |
<xsl:apply-templates mode="newtbl" select="((thead|tbody)/row)[1]"> |
| 1639 |
<xsl:with-param name="tabletype" select="$tabletype"/> |
| 1640 |
<xsl:with-param name="rownum" select="1"/> |
| 1641 |
<xsl:with-param name="rows" select="$rows"/> |
| 1642 |
<xsl:with-param name="frame" select="$frame"/> |
| 1643 |
<xsl:with-param name="colspec" select="exsl:node-set($colspec)"/> |
| 1644 |
<xsl:with-param name="spanspec" select="exsl:node-set($spanspec)"/> |
| 1645 |
</xsl:apply-templates> |
| 1646 |
|
| 1647 |
<!-- Go through each footer row --> |
| 1648 |
<xsl:apply-templates mode="newtbl" select="tfoot/row[1]"> |
| 1649 |
<xsl:with-param name="tabletype" select="$tabletype"/> |
| 1650 |
<xsl:with-param name="rownum" select="count(thead/row|tbody/row)+1"/> |
| 1651 |
<xsl:with-param name="rows" select="$rows"/> |
| 1652 |
<xsl:with-param name="frame" select="$frame"/> |
| 1653 |
<xsl:with-param name="colspec" select="exsl:node-set($colspec)"/> |
| 1654 |
<xsl:with-param name="spanspec" select="exsl:node-set($spanspec)"/> |
| 1655 |
</xsl:apply-templates> |
| 1656 |
|
| 1657 |
<!-- Need a bottom line? --> |
| 1658 |
<xsl:if test="$frame = 'all' or $frame = 'bottom' or $frame = 'topbot'"> |
| 1659 |
<xsl:text>\hline</xsl:text> |
| 1660 |
</xsl:if> |
| 1661 |
<xsl:text> </xsl:text> |
| 1662 |
|
| 1663 |
<xsl:text>\end{</xsl:text> |
| 1664 |
<xsl:value-of select="$tabletype"/> |
| 1665 |
<xsl:text>}\endgroup% </xsl:text> |
| 1666 |
</xsl:template> |
| 1667 |
|
| 1668 |
</xsl:stylesheet> |