/xmlbench/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/xmlbench/trunk

« back to all changes in this revision

Viewing changes to xml.files/odt/export/common/table/table_columns.xsl

  • Committer: Suren A. Chilingaryan
  • Date: 2009-02-16 09:27:17 UTC
  • Revision ID: csa@dside.dyndns.org-20090216092717-wipyvaaw2srxhgns
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="UTF-8"?>
 
2
<!--
 
3
 
 
4
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
5
  
 
6
  Copyright 2008 by Sun Microsystems, Inc.
 
7
 
 
8
  OpenOffice.org - a multi-platform office productivity suite
 
9
 
 
10
  $RCSfile: table_columns.xsl,v $
 
11
 
 
12
  $Revision: 1.2.62.1 $
 
13
 
 
14
  This file is part of OpenOffice.org.
 
15
 
 
16
  OpenOffice.org is free software: you can redistribute it and/or modify
 
17
  it under the terms of the GNU Lesser General Public License version 3
 
18
  only, as published by the Free Software Foundation.
 
19
 
 
20
  OpenOffice.org is distributed in the hope that it will be useful,
 
21
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
22
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
23
  GNU Lesser General Public License version 3 for more details
 
24
  (a copy is included in the LICENSE file that accompanied this code).
 
25
 
 
26
  You should have received a copy of the GNU Lesser General Public License
 
27
  version 3 along with OpenOffice.org.  If not, see
 
28
  <http://www.openoffice.org/license.html>
 
29
  for a copy of the LGPLv3 License.
 
30
 
 
31
-->
 
32
<!--
 
33
        For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
 
34
-->
 
35
<xsl:stylesheet version="1.0"
 
36
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
37
        xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
 
38
        xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
 
39
        xmlns:dc="http://purl.org/dc/elements/1.1/"
 
40
        xmlns:dom="http://www.w3.org/2001/xml-events"
 
41
        xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
 
42
        xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
 
43
        xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
 
44
        xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
 
45
        xmlns:math="http://www.w3.org/1998/Math/MathML"
 
46
        xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
 
47
        xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
 
48
        xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
 
49
        xmlns:ooo="http://openoffice.org/2004/office"
 
50
        xmlns:oooc="http://openoffice.org/2004/calc"
 
51
        xmlns:ooow="http://openoffice.org/2004/writer"
 
52
        xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
 
53
        xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
 
54
        xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
 
55
        xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
 
56
        xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
 
57
        xmlns:xforms="http://www.w3.org/2002/xforms"
 
58
        xmlns:xlink="http://www.w3.org/1999/xlink"
 
59
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 
60
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 
61
        xmlns:xt="http://www.jclark.com/xt"
 
62
        xmlns:common="http://exslt.org/common"
 
63
        xmlns:xalan="http://xml.apache.org/xalan"
 
64
        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">
 
65
 
 
66
        <xsl:param name="tableColumnElement"            select="'col'" />
 
67
 
 
68
        <!-- ******************************************** -->
 
69
        <!-- *** Create table columns style variable  *** -->
 
70
        <!-- ******************************************** -->
 
71
 
 
72
        <!-- current node is a table:table -->
 
73
        <xsl:template name="create-column-style-variable">
 
74
                <xsl:param name="globalData" />
 
75
                <xsl:param name="allVisibleTableRows" />
 
76
 
 
77
                <!-- all columns of the table -->
 
78
                <xsl:variable name="allTableColumns" select="table:table-column |
 
79
                                                                                                         table:table-column-group/descendant::table:table-column |
 
80
                                                                                                         table:table-header-columns/descendant::table:table-column" />
 
81
                <!-- allTableColumns: Containing all columns of the table, hidden and viewed.
 
82
                        - if a column is hidden, if table:visibility has the value 'collapse' or 'filter', otherwise the value is 'visible'
 
83
                        - if a column is being repeated, each repeated column is explicitly written as entry in this variable.
 
84
                          Later (during template "write-cell") the style of the column will be mixed with the cell-style by using
 
85
                          the position() of the column entry and comparing it with the iterating cell number. -->
 
86
                <xsl:variable name="allTableColumns-RTF">
 
87
                        <xsl:for-each select="$allTableColumns">
 
88
                                <xsl:call-template name="adding-column-styles-entries">
 
89
                                        <xsl:with-param name="globalData"       select="$globalData" />
 
90
                                        <xsl:with-param name="allTableColumns"  select="$allTableColumns" />
 
91
                                </xsl:call-template>
 
92
                        </xsl:for-each>
 
93
                </xsl:variable>
 
94
 
 
95
                <xsl:choose>
 
96
                        <xsl:when test="function-available('common:node-set')">
 
97
                                <xsl:call-template name="create-table-children">
 
98
                                        <xsl:with-param name="globalData"           select="$globalData" />
 
99
                                        <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
 
100
                                        <xsl:with-param name="allTableColumns"      select="common:node-set($allTableColumns-RTF)" />
 
101
                                </xsl:call-template>
 
102
                        </xsl:when>
 
103
                        <xsl:when test="function-available('xalan:nodeset')">
 
104
                                <xsl:call-template name="create-table-children">
 
105
                                        <xsl:with-param name="globalData"           select="$globalData" />
 
106
                                        <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
 
107
                                        <xsl:with-param name="allTableColumns"      select="xalan:nodeset($allTableColumns-RTF)" />
 
108
                                </xsl:call-template>
 
109
                        </xsl:when>
 
110
                        <xsl:when test="function-available('xt:node-set')">
 
111
                                <xsl:call-template name="create-table-children">
 
112
                                        <xsl:with-param name="globalData"           select="$globalData" />
 
113
                                        <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
 
114
                                        <xsl:with-param name="allTableColumns"      select="xt:node-set($allTableColumns-RTF)" />
 
115
                                </xsl:call-template>
 
116
                        </xsl:when>
 
117
                </xsl:choose>
 
118
        </xsl:template>
 
119
 
 
120
        <!-- current node is a table:table -->
 
121
        <xsl:template name="create-table-children">
 
122
                <xsl:param name="globalData" />
 
123
                <xsl:param name="allVisibleTableRows" />
 
124
                <xsl:param name="allTableColumns" />
 
125
 
 
126
 
 
127
                <xsl:for-each select="$allTableColumns/table:table-column">
 
128
                        <xsl:if test="not(@table:visibility = 'collapse' or @table:visibility = 'filter')">
 
129
 
 
130
                                <xsl:call-template name="create-column-element">
 
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:if>
 
136
                </xsl:for-each>
 
137
 
 
138
                <xsl:call-template name="create-table-rows">
 
139
                        <xsl:with-param name="globalData"           select="$globalData" />
 
140
                        <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
 
141
                        <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
 
142
                </xsl:call-template>
 
143
        </xsl:template>
 
144
 
 
145
        <!-- To be OVERWRITTEN -->
 
146
        <xsl:template name="create-column-element" />
 
147
 
 
148
        <!-- current node is a table:table-column -->
 
149
        <xsl:template name="adding-column-styles-entries">
 
150
                <xsl:param name="globalData" />
 
151
                <xsl:param name="allTableColumns" />
 
152
 
 
153
                <xsl:choose>
 
154
                        <!-- if parser reads DTD the default is set to '1' -->
 
155
                        <xsl:when test="not(@table:number-columns-repeated and @table:number-columns-repeated > 1)">
 
156
                                <!-- writes an entry of a column in the columns-variable -->
 
157
                                <xsl:copy-of select="." />
 
158
                        </xsl:when>
 
159
                        <!-- No higher repetition of cells greater than 99 for the last and second last column.
 
160
                                 This is a workaround for some sample document (Waehrungsumrechner.sxc),
 
161
                                 having 230 repeated columns in the second last column to emulate background -->
 
162
                        <!-- NOTE: Testcase with a table containing table:table-column-group and/or table:table-header-columns -->
 
163
                        <xsl:when test="(last() or (last() - 1)) and @table:number-columns-repeated &gt; 99">
 
164
                                <!-- writes an entry of a column in the columns-variable -->
 
165
                                <xsl:call-template name="repeat-adding-table-column">
 
166
                                        <xsl:with-param name="numberColumnsRepeated"    select="1" />
 
167
                                </xsl:call-template>
 
168
                        </xsl:when>
 
169
                        <xsl:otherwise>
 
170
                                <!-- repeated colums will be written explicit several times in the variable-->
 
171
                                <xsl:call-template name="repeat-adding-table-column">
 
172
                                        <xsl:with-param name="numberColumnsRepeated"    select="@table:number-columns-repeated" />
 
173
                                </xsl:call-template>
 
174
                        </xsl:otherwise>
 
175
                </xsl:choose>
 
176
         </xsl:template>
 
177
 
 
178
 
 
179
        <!-- WRITES THE REPEATED COLUMN STYLE EXPLICIT AS AN ELEMENT IN THE COLUMNS-VARIABLE -->
 
180
        <!-- current node is a table:table-column -->
 
181
        <xsl:template name="repeat-adding-table-column">
 
182
                <xsl:param name="table:table-column" />
 
183
                <xsl:param name="numberColumnsRepeated" />
 
184
 
 
185
 
 
186
                <xsl:choose>
 
187
                        <xsl:when test="$numberColumnsRepeated > 1">
 
188
                                <!-- writes an entry of a column in the columns-variable -->
 
189
                                <xsl:copy-of select="." />
 
190
                                <!-- repeat calling this method until all elements written out -->
 
191
                                <xsl:call-template name="repeat-adding-table-column">
 
192
                                        <xsl:with-param name="numberColumnsRepeated"    select="$numberColumnsRepeated - 1" />
 
193
                                </xsl:call-template>
 
194
                        </xsl:when>
 
195
                        <xsl:otherwise>
 
196
                                <!-- writes an entry of a column in the columns-variable -->
 
197
                                <xsl:copy-of select="." />
 
198
                        </xsl:otherwise>
 
199
                </xsl:choose>
 
200
        </xsl:template>
 
201
 
 
202
 
 
203
        <!--debugEnabled-START-->
 
204
        <!-- giving out the 'allColumnStyle' variable:
 
205
                For each 'table:table-column' of the 'allTableColumns' variable the style-name is given out.
 
206
                In case of 'column-hidden-flag' attribute the text 'Column is hidden is given out.-->
 
207
        <!-- current node is a table:table -->
 
208
        <xsl:template name="table-debug-allTableColumns">
 
209
                <xsl:param name="allTableColumns" />
 
210
 
 
211
                <!-- debug output as table summary attribut in html -->
 
212
                <xsl:attribute name="summary">
 
213
                        <xsl:call-template name="table-debug-column-out">
 
214
                                <xsl:with-param name="allTableColumns" select="$allTableColumns" />
 
215
                        </xsl:call-template>
 
216
                </xsl:attribute>
 
217
                <!-- debug output to console -->
 
218
                <xsl:message>
 
219
                        <xsl:call-template name="table-debug-column-out">
 
220
                                <xsl:with-param name="allTableColumns" select="$allTableColumns" />
 
221
                        </xsl:call-template>
 
222
                </xsl:message>
 
223
        </xsl:template>
 
224
 
 
225
        <!-- current node is a table:table -->
 
226
        <xsl:template name="table-debug-column-out">
 
227
                <xsl:param name="allTableColumns" />
 
228
                        <xsl:text>
 
229
                        DebugInformation: For each 'table:table-column' of the 'allTableColumns' variable the style-name is given out.
 
230
                                                          In case of table:visibility attribute unequal 'visible' the 'column is hidden' no text is given out.
 
231
                        </xsl:text>
 
232
                                <xsl:for-each select="$allTableColumns/table:table-column">
 
233
                                <xsl:choose>
 
234
                                <xsl:when test="@table:visibility = 'collapse' or @table:visibility = 'filter' ">
 
235
                        <xsl:text>  </xsl:text><xsl:value-of select="@table:style-name" /><xsl:text>column is hidden</xsl:text><xsl:text>
 
236
                        </xsl:text>
 
237
                                </xsl:when>
 
238
                                <xsl:otherwise>
 
239
                        <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>
 
240
                        </xsl:text>
 
241
                                </xsl:otherwise>
 
242
                                </xsl:choose>
 
243
                                                   </xsl:for-each>
 
244
        </xsl:template>
 
245
        <!--debugEnabled-END-->
 
246
 
 
247
</xsl:stylesheet>