1<?xml version="1.0" encoding="UTF-8"?> 2<!--*********************************************************** 3 * 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 * 21 ***********************************************************--> 22 23 24<!-- 25 For further documentation and updates visit http://xml.openoffice.org/odf2xhtml 26--> 27<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://xml.apache.org/xslt/java" xmlns:sxg="http://www.jclark.com/xt/java/org.openoffice.xslt.OOoMasterDocument" xmlns:common="http://exslt.org/common" xmlns:xt="http://www.jclark.com/xt" xmlns:xalan="http://xml.apache.org/xalan" exclude-result-prefixes="chart config dc dom dr3d draw fo form math meta number office ooo oooc ooow script style svg table text xforms xlink xsd xsi java sxg xt common xalan"> 28 29 <!-- ****************************** --> 30 <!-- *** Table of Content *** --> 31 <!-- ****************************** --> 32 33 <xsl:param name="currentChildContentRef" /> 34 <xsl:param name="contentTableHeadings" /> 35 <xsl:param name="contentTableURL" /> 36 <xsl:template match="text:table-of-content"> 37 <xsl:param name="globalData"/> 38 39 <xsl:apply-templates> 40 <xsl:with-param name="globalData" select="$globalData"/> 41 </xsl:apply-templates> 42 </xsl:template> 43 44 45 <xsl:template match="text:index-body"> 46 <xsl:param name="globalData"/> 47 48 <xsl:choose> 49 <xsl:when test="parent::table-of-content and */text:tab[1] or */*/text:tab[1]"> 50 <xsl:call-template name="createIndexBodyTable"> 51 <xsl:with-param name="globalData" select="$globalData"/> 52 </xsl:call-template> 53 </xsl:when> 54 <xsl:otherwise> 55 <xsl:apply-templates> 56 <xsl:with-param name="globalData" select="$globalData"/> 57 </xsl:apply-templates> 58 </xsl:otherwise> 59 </xsl:choose> 60 </xsl:template> 61 62 <xsl:template match="text:index-title" mode="content-table"> 63 <xsl:param name="globalData"/> 64 65 <xsl:apply-templates> 66 <xsl:with-param name="globalData" select="$globalData"/> 67 </xsl:apply-templates> 68 </xsl:template> 69 70 <xsl:template name="createIndexBodyTable"> 71 <xsl:param name="globalData"/> 72 <xsl:variable name="allStyleTabStops-RTF"> 73 <xsl:element name="style:tab-stops"> 74 <xsl:call-template name="get-tab-stops"> 75 <xsl:with-param name="globalData" select="$globalData"/> 76 <xsl:with-param name="styleName" select="current()/@text:style-name"/> 77 78 <!-- 79 Currently only the style of text:index-body is recognized, but not of a paragraph child containing the text:tab element! 80 <xsl:with-param name="styleName" select="descendant-or-self::*/@text:style-name"/> 81 82 The column width needs to be tabstop plus fo:margin-left paragraph-properties 83 --> 84 </xsl:call-template> 85 </xsl:element> 86 </xsl:variable> 87 <xsl:element namespace="{$namespace}" name="table"> 88 89 <xsl:attribute name="border">0</xsl:attribute> 90 <xsl:attribute name="cellspacing">0</xsl:attribute> 91 <xsl:attribute name="cellpadding">0</xsl:attribute> 92 <xsl:if test="parent::*/@text:style-name"> 93 <!-- parent as index:body has no style --> 94 <xsl:variable name="value" select="$globalData/all-doc-styles/style[@style:name = current()/parent::*/@text:style-name]/*/@style:rel-width"/> 95 <xsl:if test="$value"> 96 <xsl:attribute name="width"> 97 <xsl:value-of select="$value"/> 98 </xsl:attribute> 99 </xsl:if> 100 <xsl:attribute name="class"> 101 <xsl:value-of select="translate(parent::*/@text:style-name, '.,;: %()[]/\+', '_____________')"/> 102 </xsl:attribute> 103 </xsl:if> 104 105 <xsl:element namespace="{$namespace}" name="colgroup"> 106 <xsl:choose> 107 <xsl:when test="function-available('common:node-set')"> 108 <xsl:call-template name="create-col-element"> 109 <xsl:with-param name="lastNodePosition" select="count(common:node-set($allStyleTabStops-RTF)/style:tab-stops/style:tab-stop)"/> 110 <xsl:with-param name="allStyleTabStops" select="common:node-set($allStyleTabStops-RTF)"/> 111 </xsl:call-template> 112 </xsl:when> 113 <xsl:when test="function-available('xalan:nodeset')"> 114 <xsl:call-template name="create-col-element"> 115 <xsl:with-param name="lastNodePosition" select="count(xalan:nodeset($allStyleTabStops-RTF)/style:tab-stops/style:tab-stop)"/> 116 <xsl:with-param name="allStyleTabStops" select="xalan:nodeset($allStyleTabStops-RTF)"/> 117 </xsl:call-template> 118 </xsl:when> 119 <xsl:when test="function-available('xt:node-set')"> 120 <xsl:call-template name="create-col-element"> 121 <xsl:with-param name="lastNodePosition" select="count(xt:node-set($allStyleTabStops-RTF)/style:tab-stops/style:tab-stop)"/> 122 <xsl:with-param name="allStyleTabStops" select="xt:node-set($allStyleTabStops-RTF)"/> 123 </xsl:call-template> 124 </xsl:when> 125 <xsl:otherwise> 126 <xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message> 127 </xsl:otherwise> 128 </xsl:choose> 129 </xsl:element> 130 131 <!-- add table data --> 132 <xsl:choose> 133 <xsl:when test="function-available('common:node-set')"> 134 <xsl:apply-templates mode="content-table"> 135 <xsl:with-param name="globalData" select="$globalData"/> 136 <xsl:with-param name="allStyleTabStops" select="common:node-set($allStyleTabStops-RTF)"/> 137 </xsl:apply-templates> 138 </xsl:when> 139 <xsl:when test="function-available('xalan:nodeset')"> 140 <xsl:apply-templates mode="content-table"> 141 <xsl:with-param name="globalData" select="$globalData"/> 142 <xsl:with-param name="allStyleTabStops" select="xalan:nodeset($allStyleTabStops-RTF)"/> 143 </xsl:apply-templates> 144 </xsl:when> 145 <xsl:when test="function-available('xt:node-set')"> 146 <xsl:apply-templates mode="content-table"> 147 <xsl:with-param name="globalData" select="$globalData"/> 148 <xsl:with-param name="allStyleTabStops" select="xt:node-set($allStyleTabStops-RTF)"/> 149 </xsl:apply-templates> 150 </xsl:when> 151 <xsl:otherwise> 152 <xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message> 153 </xsl:otherwise> 154 </xsl:choose> 155 156 </xsl:element> 157 </xsl:template> 158 159 160 <!-- ************************************************ --> 161 <!-- *** Create Table for Content Table Paragraph *** --> 162 <!-- ************************************************ --> 163 164 <!-- Usually the paragraph in a content-table are ordered by tab-stops, which can not be displayed correctly by XHTML/CSS 165 Therefore they will be simulated by a table --> 166 <xsl:template match="text:p" mode="content-table"> 167 <xsl:param name="globalData"/> 168 <xsl:param name="allStyleTabStops"/> 169 170 <!-- all elements before the first tabStop --> 171 <xsl:variable name="testNo-RTF"> 172 <xsl:apply-templates select="node()" mode="cell-content"/> 173 </xsl:variable> 174 175 <xsl:choose> 176 <xsl:when test="function-available('common:node-set')"> 177 <xsl:variable name="tabNodePositions" select="common:node-set($testNo-RTF)"/> 178 <xsl:element namespace="{$namespace}" name="tr"> 179 <xsl:call-template name="create-td-elements"> 180 <xsl:with-param name="lastNodePosition" select="count($allStyleTabStops/style:tab-stops/style:tab-stop)"/> 181 <xsl:with-param name="position" select="1"/> 182 <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/> 183 <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/> 184 <xsl:with-param name="globalData" select="$globalData"/> 185 </xsl:call-template> 186 </xsl:element> 187 </xsl:when> 188 <xsl:when test="function-available('xalan:nodeset')"> 189 <xsl:variable name="tabNodePositions" select="xalan:nodeset($testNo-RTF)"/> 190 <xsl:element namespace="{$namespace}" name="tr"> 191 <xsl:call-template name="create-td-elements"> 192 <xsl:with-param name="lastNodePosition" select="count($allStyleTabStops/style:tab-stops/style:tab-stop)"/> 193 <xsl:with-param name="position" select="1"/> 194 <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/> 195 <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/> 196 <xsl:with-param name="globalData" select="$globalData"/> 197 </xsl:call-template> 198 </xsl:element> 199 </xsl:when> 200 <xsl:when test="function-available('xt:node-set')"> 201 <xsl:variable name="tabNodePositions" select="xt:node-set($testNo-RTF)"/> 202 <xsl:element namespace="{$namespace}" name="tr"> 203 <xsl:call-template name="create-td-elements"> 204 <xsl:with-param name="lastNodePosition" select="count($allStyleTabStops/style:tab-stops/style:tab-stop)"/> 205 <xsl:with-param name="position" select="1"/> 206 <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/> 207 <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/> 208 <xsl:with-param name="globalData" select="$globalData"/> 209 </xsl:call-template> 210 </xsl:element> 211 </xsl:when> 212 <xsl:otherwise> 213 <xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message> 214 </xsl:otherwise> 215 </xsl:choose> 216 </xsl:template> 217 218 <!-- Gathering all style:tab-stops from a style-hierarchy as siblings --> 219 <xsl:template name="get-tab-stops"> 220 <xsl:param name="globalData"/> 221 <xsl:param name="styleName"/> 222 <xsl:variable name="tabStyle" select="key('styles', $styleName)"/> 223 224 <xsl:if test="$tabStyle/*/style:tab-stops/style:tab-stop/@style:position"> 225 <xsl:for-each select="$tabStyle/*/style:tab-stops/style:tab-stop"> 226 <xsl:copy-of select="."/> 227 </xsl:for-each> 228 </xsl:if> 229 230 <xsl:if test="$tabStyle/@style:parent-style-name"> 231 <xsl:call-template name="get-tab-stops"> 232 <xsl:with-param name="globalData" select="$globalData"/> 233 <xsl:with-param name="styleName" select="$tabStyle/@style:parent-style-name"/> 234 </xsl:call-template> 235 </xsl:if> 236 </xsl:template> 237 238 <xsl:template name="create-col-element"> 239 <xsl:param name="lastNodePosition"/> 240 <xsl:param name="allStyleTabStops"/> 241 242 <xsl:for-each select="$allStyleTabStops/style:tab-stops/style:tab-stop"> 243 <xsl:element namespace="{$namespace}" name="col"> 244 <xsl:attribute name="style"> 245 <xsl:text>width: </xsl:text> 246 <xsl:choose> 247 <xsl:when test="contains(@style:position, 'cm')"> 248 <xsl:call-template name="create-cell-width"> 249 <xsl:with-param name="width" select="number(substring-before(@style:position,'cm'))"/> 250 <xsl:with-param name="unit" select="'cm'"/> 251 <xsl:with-param name="position" select="position() - 1"/> 252 <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/> 253 </xsl:call-template> 254 </xsl:when> 255 <xsl:when test="contains(@style:position, 'in')"> 256 <xsl:call-template name="create-cell-width"> 257 <xsl:with-param name="width" select="number(substring-before(@style:position,'in'))"/> 258 <xsl:with-param name="unit" select="'in'"/> 259 <xsl:with-param name="position" select="position() - 1"/> 260 <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/> 261 </xsl:call-template> 262 </xsl:when> 263 <xsl:when test="contains(@style:position, 'ch')"> 264 <xsl:call-template name="create-cell-width"> 265 <xsl:with-param name="width" select="number(substring-before(@style:position,'ch'))"/> 266 <xsl:with-param name="unit" select="'ch'"/> 267 <xsl:with-param name="position" select="position() - 1"/> 268 <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/> 269 </xsl:call-template> 270 </xsl:when> 271 <xsl:when test="contains(@style:position, 'pt')"> 272 <xsl:call-template name="create-cell-width"> 273 <xsl:with-param name="width" select="number(substring-before(@style:position,'pt'))"/> 274 <xsl:with-param name="unit" select="'pt'"/> 275 <xsl:with-param name="position" select="position() - 1"/> 276 <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/> 277 </xsl:call-template> 278 </xsl:when> 279 </xsl:choose> 280 281 </xsl:attribute> 282 </xsl:element> 283 </xsl:for-each> 284 285 </xsl:template> 286<!-- 287Scenarios tabstops 288 2891) style:type of style:tab-stop is 'right' and earlier tabStop is not right 290 -> Earlier text-nodes and following text-nodes, will be put into an inner table, with two TD first aligned left, with proceeding textnodes, the latter aligned right. 291 2922) style:type is 'right' and earlier tabStop is right 293 -> following text-nodes, will be put into a right aligned TD 294 2953) style:type is 'non-right' and earlier tabStop 'non-right' as well 296 -> put the preceding tab stops into a TD (left aligned is default) 297 2984) first style:type would have no right preceding tabStop 299 -> works well with first sceanrios 1 and 3 300 3015) last style:type would be a special case, if it would be left aligned, but this won't happen in our case.. :D 302 303Scenarios unmatched: 304- text:styleposition 'center' will not be matched in our case (effort for nothing), there will be only 'right' and not 'right' 305- If the last tabStop is not from text:styleposition 'right', the length of the last cell is undefined and a document length must be found. 306 Not happens in our master document case. Also the algorithm below would have to be expanded (cp. scenario 5). 307 308--> 309 <xsl:template name="create-td-elements"> 310 <xsl:param name="globalData"/> 311 <xsl:param name="lastNodePosition"/> 312 <xsl:param name="position"/> 313 <xsl:param name="allStyleTabStops"/> 314 <xsl:param name="tabNodePositions"/> 315 316 <xsl:variable name="currentTabStop" select="$allStyleTabStops/style:tab-stops/style:tab-stop[$position]"/> 317 <xsl:variable name="earlierTabStop" select="$allStyleTabStops/style:tab-stops/style:tab-stop[$position - 1]"/> 318 <xsl:choose> 319 <xsl:when test="not($currentTabStop/@style:position) and not($earlierTabStop/@style:position)"> 320 <!-- in case no TAB STOP is being set --> 321 <xsl:element namespace="{$namespace}" name="td"> 322 <xsl:element namespace="{$namespace}" name="p"> 323 <xsl:if test="$position = 1"> 324 <xsl:attribute name="class"> 325 <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/> 326 </xsl:attribute> 327 </xsl:if> 328 <xsl:apply-templates mode="content-table"> 329 <xsl:with-param name="globalData" select="$globalData"/> 330 </xsl:apply-templates> 331 </xsl:element> 332 </xsl:element> 333 </xsl:when> 334 <xsl:otherwise> 335 <xsl:choose> 336 <xsl:when test="$currentTabStop/@style:type = 'right'"> 337 <xsl:choose> 338 <xsl:when test="$earlierTabStop/@style:type = 'right'"> 339 <!-- 340 2) style:type is 'right' and earlier tabStop is right 341 -> following text-nodes, will be put into a right aligned TD --> 342 <xsl:element namespace="{$namespace}" name="td"> 343 <xsl:attribute name="style"> 344 <xsl:text>align: right</xsl:text> 345 </xsl:attribute> 346 <xsl:element namespace="{$namespace}" name="p"> 347 <xsl:if test="$position = 1"> 348 <xsl:attribute name="class"> 349 <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/> 350 </xsl:attribute> 351 </xsl:if> 352 <xsl:call-template name="grab-cell-content-before-tab-stop"> 353 <xsl:with-param name="globalData" select="$globalData"/> 354 <xsl:with-param name="endingTabStopPosition" select="$position + 1"/> 355 <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/> 356 <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/> 357 </xsl:call-template> 358 </xsl:element> 359 </xsl:element> 360 </xsl:when> 361 <xsl:otherwise> 362 <xsl:element namespace="{$namespace}" name="td"> 363 <xsl:element namespace="{$namespace}" name="p"> 364 <xsl:if test="$position = 1"> 365 <xsl:attribute name="class"> 366 <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/> 367 </xsl:attribute> 368 </xsl:if> 369 <xsl:call-template name="grab-cell-content-before-tab-stop"> 370 <xsl:with-param name="globalData" select="$globalData"/> 371 <xsl:with-param name="endingTabStopPosition" select="$position"/> 372 <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/> 373 <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/> 374 </xsl:call-template> 375 </xsl:element> 376 </xsl:element> 377 </xsl:otherwise> 378 </xsl:choose> 379 </xsl:when> 380 <xsl:otherwise> 381 <xsl:choose> 382 <xsl:when test="$earlierTabStop/@style:type = 'right'"></xsl:when> 383 <xsl:otherwise> 384 <!-- 385 3) style:type is 'non-right' and earlier tabStop 'non-right' as well 386 -> put the preceding tab stops into a TD (left aligned is default) --> 387 <xsl:element namespace="{$namespace}" name="p"> 388 <xsl:if test="$position = 1"> 389 <xsl:attribute name="class"> 390 <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/> 391 </xsl:attribute> 392 </xsl:if> 393 <xsl:element namespace="{$namespace}" name="td"> 394 <xsl:call-template name="grab-cell-content-before-tab-stop"> 395 <xsl:with-param name="globalData" select="$globalData"/> 396 <xsl:with-param name="endingTabStopPosition" select="$position"/> 397 <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/> 398 <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/> 399 </xsl:call-template> 400 </xsl:element> 401 </xsl:element> 402 </xsl:otherwise> 403 </xsl:choose> 404 </xsl:otherwise> 405 </xsl:choose> 406 407 <xsl:if test="$position != $lastNodePosition"> 408 <xsl:call-template name="create-td-elements"> 409 <xsl:with-param name="globalData" select="$globalData"/> 410 <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/> 411 <xsl:with-param name="position" select="$position + 1"/> 412 <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/> 413 <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/> 414 </xsl:call-template> 415 </xsl:if> 416 </xsl:otherwise> 417 </xsl:choose> 418 </xsl:template> 419 420 <xsl:template name="grab-cell-content-before-tab-stop"> 421 <xsl:param name="globalData"/> 422 <xsl:param name="endingTabStopPosition"/> 423 <xsl:param name="tabNodePositions"/> 424 <xsl:param name="lastNodePosition"/> 425 426 <xsl:choose> 427 <xsl:when test="$endingTabStopPosition = 1"> 428 <xsl:apply-templates mode="content-table" select="node()[position() < $tabNodePositions/tab-stop-node-position[$endingTabStopPosition]]"> 429 <xsl:with-param name="globalData" select="$globalData"/> 430 </xsl:apply-templates> 431 </xsl:when> 432 <xsl:when test="$endingTabStopPosition > $lastNodePosition"> 433 <xsl:apply-templates mode="content-table" select="node()[position() > $tabNodePositions/tab-stop-node-position[$endingTabStopPosition - 1]]"> 434 <xsl:with-param name="globalData" select="$globalData"/> 435 </xsl:apply-templates> 436 </xsl:when> 437 <xsl:otherwise> 438 <xsl:variable name="nodesOfNextColumn" select="node()[position() < $tabNodePositions/tab-stop-node-position[$endingTabStopPosition]][position() > $tabNodePositions/tab-stop-node-position[$endingTabStopPosition - 1]]"/> 439 <xsl:choose> 440 <xsl:when test="$nodesOfNextColumn != ''"> 441 <xsl:apply-templates mode="content-table" select="$nodesOfNextColumn"> 442 <xsl:with-param name="globalData" select="$globalData"/> 443 </xsl:apply-templates> 444 </xsl:when> 445 <xsl:otherwise> 446 <xsl:apply-templates mode="content-table"> 447 <xsl:with-param name="globalData" select="$globalData"/> 448 </xsl:apply-templates> 449 </xsl:otherwise> 450 </xsl:choose> 451 </xsl:otherwise> 452 </xsl:choose> 453 </xsl:template> 454 455 <!-- As the span width will be mapped to column width, the preceding span widths have to be subtracted --> 456 <xsl:template name="create-cell-width"> 457 <xsl:param name="width"/> 458 <xsl:param name="unit"/> 459 <xsl:param name="position"/> 460 <xsl:param name="allStyleTabStops"/> 461 462 <xsl:choose> 463 <!-- beyond second width --> 464 <xsl:when test="$position > 1"> 465 <xsl:call-template name="create-cell-width"> 466 <xsl:with-param name="width" select="$width - number(substring-before($allStyleTabStops/style:tab-stops/style:tab-stop[$position]/@style:position,$unit))"/> 467 <xsl:with-param name="unit" select="$unit"/> 468 <xsl:with-param name="position" select="$position - 1"/> 469 <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/> 470 </xsl:call-template> 471 </xsl:when> 472 <!-- second width --> 473 <xsl:when test="$position = 1"> 474 <xsl:value-of select="concat($width - number(substring-before($allStyleTabStops/style:tab-stops/style:tab-stop[$position]/@style:position,$unit)), $unit)"/> 475 </xsl:when> 476 <!-- first width --> 477 <xsl:otherwise> 478 <xsl:value-of select="concat($width, $unit)"/> 479 </xsl:otherwise> 480 </xsl:choose> 481 </xsl:template> 482 483 484 <!-- ************************************** --> 485 <!-- CREATION OF A CONTENT TABLE LINK --> 486 <!-- ************************************** --> 487 488 <xsl:key name="bookmark" match="text:bookmark | text:bookmark-start" use="@text:name"/> 489 490 <!-- content table link --> 491 <xsl:template match="text:a" mode="content-table"> 492 <xsl:param name="globalData"/> 493 494 <xsl:variable name="name" select="substring(@xlink:href,2)"/> 495 496 <xsl:variable name="text"> 497 <xsl:choose> 498 <!-- heuristic assumption that first in a content table row, there is numbering (if at all) and than the text, 499 furthermore that a tab will separate the to be neglected page number --> 500 <xsl:when test="text:tab"> 501 <xsl:call-template name="write-text-without-line-numbers"> 502 <xsl:with-param name="textCount" select="count(text())"/> 503 </xsl:call-template> 504 </xsl:when> 505 <xsl:otherwise> 506 <xsl:value-of select="text()"/> 507 </xsl:otherwise> 508 </xsl:choose> 509 </xsl:variable> 510 511 <!-- REFERENCE HANDLING - HREF --> 512 <xsl:element namespace="{$namespace}" name="a"> 513 <xsl:attribute name="href"> 514 <xsl:text>#</xsl:text> 515 <xsl:choose> 516 <xsl:when test="key('bookmark',$name)"> 517 <xsl:value-of select="$name"/> 518 </xsl:when> 519 <xsl:otherwise> 520 <xsl:value-of select='concat("a_", translate(normalize-space($text), "
&<>.,;: %()[]/\+", "_______________________________"))'/> 521 </xsl:otherwise> 522 </xsl:choose> 523 </xsl:attribute> 524 <xsl:value-of select="$text"/> 525 </xsl:element> 526 </xsl:template> 527 528 <!-- Heuristic: write out text separated by elements, leaving the last number out (mostly text number) --> 529 <xsl:template name="write-text-without-line-numbers"> 530 <xsl:param name="textCount"/> 531 <xsl:param name="textNodeNumber" select="1"/> 532 533 <xsl:choose> 534 <xsl:when test="$textCount > $textNodeNumber"> 535 <xsl:value-of select="text()[$textNodeNumber]"/> 536 <xsl:call-template name="write-text-without-line-numbers"> 537 <xsl:with-param name="textCount" select="$textCount"/> 538 <xsl:with-param name="textNodeNumber" select="$textNodeNumber + 1"/> 539 </xsl:call-template> 540 </xsl:when> 541 <xsl:otherwise> 542 <xsl:if test="not(number(text()[$textNodeNumber]) > -1)"> 543 <xsl:value-of select="text()[$textNodeNumber]"/> 544 </xsl:if> 545 </xsl:otherwise> 546 </xsl:choose> 547 548 </xsl:template> 549 550 <xsl:template match="text:s" mode="content-table"> 551 <xsl:call-template name="write-breakable-whitespace"> 552 <xsl:with-param name="whitespaces" select="@text:c"/> 553 </xsl:call-template> 554 </xsl:template> 555 556 <!-- ******************** --> 557 <!-- *** Common Rules *** --> 558 <!-- ******************** --> 559 560 <xsl:template match="*" mode="content-table"> 561 <xsl:param name="globalData"/> 562 563 <xsl:apply-templates select="."> 564 <xsl:with-param name="globalData" select="$globalData"/> 565 </xsl:apply-templates> 566 </xsl:template> 567 568 <xsl:template match="*" mode="cell-content"> 569 <xsl:if test="name() = 'text:tab' or *[name() = 'text:tab']"> 570 <xsl:element name="tab-stop-node-position" namespace=""> 571 <xsl:value-of select="position()"/> 572 </xsl:element> 573 </xsl:if> 574 </xsl:template> 575 576 <xsl:template match="text()" mode="content-table"> 577 <!-- Heuristic to remove page numbers (useless in HTML) in the content table 578 usually after a tab --> 579 <xsl:if test="name(preceding-sibling::*[1]) != 'text:tab' and not(number() > -1)"> 580 <xsl:value-of select="."/> 581 </xsl:if> 582 </xsl:template> 583 584</xsl:stylesheet> 585