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	<xsl:param name="tableColumnElement"            select="'col'" />
59
60	<!-- ******************************************** -->
61	<!-- *** Create table columns style variable  *** -->
62	<!-- ******************************************** -->
63
64	<!-- current node is a table:table -->
65	<xsl:template name="create-column-style-variable">
66		<xsl:param name="globalData" />
67		<xsl:param name="allVisibleTableRows" />
68
69		<!-- all columns of the table -->
70		<xsl:variable name="allTableColumns" select="table:table-column |
71													 table:table-column-group/descendant::table:table-column |
72													 table:table-header-columns/descendant::table:table-column" />
73		<!-- allTableColumns: Containing all columns of the table, hidden and viewed.
74			- if a column is hidden, if table:visibility has the value 'collapse' or 'filter', otherwise the value is 'visible'
75			- if a column is being repeated, each repeated column is explicitly written as entry in this variable.
76			  Later (during template "write-cell") the style of the column will be mixed with the cell-style by using
77			  the position() of the column entry and comparing it with the iterating cell number. -->
78		<xsl:variable name="allTableColumns-RTF">
79			<xsl:for-each select="$allTableColumns">
80				<xsl:call-template name="adding-column-styles-entries">
81					<xsl:with-param name="globalData"       select="$globalData" />
82					<xsl:with-param name="allTableColumns"  select="$allTableColumns" />
83				</xsl:call-template>
84			</xsl:for-each>
85		</xsl:variable>
86
87		<xsl:choose>
88			<xsl:when test="function-available('common:node-set')">
89				<xsl:call-template name="create-table-children">
90					<xsl:with-param name="globalData"           select="$globalData" />
91					<xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
92					<xsl:with-param name="allTableColumns"      select="common:node-set($allTableColumns-RTF)" />
93				</xsl:call-template>
94			</xsl:when>
95			<xsl:when test="function-available('xalan:nodeset')">
96				<xsl:call-template name="create-table-children">
97					<xsl:with-param name="globalData"           select="$globalData" />
98					<xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
99					<xsl:with-param name="allTableColumns"      select="xalan:nodeset($allTableColumns-RTF)" />
100				</xsl:call-template>
101			</xsl:when>
102			<xsl:when test="function-available('xt:node-set')">
103				<xsl:call-template name="create-table-children">
104					<xsl:with-param name="globalData"           select="$globalData" />
105					<xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
106					<xsl:with-param name="allTableColumns"      select="xt:node-set($allTableColumns-RTF)" />
107				</xsl:call-template>
108			</xsl:when>
109		</xsl:choose>
110	</xsl:template>
111
112	<!-- current node is a table:table -->
113	<xsl:template name="create-table-children">
114		<xsl:param name="globalData" />
115		<xsl:param name="allVisibleTableRows" />
116		<xsl:param name="allTableColumns" />
117
118
119		<xsl:for-each select="$allTableColumns/table:table-column">
120			<xsl:if test="not(@table:visibility = 'collapse' or @table:visibility = 'filter')">
121
122				<xsl:call-template name="create-column-element">
123					<xsl:with-param name="globalData"           select="$globalData" />
124					<xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
125					<xsl:with-param name="allTableColumns"      select="$allTableColumns" />
126				</xsl:call-template>
127			</xsl:if>
128		</xsl:for-each>
129
130		<xsl:call-template name="create-table-rows">
131			<xsl:with-param name="globalData"           select="$globalData" />
132			<xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
133			<xsl:with-param name="allTableColumns"      select="$allTableColumns" />
134		</xsl:call-template>
135	</xsl:template>
136
137	<!-- To be OVERWRITTEN -->
138	<xsl:template name="create-column-element" />
139
140	<!-- current node is a table:table-column -->
141	<xsl:template name="adding-column-styles-entries">
142		<xsl:param name="globalData" />
143		<xsl:param name="allTableColumns" />
144
145		<xsl:choose>
146			<!-- if parser reads DTD the default is set to '1' -->
147			<xsl:when test="not(@table:number-columns-repeated and @table:number-columns-repeated > 1)">
148				<!-- writes an entry of a column in the columns-variable -->
149				<xsl:copy-of select="." />
150			</xsl:when>
151			<!-- No higher repetition of cells greater than 99 for the last and second last column.
152				 This is a workaround for some sample document (Waehrungsumrechner.sxc),
153				 having 230 repeated columns in the second last column to emulate background -->
154			<!-- NOTE: Testcase with a table containing table:table-column-group and/or table:table-header-columns -->
155			<xsl:when test="(last() or (last() - 1)) and @table:number-columns-repeated &gt; 99">
156				<!-- writes an entry of a column in the columns-variable -->
157				<xsl:call-template name="repeat-adding-table-column">
158					<xsl:with-param name="numberColumnsRepeated"    select="1" />
159				</xsl:call-template>
160			</xsl:when>
161			<xsl:otherwise>
162				<!-- repeated colums will be written explicit several times in the variable-->
163				<xsl:call-template name="repeat-adding-table-column">
164					<xsl:with-param name="numberColumnsRepeated"    select="@table:number-columns-repeated" />
165				</xsl:call-template>
166			</xsl:otherwise>
167		</xsl:choose>
168	 </xsl:template>
169
170
171	<!-- WRITES THE REPEATED COLUMN STYLE EXPLICIT AS AN ELEMENT IN THE COLUMNS-VARIABLE -->
172	<!-- current node is a table:table-column -->
173	<xsl:template name="repeat-adding-table-column">
174		<xsl:param name="table:table-column" />
175		<xsl:param name="numberColumnsRepeated" />
176
177
178		<xsl:choose>
179			<xsl:when test="$numberColumnsRepeated > 1">
180				<!-- writes an entry of a column in the columns-variable -->
181				<xsl:copy-of select="." />
182				<!-- repeat calling this method until all elements written out -->
183				<xsl:call-template name="repeat-adding-table-column">
184					<xsl:with-param name="numberColumnsRepeated"    select="$numberColumnsRepeated - 1" />
185				</xsl:call-template>
186			</xsl:when>
187			<xsl:otherwise>
188				<!-- writes an entry of a column in the columns-variable -->
189				<xsl:copy-of select="." />
190			</xsl:otherwise>
191		</xsl:choose>
192	</xsl:template>
193
194
195	<!--debugEnabled-START-->
196	<!-- giving out the 'allColumnStyle' variable:
197		For each 'table:table-column' of the 'allTableColumns' variable the style-name is given out.
198		In case of 'column-hidden-flag' attribute the text 'Column is hidden is given out.-->
199	<!-- current node is a table:table -->
200	<xsl:template name="table-debug-allTableColumns">
201		<xsl:param name="allTableColumns" />
202
203		<!-- debug output as table summary attribut in html -->
204		<xsl:attribute name="summary">
205			<xsl:call-template name="table-debug-column-out">
206				<xsl:with-param name="allTableColumns" select="$allTableColumns" />
207			</xsl:call-template>
208		</xsl:attribute>
209		<!-- debug output to console -->
210		<xsl:message>
211			<xsl:call-template name="table-debug-column-out">
212				<xsl:with-param name="allTableColumns" select="$allTableColumns" />
213			</xsl:call-template>
214		</xsl:message>
215	</xsl:template>
216
217	<!-- current node is a table:table -->
218	<xsl:template name="table-debug-column-out">
219		<xsl:param name="allTableColumns" />
220			<xsl:text>
221			DebugInformation: For each 'table:table-column' of the 'allTableColumns' variable the style-name is given out.
222							  In case of table:visibility attribute unequal 'visible' the 'column is hidden' no text is given out.
223			</xsl:text>
224				<xsl:for-each select="$allTableColumns/table:table-column">
225				<xsl:choose>
226				<xsl:when test="@table:visibility = 'collapse' or @table:visibility = 'filter' ">
227			<xsl:text>  </xsl:text><xsl:value-of select="@table:style-name" /><xsl:text>column is hidden</xsl:text><xsl:text>
228			</xsl:text>
229				</xsl:when>
230				<xsl:otherwise>
231			<xsl:text>  </xsl:text><xsl:value-of select="@table:style-name" /><xsl:text> </xsl:text><xsl:value-of select="@table:default-cell-style-name" /><xsl:text>
232			</xsl:text>
233				</xsl:otherwise>
234				</xsl:choose>
235						   </xsl:for-each>
236	</xsl:template>
237	<!--debugEnabled-END-->
238
239</xsl:stylesheet>
240