1
<?xml version="1.0" encoding="UTF-8"?>
4
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6
Copyright 2008 by Sun Microsystems, Inc.
8
OpenOffice.org - a multi-platform office productivity suite
10
$RCSfile: table.xsl,v $
14
This file is part of OpenOffice.org.
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.
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).
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.
33
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
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
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">
64
<!-- table row handling -->
65
<xsl:include href="table_rows.xsl" />
66
<!-- table column handling -->
67
<xsl:include href="table_columns.xsl" />
68
<!-- table cell handling -->
69
<xsl:include href="table_cells.xsl" />
71
<xsl:param name="tableElement" select="'table'" />
73
<!-- ******************* -->
74
<!-- *** main table *** -->
75
<!-- ******************* -->
78
<xsl:template match="table:table" name="table:table">
79
<xsl:param name="globalData" />
81
<!-- The table will only be created if the table:scenario is active -->
82
<xsl:if test="not(table:scenario) or table:scenario/@table:is-active">
83
<xsl:call-template name="create-table">
84
<xsl:with-param name="globalData" select="$globalData" />
91
<xsl:template name="create-table">
92
<xsl:param name="globalData" />
94
<!-- by default '1', for each new sub/inner/nested table the number counts one up -->
95
<xsl:variable name="tableLevel" select="count(ancestor-or-self::table:table)" />
96
<!-- collecting all visible "table:table-row" elements of the table -->
97
<xsl:variable name="allVisibleTableRows" select="table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')][count(ancestor-or-self::table:table) = $tableLevel] |
98
table:table-header-rows/descendant::table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')][count(ancestor-or-self::table:table) = $tableLevel] |
99
table:table-row-group/descendant::table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')][count(ancestor-or-self::table:table) = $tableLevel]" />
100
<!-- As the alignment of a table is by 'align' attribut is deprecated and as the CSS 'float' attribute not well displayed,
101
we do a trick by encapsulating the table with a aligned 'div' element-->
102
<xsl:variable name="table-alignment" select="key('styles', @style:name = current()/@table:style-name)/*/@table:align" />
104
<xsl:when test="string-length($table-alignment) != 0">
105
<xsl:element namespace="{$namespace}" name="div">
106
<xsl:attribute name="style">
108
<xsl:when test='$table-alignment="left" or $table-alignment="margins"'>
109
<xsl:text>text-align:left</xsl:text>
111
<xsl:when test='$table-alignment="right"'>
112
<xsl:text>text-align:right</xsl:text>
114
<xsl:when test='$table-alignment="center"'>
115
<xsl:text>text-align:center</xsl:text>
119
<xsl:call-template name="create-table-element">
120
<xsl:with-param name="globalData" select="$globalData" />
121
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
126
<xsl:call-template name="create-table-element">
127
<xsl:with-param name="globalData" select="$globalData" />
128
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
135
<xsl:template name="create-table-element">
136
<xsl:param name="globalData" />
137
<xsl:param name="allVisibleTableRows" />
139
<xsl:element namespace="{$namespace}" name="{$tableElement}">
140
<xsl:attribute name="border">0</xsl:attribute>
141
<xsl:attribute name="cellspacing">0</xsl:attribute>
142
<xsl:attribute name="cellpadding">0</xsl:attribute>
144
<xsl:when test='name()="table:table"'>
145
<xsl:variable name="value" select="$globalData/all-doc-styles/style[@style:name = current()/@table:style-name]/*/@style:rel-width" />
146
<xsl:if test="$value">
147
<xsl:attribute name="width">
148
<xsl:value-of select="$value" />
153
<xsl:attribute name="width">100%</xsl:attribute>
157
<xsl:apply-templates select="@table:style-name">
158
<xsl:with-param name="globalData" select="$globalData" />
159
</xsl:apply-templates>
161
<xsl:call-template name="create-column-style-variable">
162
<xsl:with-param name="globalData" select="$globalData" />
163
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />