html2odt 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +32 -0
- data/LICENSE.txt +21 -0
- data/README.md +163 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/html2odt.gemspec +29 -0
- data/lib/html2odt/document.rb +309 -0
- data/lib/html2odt/image.rb +82 -0
- data/lib/html2odt/version.rb +3 -0
- data/lib/html2odt.rb +18 -0
- data/odt/template.odt +0 -0
- data/xsl/LICENSE.txt +502 -0
- data/xsl/README.rst +144 -0
- data/xsl/document-content/block.xsl +169 -0
- data/xsl/document-content/html5.xsl +122 -0
- data/xsl/document-content/ignore.xsl +93 -0
- data/xsl/document-content/inline.xsl +167 -0
- data/xsl/document-content/link.xsl +127 -0
- data/xsl/document-content/lists.xsl +130 -0
- data/xsl/document-content/media.xsl +130 -0
- data/xsl/document-content/paragraph.xsl +151 -0
- data/xsl/document-content/section.xsl +80 -0
- data/xsl/document-content/tables.xsl +334 -0
- data/xsl/document-content.xsl +63 -0
- data/xsl/param.xsl +70 -0
- data/xsl/specific/elyxer.xsl +93 -0
- data/xsl/specific/geshi.xsl +94 -0
- data/xsl/specific/lyx.xsl +101 -0
- data/xsl/specific/pygments.xsl +170 -0
- data/xsl/specific/trac.xsl +61 -0
- data/xsl/specific.xsl +58 -0
- data/xsl/styles/automatic-styles.xsl +388 -0
- data/xsl/styles/fonts.xsl +62 -0
- data/xsl/styles/highlight.xsl +152 -0
- data/xsl/styles/inline.xsl +114 -0
- data/xsl/styles/main-styles.xsl +455 -0
- data/xsl/styles.xsl +143 -0
- data/xsl/xhtml2odt.xsl +116 -0
- metadata +185 -0
@@ -0,0 +1,151 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!--
|
3
|
+
|
4
|
+
xhtml2odt - XHTML to ODT XML transformation.
|
5
|
+
Copyright (C) 2009 Aurelien Bompard
|
6
|
+
Inspired by the work on docbook2odt, by Roman Fordinal
|
7
|
+
http://open.comsultia.com/docbook2odf/
|
8
|
+
|
9
|
+
License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html>
|
10
|
+
|
11
|
+
This library is free software; you can redistribute it and/or
|
12
|
+
modify it under the terms of the GNU Lesser General Public
|
13
|
+
License as published by the Free Software Foundation; either
|
14
|
+
version 2.1 of the License, or (at your option) any later version.
|
15
|
+
|
16
|
+
This library is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19
|
+
Lesser General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU Lesser General Public
|
22
|
+
License along with this library; if not, write to the Free Software
|
23
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
24
|
+
MA 02110-1301 USA
|
25
|
+
|
26
|
+
-->
|
27
|
+
<xsl:stylesheet
|
28
|
+
xmlns:h="http://www.w3.org/1999/xhtml"
|
29
|
+
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
30
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
31
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
32
|
+
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
33
|
+
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
34
|
+
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
35
|
+
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
36
|
+
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
37
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
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:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
41
|
+
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
42
|
+
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
43
|
+
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
44
|
+
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
45
|
+
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
46
|
+
xmlns:dom="http://www.w3.org/2001/xml-events"
|
47
|
+
xmlns:xforms="http://www.w3.org/2002/xforms"
|
48
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
49
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
50
|
+
xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
|
51
|
+
version="1.0">
|
52
|
+
|
53
|
+
|
54
|
+
<xsl:template match="h:p">
|
55
|
+
<xsl:call-template name="paragraph"/>
|
56
|
+
</xsl:template>
|
57
|
+
<xsl:template match="h:p" mode="inparagraph">
|
58
|
+
<xsl:apply-templates mode="inparagraph"/>
|
59
|
+
</xsl:template>
|
60
|
+
|
61
|
+
<xsl:template name="paragraph">
|
62
|
+
<xsl:choose>
|
63
|
+
<xsl:when test="
|
64
|
+
child::h:ul|
|
65
|
+
child::h:ol|
|
66
|
+
child::h:blockquote|
|
67
|
+
child::h:pre |
|
68
|
+
child::h:dl |
|
69
|
+
child::h:div
|
70
|
+
">
|
71
|
+
<xsl:for-each select="
|
72
|
+
child::h:ul |
|
73
|
+
child::h:ol |
|
74
|
+
child::h:blockquote |
|
75
|
+
child::h:pre |
|
76
|
+
child::h:dl |
|
77
|
+
child::h:div
|
78
|
+
">
|
79
|
+
<!-- Paragraph with the text before -->
|
80
|
+
<xsl:if test="preceding-sibling::node()">
|
81
|
+
<xsl:call-template name="paragraph-content">
|
82
|
+
<xsl:with-param name="subject" select="preceding-sibling::node()"/>
|
83
|
+
</xsl:call-template>
|
84
|
+
</xsl:if>
|
85
|
+
<!-- Create the block-type element -->
|
86
|
+
<xsl:apply-templates select="."/>
|
87
|
+
<!-- Paragraph with the text after -->
|
88
|
+
<xsl:if test="following-sibling::node()">
|
89
|
+
<xsl:call-template name="paragraph-content">
|
90
|
+
<xsl:with-param name="subject" select="following-sibling::node()"/>
|
91
|
+
</xsl:call-template>
|
92
|
+
</xsl:if>
|
93
|
+
</xsl:for-each>
|
94
|
+
</xsl:when>
|
95
|
+
<xsl:otherwise>
|
96
|
+
<xsl:call-template name="paragraph-content">
|
97
|
+
<xsl:with-param name="subject" select="node()"/>
|
98
|
+
</xsl:call-template>
|
99
|
+
</xsl:otherwise>
|
100
|
+
</xsl:choose>
|
101
|
+
</xsl:template>
|
102
|
+
|
103
|
+
|
104
|
+
<xsl:template name="paragraph-content">
|
105
|
+
|
106
|
+
<xsl:param name="subject"/>
|
107
|
+
|
108
|
+
<text:p>
|
109
|
+
|
110
|
+
<xsl:attribute name="text:style-name">
|
111
|
+
<xsl:choose>
|
112
|
+
<!-- those two seem unnecessary, it's handled in lists.xsl -->
|
113
|
+
<xsl:when test="$subject/parent::h:ul">
|
114
|
+
<xsl:text>list-item-bullet</xsl:text>
|
115
|
+
</xsl:when>
|
116
|
+
<xsl:when test="$subject/parent::h:ol">
|
117
|
+
<xsl:text>list-item-number</xsl:text>
|
118
|
+
</xsl:when>
|
119
|
+
<xsl:when test="$subject/../parent::h:blockquote">Quotations</xsl:when>
|
120
|
+
<xsl:when test="contains(@style,'text-align:') and contains(@style,'left')">left</xsl:when>
|
121
|
+
<xsl:when test="contains(@style,'text-align:') and contains(@style,'center')">center</xsl:when>
|
122
|
+
<xsl:when test="contains(@style,'text-align:') and contains(@style,'right')">right</xsl:when>
|
123
|
+
<xsl:when test="contains(@style,'text-align:') and contains(@style,'justify')">justify</xsl:when>
|
124
|
+
<xsl:when test="$subject/self::h:address or (name($subject) = '' and $subject/parent::h:address)">Sender</xsl:when>
|
125
|
+
<xsl:when test="$subject/self::h:center or (name($subject) = '' and $subject/parent::h:center)">center</xsl:when>
|
126
|
+
<xsl:when test="$subject/self::h:th or (name($subject) = '' and $subject/parent::h:th)">Table_20_Heading</xsl:when>
|
127
|
+
<xsl:when test="$subject/self::h:td or (name($subject) = '' and $subject/parent::h:td)">Table_20_Contents</xsl:when>
|
128
|
+
<xsl:when test="$subject/self::h:dt or (name($subject) = '' and $subject/parent::h:dt)">Definition_20_Term</xsl:when>
|
129
|
+
<xsl:when test="$subject/self::h:dd or (name($subject) = '' and $subject/parent::h:dd)">Definition_20_Description</xsl:when>
|
130
|
+
<xsl:otherwise>Text_20_body</xsl:otherwise>
|
131
|
+
</xsl:choose>
|
132
|
+
</xsl:attribute>
|
133
|
+
|
134
|
+
<xsl:for-each select="$subject">
|
135
|
+
<xsl:choose>
|
136
|
+
<xsl:when test="name() = ''">
|
137
|
+
<!-- text node -->
|
138
|
+
<xsl:value-of select="string()"/>
|
139
|
+
</xsl:when>
|
140
|
+
<xsl:otherwise>
|
141
|
+
<xsl:apply-templates select="." mode="inparagraph"/>
|
142
|
+
</xsl:otherwise>
|
143
|
+
</xsl:choose>
|
144
|
+
</xsl:for-each>
|
145
|
+
|
146
|
+
</text:p>
|
147
|
+
|
148
|
+
</xsl:template>
|
149
|
+
|
150
|
+
|
151
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,80 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!--
|
3
|
+
|
4
|
+
xhtml2odt - XHTML to ODT XML transformation.
|
5
|
+
Copyright (C) 2009 Aurelien Bompard
|
6
|
+
Inspired by the work on docbook2odt, by Roman Fordinal
|
7
|
+
http://open.comsultia.com/docbook2odf/
|
8
|
+
|
9
|
+
License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html>
|
10
|
+
|
11
|
+
This library is free software; you can redistribute it and/or
|
12
|
+
modify it under the terms of the GNU Lesser General Public
|
13
|
+
License as published by the Free Software Foundation; either
|
14
|
+
version 2.1 of the License, or (at your option) any later version.
|
15
|
+
|
16
|
+
This library is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19
|
+
Lesser General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU Lesser General Public
|
22
|
+
License along with this library; if not, write to the Free Software
|
23
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
24
|
+
MA 02110-1301 USA
|
25
|
+
|
26
|
+
-->
|
27
|
+
<xsl:stylesheet
|
28
|
+
xmlns:h="http://www.w3.org/1999/xhtml"
|
29
|
+
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
30
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
31
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
32
|
+
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
33
|
+
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
34
|
+
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
35
|
+
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
36
|
+
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
37
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
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:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
41
|
+
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
42
|
+
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
43
|
+
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
44
|
+
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
45
|
+
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
46
|
+
xmlns:dom="http://www.w3.org/2001/xml-events"
|
47
|
+
xmlns:xforms="http://www.w3.org/2002/xforms"
|
48
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
49
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
50
|
+
xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
|
51
|
+
version="1.0">
|
52
|
+
|
53
|
+
|
54
|
+
<xsl:template name="section" match="h:h1|h:h2|h:h3|h:h4|h:h5|h:h6">
|
55
|
+
|
56
|
+
<!-- compute level of section -->
|
57
|
+
<xsl:variable name="level">
|
58
|
+
<xsl:value-of select="substring-after(local-name(.),'h') - $heading_minus_level"/>
|
59
|
+
</xsl:variable>
|
60
|
+
|
61
|
+
<xsl:comment>
|
62
|
+
<xsl:text>section level </xsl:text><xsl:value-of select="$level"/>
|
63
|
+
</xsl:comment>
|
64
|
+
|
65
|
+
<text:h>
|
66
|
+
<xsl:attribute name="text:style-name"><xsl:text>Heading_20_</xsl:text>
|
67
|
+
<xsl:value-of select="$level"/>
|
68
|
+
</xsl:attribute>
|
69
|
+
<xsl:attribute name="text:outline-level">
|
70
|
+
<xsl:value-of select="$level"/>
|
71
|
+
</xsl:attribute>
|
72
|
+
|
73
|
+
<xsl:apply-templates mode="inparagraph"/>
|
74
|
+
|
75
|
+
</text:h>
|
76
|
+
|
77
|
+
</xsl:template>
|
78
|
+
|
79
|
+
|
80
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,334 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!--
|
3
|
+
|
4
|
+
xhtml2odt - XHTML to ODT XML transformation.
|
5
|
+
Copyright (C) 2009 Aurelien Bompard
|
6
|
+
Inspired by the work on docbook2odt, by Roman Fordinal
|
7
|
+
http://open.comsultia.com/docbook2odf/
|
8
|
+
|
9
|
+
License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html>
|
10
|
+
|
11
|
+
This library is free software; you can redistribute it and/or
|
12
|
+
modify it under the terms of the GNU Lesser General Public
|
13
|
+
License as published by the Free Software Foundation; either
|
14
|
+
version 2.1 of the License, or (at your option) any later version.
|
15
|
+
|
16
|
+
This library is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19
|
+
Lesser General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU Lesser General Public
|
22
|
+
License along with this library; if not, write to the Free Software
|
23
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
24
|
+
MA 02110-1301 USA
|
25
|
+
|
26
|
+
-->
|
27
|
+
<xsl:stylesheet
|
28
|
+
xmlns:h="http://www.w3.org/1999/xhtml"
|
29
|
+
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
30
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
31
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
32
|
+
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
33
|
+
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
34
|
+
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
35
|
+
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
36
|
+
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
37
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
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:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
41
|
+
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
42
|
+
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
43
|
+
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
44
|
+
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
45
|
+
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
46
|
+
xmlns:dom="http://www.w3.org/2001/xml-events"
|
47
|
+
xmlns:xforms="http://www.w3.org/2002/xforms"
|
48
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
49
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
50
|
+
xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
|
51
|
+
version="1.0">
|
52
|
+
|
53
|
+
|
54
|
+
<xsl:template name="table.number">
|
55
|
+
<!-- compute number of section -->
|
56
|
+
<xsl:value-of select="count(preceding::h:table)+1"/>
|
57
|
+
</xsl:template>
|
58
|
+
|
59
|
+
<xsl:template match="h:table">
|
60
|
+
<table:table table:style-name="table-default">
|
61
|
+
<table:table-column>
|
62
|
+
<xsl:attribute name="table:number-columns-repeated">
|
63
|
+
<xsl:value-of select="count(descendant::h:tr[1]/h:th|descendant::h:tr[1]/h:td)"/>
|
64
|
+
</xsl:attribute>
|
65
|
+
</table:table-column>
|
66
|
+
<!--<xsl:attribute name="table:name"></xsl:attribute>-->
|
67
|
+
<xsl:apply-templates/>
|
68
|
+
<xsl:apply-templates select="h:tfoot/*"/>
|
69
|
+
</table:table>
|
70
|
+
<xsl:if test="h:caption">
|
71
|
+
<xsl:variable name="number">
|
72
|
+
<xsl:call-template name="table.number"/>
|
73
|
+
</xsl:variable>
|
74
|
+
<text:p text:style-name="Caption">
|
75
|
+
<xsl:text>Table </xsl:text>
|
76
|
+
<text:sequence text:ref-name="refTable0" text:name="Table"
|
77
|
+
text:formula="ooow:Table+1" style:num-format="1">
|
78
|
+
<xsl:value-of select="$number"/>
|
79
|
+
</text:sequence>
|
80
|
+
<xsl:text>: </xsl:text><xsl:value-of select="h:caption"/>
|
81
|
+
</text:p>
|
82
|
+
</xsl:if>
|
83
|
+
</xsl:template>
|
84
|
+
|
85
|
+
<xsl:template match="h:table/h:caption"/>
|
86
|
+
|
87
|
+
<xsl:template match="h:thead">
|
88
|
+
<!-- <table:table-header-rows> handled in <th> -->
|
89
|
+
<xsl:apply-templates/>
|
90
|
+
</xsl:template>
|
91
|
+
|
92
|
+
<xsl:template match="h:tfoot">
|
93
|
+
<!-- handled above in h:table -->
|
94
|
+
</xsl:template>
|
95
|
+
|
96
|
+
<xsl:template match="h:tbody">
|
97
|
+
<xsl:apply-templates/>
|
98
|
+
</xsl:template>
|
99
|
+
|
100
|
+
<xsl:template match="h:tr">
|
101
|
+
<xsl:choose>
|
102
|
+
<!-- this is header -->
|
103
|
+
<xsl:when test="h:th">
|
104
|
+
<table:table-header-rows>
|
105
|
+
<xsl:call-template name="make-table-row"/>
|
106
|
+
</table:table-header-rows>
|
107
|
+
</xsl:when>
|
108
|
+
<xsl:otherwise>
|
109
|
+
<xsl:call-template name="make-table-row"/>
|
110
|
+
</xsl:otherwise>
|
111
|
+
</xsl:choose>
|
112
|
+
</xsl:template>
|
113
|
+
|
114
|
+
<xsl:template name="make-table-row">
|
115
|
+
<table:table-row>
|
116
|
+
<!-- fill covered-table-cells for rowspans on the first column -->
|
117
|
+
<xsl:for-each select="preceding-sibling::h:tr/*[position() = 1 and @rowspan != 1]">
|
118
|
+
<xsl:call-template name="make-rowspan-covered-table-cell">
|
119
|
+
<xsl:with-param name="vertical-position">
|
120
|
+
<xsl:value-of select="count(preceding-sibling::h:tr) + 1"/>
|
121
|
+
</xsl:with-param>
|
122
|
+
</xsl:call-template>
|
123
|
+
</xsl:for-each>
|
124
|
+
<!-- do the cell handling now -->
|
125
|
+
<xsl:apply-templates/>
|
126
|
+
</table:table-row>
|
127
|
+
</xsl:template>
|
128
|
+
|
129
|
+
<xsl:template match="h:th">
|
130
|
+
<xsl:call-template name="table-cell">
|
131
|
+
<xsl:with-param name="horizontal-position" select="count(preceding-sibling::*) + 1"/>
|
132
|
+
<xsl:with-param name="horizontal-count" select="count(../*)"/>
|
133
|
+
<xsl:with-param name="vertical-position" select="count(../preceding-sibling::h:tr) + 1"/>
|
134
|
+
<xsl:with-param name="vertical-count" select="count(ancestor::h:table[1]/descendant::h:tr)"/>
|
135
|
+
</xsl:call-template>
|
136
|
+
</xsl:template>
|
137
|
+
|
138
|
+
<xsl:template match="h:td">
|
139
|
+
<xsl:call-template name="table-cell">
|
140
|
+
<xsl:with-param name="horizontal-position" select="count(preceding-sibling::*) + 1"/>
|
141
|
+
<xsl:with-param name="horizontal-count" select="count(../*)"/>
|
142
|
+
<xsl:with-param name="vertical-position" select="count(../preceding-sibling::h:tr)
|
143
|
+
+ count(ancestor::h:table[1]/descendant::h:thead/h:tr)
|
144
|
+
+ 1"/>
|
145
|
+
<xsl:with-param name="vertical-count" select="count(ancestor::h:table[1]/descendant::h:tr)"/>
|
146
|
+
</xsl:call-template>
|
147
|
+
</xsl:template>
|
148
|
+
|
149
|
+
|
150
|
+
<!-- table cell -->
|
151
|
+
|
152
|
+
<xsl:template name="table-cell">
|
153
|
+
|
154
|
+
<xsl:param name="horizontal-position" />
|
155
|
+
<xsl:param name="horizontal-count" />
|
156
|
+
<xsl:param name="vertical-position" />
|
157
|
+
<xsl:param name="vertical-count" />
|
158
|
+
|
159
|
+
<xsl:comment>horizontal-position=<xsl:value-of select="$horizontal-position"/></xsl:comment>
|
160
|
+
<xsl:comment>horizontal-count=<xsl:value-of select="$horizontal-count"/></xsl:comment>
|
161
|
+
<xsl:comment>vertical-position=<xsl:value-of select="$vertical-position"/></xsl:comment>
|
162
|
+
<xsl:comment>vertical-count=<xsl:value-of select="$vertical-count"/></xsl:comment>
|
163
|
+
|
164
|
+
<table:table-cell office:value-type="string">
|
165
|
+
|
166
|
+
<xsl:attribute name="table:style-name">
|
167
|
+
<xsl:text>table-default.cell-</xsl:text>
|
168
|
+
<!-- prefix -->
|
169
|
+
<xsl:if test="self::h:th and $vertical-position = 1">
|
170
|
+
<xsl:text>H-</xsl:text>
|
171
|
+
</xsl:if>
|
172
|
+
<xsl:if test="parent::h:tr/parent::h:tfoot">
|
173
|
+
<xsl:text>F-</xsl:text>
|
174
|
+
</xsl:if>
|
175
|
+
<!-- postfix defined by cell position -->
|
176
|
+
<!--
|
177
|
+
__________
|
178
|
+
|A1|B1|C1|
|
179
|
+
|A2|B2|C2|
|
180
|
+
|A3|B3|C3|
|
181
|
+
^^^^^^^^^^
|
182
|
+
__________
|
183
|
+
|A4|B4|C4|
|
184
|
+
^^^^^^^^^^
|
185
|
+
____
|
186
|
+
|C1|
|
187
|
+
|C2|
|
188
|
+
|C3|
|
189
|
+
^^^^
|
190
|
+
-->
|
191
|
+
<xsl:choose>
|
192
|
+
|
193
|
+
<!-- single -->
|
194
|
+
<xsl:when test="$horizontal-count = 1 and $vertical-count = 1">
|
195
|
+
<xsl:text>single</xsl:text>
|
196
|
+
</xsl:when>
|
197
|
+
|
198
|
+
<!-- A4 -->
|
199
|
+
<xsl:when test="$horizontal-position = 1 and $vertical-count = 1">
|
200
|
+
<xsl:text>A4</xsl:text>
|
201
|
+
</xsl:when>
|
202
|
+
<!-- C4 -->
|
203
|
+
<xsl:when test="$horizontal-position = $horizontal-count and $vertical-count = 1">
|
204
|
+
<xsl:text>C4</xsl:text>
|
205
|
+
</xsl:when>
|
206
|
+
<!-- B4 -->
|
207
|
+
<xsl:when test="$vertical-count = 1">
|
208
|
+
<xsl:text>B4</xsl:text>
|
209
|
+
</xsl:when>
|
210
|
+
|
211
|
+
<!-- tfoot A -->
|
212
|
+
<xsl:when test="ancestor::h:tfoot and $horizontal-position = 1">
|
213
|
+
<xsl:text>A3</xsl:text>
|
214
|
+
</xsl:when>
|
215
|
+
<!-- tfoot B -->
|
216
|
+
<xsl:when test="ancestor::h:tfoot and $horizontal-position = $horizontal-count">
|
217
|
+
<xsl:text>C3</xsl:text>
|
218
|
+
</xsl:when>
|
219
|
+
<!-- tfoot C -->
|
220
|
+
<xsl:when test="ancestor::h:tfoot">
|
221
|
+
<xsl:text>B3</xsl:text>
|
222
|
+
</xsl:when>
|
223
|
+
|
224
|
+
<!-- A3 -->
|
225
|
+
<xsl:when test="$horizontal-position = 1 and $horizontal-count != 1 and $vertical-position = $vertical-count">
|
226
|
+
<xsl:text>A3</xsl:text>
|
227
|
+
</xsl:when>
|
228
|
+
<!-- C3 -->
|
229
|
+
<xsl:when test="$horizontal-position = $horizontal-count and $vertical-position = $vertical-count">
|
230
|
+
<xsl:text>C3</xsl:text>
|
231
|
+
</xsl:when>
|
232
|
+
<!-- B3 -->
|
233
|
+
<xsl:when test="$vertical-position = $vertical-count">
|
234
|
+
<xsl:text>B3</xsl:text>
|
235
|
+
</xsl:when>
|
236
|
+
|
237
|
+
<!-- A1 -->
|
238
|
+
<xsl:when test="$horizontal-position = 1 and $horizontal-position != $horizontal-count and $vertical-position = 1">
|
239
|
+
<xsl:text>A1</xsl:text>
|
240
|
+
</xsl:when>
|
241
|
+
<!-- C1 -->
|
242
|
+
<xsl:when test="$horizontal-position = $horizontal-count and $vertical-position = 1">
|
243
|
+
<xsl:text>C1</xsl:text>
|
244
|
+
</xsl:when>
|
245
|
+
<!-- B1 -->
|
246
|
+
<xsl:when test="$vertical-position = 1">
|
247
|
+
<xsl:text>B1</xsl:text>
|
248
|
+
</xsl:when>
|
249
|
+
|
250
|
+
<!-- A2 -->
|
251
|
+
<xsl:when test="$horizontal-position = 1 and $horizontal-position != $horizontal-count">
|
252
|
+
<xsl:text>A2</xsl:text>
|
253
|
+
</xsl:when>
|
254
|
+
<!-- C2 -->
|
255
|
+
<xsl:when test="$horizontal-position = $horizontal-count">
|
256
|
+
<xsl:text>C2</xsl:text>
|
257
|
+
</xsl:when>
|
258
|
+
|
259
|
+
<!-- all other cells -->
|
260
|
+
<xsl:otherwise>
|
261
|
+
<xsl:text>B2</xsl:text>
|
262
|
+
</xsl:otherwise>
|
263
|
+
|
264
|
+
</xsl:choose>
|
265
|
+
|
266
|
+
</xsl:attribute>
|
267
|
+
|
268
|
+
<xsl:if test="@colspan and @colspan != 1">
|
269
|
+
<xsl:attribute name="table:number-columns-spanned">
|
270
|
+
<xsl:value-of select="@colspan"/>
|
271
|
+
</xsl:attribute>
|
272
|
+
</xsl:if>
|
273
|
+
|
274
|
+
<xsl:if test="@rowspan and @rowspan != 1">
|
275
|
+
<xsl:attribute name="table:number-rows-spanned">
|
276
|
+
<xsl:value-of select="@rowspan"/>
|
277
|
+
</xsl:attribute>
|
278
|
+
</xsl:if>
|
279
|
+
|
280
|
+
<!-- Content -->
|
281
|
+
<xsl:choose>
|
282
|
+
<xsl:when test="h:table"> <!-- nested tables -->
|
283
|
+
<xsl:apply-templates/>
|
284
|
+
</xsl:when>
|
285
|
+
<xsl:otherwise>
|
286
|
+
<xsl:call-template name="paragraph"/>
|
287
|
+
</xsl:otherwise>
|
288
|
+
</xsl:choose>
|
289
|
+
|
290
|
+
</table:table-cell>
|
291
|
+
|
292
|
+
<!-- fill covered-table-cells for colspans -->
|
293
|
+
<xsl:if test="@colspan and @colspan != 1">
|
294
|
+
<xsl:call-template name="make-covered-table-cell">
|
295
|
+
<xsl:with-param name="num">
|
296
|
+
<xsl:value-of select="@colspan"/>
|
297
|
+
</xsl:with-param>
|
298
|
+
</xsl:call-template>
|
299
|
+
</xsl:if>
|
300
|
+
|
301
|
+
<!-- fill covered-table-cells for rowspans -->
|
302
|
+
<xsl:for-each select="../preceding-sibling::h:tr/*[position() = $horizontal-position + 1 and @rowspan != 1]">
|
303
|
+
<xsl:call-template name="make-rowspan-covered-table-cell">
|
304
|
+
<xsl:with-param name="vertical-position">
|
305
|
+
<xsl:value-of select="$vertical-position"/>
|
306
|
+
</xsl:with-param>
|
307
|
+
</xsl:call-template>
|
308
|
+
</xsl:for-each>
|
309
|
+
|
310
|
+
</xsl:template>
|
311
|
+
|
312
|
+
|
313
|
+
<xsl:template name="make-covered-table-cell">
|
314
|
+
<xsl:param name="num"/>
|
315
|
+
<xsl:if test="$num > 1">
|
316
|
+
<table:covered-table-cell/>
|
317
|
+
<xsl:call-template name="make-covered-table-cell">
|
318
|
+
<xsl:with-param name="num">
|
319
|
+
<xsl:value-of select="$num - 1"/>
|
320
|
+
</xsl:with-param>
|
321
|
+
</xsl:call-template>
|
322
|
+
</xsl:if>
|
323
|
+
</xsl:template>
|
324
|
+
|
325
|
+
<xsl:template name="make-rowspan-covered-table-cell">
|
326
|
+
<xsl:param name="vertical-position"/>
|
327
|
+
<xsl:variable name="spanned-vertical-position" select="count(../preceding-sibling::h:tr) + 1"/>
|
328
|
+
<xsl:if test="$spanned-vertical-position + @rowspan - 1 >= $vertical-position">
|
329
|
+
<table:covered-table-cell/>
|
330
|
+
</xsl:if>
|
331
|
+
</xsl:template>
|
332
|
+
|
333
|
+
|
334
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!--
|
3
|
+
|
4
|
+
xhtml2odt - XHTML to ODT XML transformation.
|
5
|
+
Copyright (C) 2009 Aurelien Bompard
|
6
|
+
Inspired by the work on docbook2odt, by Roman Fordinal
|
7
|
+
http://open.comsultia.com/docbook2odf/
|
8
|
+
|
9
|
+
License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html>
|
10
|
+
|
11
|
+
This library is free software; you can redistribute it and/or
|
12
|
+
modify it under the terms of the GNU Lesser General Public
|
13
|
+
License as published by the Free Software Foundation; either
|
14
|
+
version 2.1 of the License, or (at your option) any later version.
|
15
|
+
|
16
|
+
This library is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19
|
+
Lesser General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU Lesser General Public
|
22
|
+
License along with this library; if not, write to the Free Software
|
23
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
24
|
+
MA 02110-1301 USA
|
25
|
+
|
26
|
+
-->
|
27
|
+
<xsl:stylesheet
|
28
|
+
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
29
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
30
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
31
|
+
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
32
|
+
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
33
|
+
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table: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:xlink="http://www.w3.org/1999/xlink"
|
37
|
+
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
38
|
+
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
39
|
+
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
40
|
+
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
41
|
+
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
42
|
+
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
43
|
+
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
44
|
+
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
45
|
+
xmlns:dom="http://www.w3.org/2001/xml-events"
|
46
|
+
xmlns:xforms="http://www.w3.org/2002/xforms"
|
47
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
48
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
49
|
+
xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
|
50
|
+
version="1.0">
|
51
|
+
|
52
|
+
<xsl:include href="document-content/paragraph.xsl"/>
|
53
|
+
<xsl:include href="document-content/block.xsl"/>
|
54
|
+
<xsl:include href="document-content/inline.xsl"/>
|
55
|
+
<xsl:include href="document-content/link.xsl"/>
|
56
|
+
<xsl:include href="document-content/lists.xsl"/>
|
57
|
+
<xsl:include href="document-content/section.xsl"/>
|
58
|
+
<xsl:include href="document-content/media.xsl"/>
|
59
|
+
<xsl:include href="document-content/tables.xsl"/>
|
60
|
+
<xsl:include href="document-content/ignore.xsl"/>
|
61
|
+
<xsl:include href="document-content/html5.xsl"/>
|
62
|
+
|
63
|
+
</xsl:stylesheet>
|