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" 28 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 29 xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 30 xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 31 xmlns:dc="http://purl.org/dc/elements/1.1/" 32 xmlns:dom="http://www.w3.org/2001/xml-events" 33 xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 34 xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 35 xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 36 xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 37 xmlns:math="http://www.w3.org/1998/Math/MathML" 38 xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 39 xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 40 xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 41 xmlns:ooo="http://openoffice.org/2004/office" 42 xmlns:oooc="http://openoffice.org/2004/calc" 43 xmlns:ooow="http://openoffice.org/2004/writer" 44 xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 45 xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 46 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 47 xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 48 xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 49 xmlns:xforms="http://www.w3.org/2002/xforms" 50 xmlns:xlink="http://www.w3.org/1999/xlink" 51 xmlns:xsd="http://www.w3.org/2001/XMLSchema" 52 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 53 xmlns:xt="http://www.jclark.com/xt" 54 xmlns:common="http://exslt.org/common" 55 xmlns:xalan="http://xml.apache.org/xalan" 56 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 xt common xalan"> 57 58 59 <!-- *********************************** --> 60 <!-- *** write repeating table cells *** --> 61 <!-- *********************************** --> 62 63 64 <!-- matching cells to give out -> covered table cells are not written out --> 65 <xsl:template match="table:table-cell"> 66 <xsl:param name="globalData" /> 67 <!-- position of the current input cell to get the correct colum style (hidden are also counted)--> 68 <xsl:param name="allTableColumns" /> 69 <xsl:param name="maxRowLength" /> 70 <xsl:param name="tableDataType" /> 71 72 73 <!-- The column position of the current cell has to be determined 74 to get the adequate column styles during later cell creation, 75 or hiding the cell when @table:visibility is not set to 'visible'. 76 77 The position is archieved by adding up all table:number-columns-repeated of the preceding cells. 78 Step1: creating '$precedingCells/quantity/@table:number-columns-repeated'). 79 Step2: sum(xxx:nodeset($precedingCells)/quantity) + 1 --> 80 <xsl:variable name="precedingCells"> 81 <xsl:for-each select="preceding-sibling::*"> 82 <xsl:choose> 83 <!-- maybe a parser is used, which reads the DTD files (e.g. Xerces), 84 then '1' is the default for 'table:number-columns-repeated' --> 85 <xsl:when test="not(@table:number-columns-repeated and @table:number-columns-repeated > 1)"> 86 <xsl:element name="quantity" namespace=""> 87 <xsl:text>1</xsl:text> 88 </xsl:element> 89 </xsl:when> 90 <xsl:otherwise> 91 <xsl:element name="quantity" namespace=""> 92 <xsl:value-of select="@table:number-columns-repeated" /> 93 </xsl:element> 94 </xsl:otherwise> 95 </xsl:choose> 96 </xsl:for-each> 97 </xsl:variable> 98 99 100 101 <xsl:choose> 102 <xsl:when test="function-available('common:node-set')"> 103 <xsl:call-template name="create-table-cell"> 104 <!-- position of the current input cell to get the correct colum style (hidden are also counted)--> 105 <xsl:with-param name="allTableColumns" select="$allTableColumns" /> 106 <xsl:with-param name="maxRowLength" select="$maxRowLength" /> 107 <xsl:with-param name="precedingColumns" select="sum(common:node-set($precedingCells)/*)" /> 108 <xsl:with-param name="globalData" select="$globalData" /> 109 <xsl:with-param name="tableDataType" select="$tableDataType" /> 110 </xsl:call-template> 111 </xsl:when> 112 <xsl:when test="function-available('xalan:nodeset')"> 113 <xsl:call-template name="create-table-cell"> 114 <!-- position of the current input cell to get the correct colum style (hidden are also counted)--> 115 <xsl:with-param name="allTableColumns" select="$allTableColumns" /> 116 <xsl:with-param name="maxRowLength" select="$maxRowLength" /> 117 <xsl:with-param name="precedingColumns" select="sum(xalan:nodeset($precedingCells)/*)" /> 118 <xsl:with-param name="globalData" select="$globalData" /> 119 <xsl:with-param name="tableDataType" select="$tableDataType" /> 120 </xsl:call-template> 121 </xsl:when> 122 <xsl:when test="function-available('xt:node-set')"> 123 <xsl:call-template name="create-table-cell"> 124 <!-- position of the current input cell to get the correct colum style (hidden are also counted)--> 125 <xsl:with-param name="allTableColumns" select="$allTableColumns" /> 126 <xsl:with-param name="maxRowLength" select="$maxRowLength" /> 127 <xsl:with-param name="precedingColumns" select="sum(xt:node-set($precedingCells)/*)" /> 128 <xsl:with-param name="globalData" select="$globalData" /> 129 <xsl:with-param name="tableDataType" select="$tableDataType" /> 130 </xsl:call-template> 131 </xsl:when> 132 <xsl:otherwise> 133 <xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message> 134 </xsl:otherwise> 135 </xsl:choose> 136 </xsl:template> 137 138 139 <!-- current node is a table:table-cell --> 140 <xsl:template name="create-table-cell"> 141 <!-- position of the current input cell to get the correct colum style (hidden are also counted)--> 142 <xsl:param name="allTableColumns" /> 143 <xsl:param name="globalData" /> 144 <xsl:param name="maxRowLength" /> 145 <xsl:param name="precedingColumns" select="0" /> 146 <xsl:param name="tableDataType" /> 147 148 <xsl:variable name="columnPosition" select="$precedingColumns + 1" /> 149 150 <xsl:if test="$debugEnabled"> 151 <xsl:message> 152 <xsl:text> 153 table:table-cell #</xsl:text> 154 <xsl:value-of select="$columnPosition" /> 155 <xsl:text> has been entered with node value: </xsl:text> 156 <xsl:value-of select="." /> 157 <xsl:text> 158 table:number-columns-repeated: </xsl:text> 159 <xsl:value-of select="@table:number-columns-repeated" /> 160 <xsl:text> 161 maxRowLength: </xsl:text> 162 <xsl:value-of select="$maxRowLength" /> 163 </xsl:message> 164 </xsl:if> 165 166 <!-- only non hidden column will be given out --> 167 <xsl:variable name="currentTableColumn" select="$allTableColumns/table:table-column[position() = $columnPosition]" /> 168 <xsl:if test="$currentTableColumn[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]"> 169 <xsl:choose> 170 <!-- if parser reads DTD the default is set to '1' --> 171 <xsl:when test="@table:number-columns-repeated > 1"> 172 <!-- writes multiple entries of a cell --> 173 <xsl:call-template name="repeat-write-cell"> 174 <xsl:with-param name="globalData" select="$globalData" /> 175 <xsl:with-param name="allTableColumns" select="$allTableColumns" /> 176 <xsl:with-param name="columnPosition" select="$columnPosition" /> 177 <xsl:with-param name="currentTableColumn" select="$currentTableColumn" /> 178 <xsl:with-param name="maxRowLength" select="$maxRowLength" /> 179 <xsl:with-param name="numberColumnsRepeated" select="@table:number-columns-repeated" /> 180 <xsl:with-param name="tableDataType" select="$tableDataType" /> 181 </xsl:call-template> 182 </xsl:when> 183 <xsl:otherwise> 184 <!-- writes an entry of a cell --> 185 <xsl:call-template name="write-cell"> 186 <xsl:with-param name="globalData" select="$globalData" /> 187 <xsl:with-param name="allTableColumns" select="$allTableColumns" /> 188 <xsl:with-param name="columnPosition" select="$columnPosition" /> 189 <xsl:with-param name="currentTableColumn" select="$currentTableColumn" /> 190 <xsl:with-param name="maxRowLength" select="$maxRowLength" /> 191 <xsl:with-param name="tableDataType" select="$tableDataType" /> 192 </xsl:call-template> 193 </xsl:otherwise> 194 </xsl:choose> 195 </xsl:if> 196 </xsl:template> 197 198 199 <xsl:template name="repeat-write-cell"> 200 <xsl:param name="globalData" /> 201 <xsl:param name="allTableColumns" /> 202 <xsl:param name="columnPosition" /> 203 <xsl:param name="currentTableColumn" /> 204 <xsl:param name="maxRowLength" /> 205 <xsl:param name="numberColumnsRepeated" /> 206 <xsl:param name="tableDataType" /> 207 208 <xsl:choose> 209 <!-- This is the current workaround for the flood of cells, simulation background by repeating cell --> 210 <xsl:when test="$numberColumnsRepeated > 1 and $maxRowLength > $columnPosition"> 211 212 <!-- writes an entry of a cell --> 213 <xsl:call-template name="write-cell"> 214 <xsl:with-param name="globalData" select="$globalData" /> 215 <xsl:with-param name="allTableColumns" select="$allTableColumns" /> 216 <xsl:with-param name="columnPosition" select="$columnPosition" /> 217 <xsl:with-param name="currentTableColumn" select="$currentTableColumn" /> 218 <xsl:with-param name="tableDataType" select="$tableDataType" /> 219 </xsl:call-template> 220 <!-- repeat calling this method until all elements written out --> 221 <xsl:if test="$debugEnabled"> 222 <xsl:message>+++++++++ cell repetition +++++++++</xsl:message> 223 </xsl:if> 224 <xsl:call-template name="repeat-write-cell"> 225 <xsl:with-param name="globalData" select="$globalData" /> 226 <xsl:with-param name="allTableColumns" select="$allTableColumns" /> 227 <xsl:with-param name="columnPosition" select="$columnPosition + 1" /> 228 <xsl:with-param name="currentTableColumn" select="$allTableColumns/table:table-column[position() = ($columnPosition + 1)]" /> 229 <xsl:with-param name="maxRowLength" select="$maxRowLength" /> 230 <xsl:with-param name="numberColumnsRepeated" select="$numberColumnsRepeated - 1" /> 231 <xsl:with-param name="tableDataType" select="$tableDataType" /> 232 </xsl:call-template> 233 </xsl:when> 234 <xsl:otherwise> 235 <!-- This is the current workaround for the flood of cells, simulation background by repeating cell --> 236 <!-- When the maxRowLength is reached a last entry of a cell is written --> 237 <xsl:call-template name="write-cell"> 238 <xsl:with-param name="globalData" select="$globalData" /> 239 <xsl:with-param name="allTableColumns" select="$allTableColumns" /> 240 <xsl:with-param name="columnPosition" select="$columnPosition" /> 241 <xsl:with-param name="currentTableColumn" select="$currentTableColumn" /> 242 <xsl:with-param name="tableDataType" select="$tableDataType" /> 243 </xsl:call-template> 244 </xsl:otherwise> 245 </xsl:choose> 246 </xsl:template> 247 248 249 <xsl:template name="write-cell"> 250 <xsl:param name="globalData" /> 251 <xsl:param name="allTableColumns" /> 252 <xsl:param name="columnPosition" /> 253 <xsl:param name="currentTableColumn" /> 254 <xsl:param name="tableDataType" /> 255 256 <!-- a non hidden column will be give out --> 257 <xsl:choose> 258 <xsl:when test="$currentTableColumn[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]"> 259 <xsl:call-template name="create-table-cell-content"> 260 <xsl:with-param name="globalData" select="$globalData" /> 261 <xsl:with-param name="allTableColumns" select="$allTableColumns" /> 262 <xsl:with-param name="columnPosition" select="$columnPosition" /> 263 <xsl:with-param name="currentTableColumn" select="$currentTableColumn" /> 264 <xsl:with-param name="tableDataType" select="$tableDataType" /> 265 </xsl:call-template> 266 </xsl:when> 267 <!-- a hidden column --> 268 <xsl:otherwise> 269 <xsl:if test="$debugEnabled"> 270 <xsl:message>table column is hidden!</xsl:message> 271 </xsl:if> 272 </xsl:otherwise> 273 </xsl:choose> 274 </xsl:template> 275</xsl:stylesheet> 276