htmltoooxml 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 +9 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +4 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/htmltoooxml.gemspec +34 -0
- data/lib/htmltoooxml/configuration.rb +10 -0
- data/lib/htmltoooxml/document.rb +28 -0
- data/lib/htmltoooxml/helpers/xslt_helper.rb +17 -0
- data/lib/htmltoooxml/version.rb +3 -0
- data/lib/htmltoooxml/xslt/base.xslt +345 -0
- data/lib/htmltoooxml/xslt/cleanup.xslt +71 -0
- data/lib/htmltoooxml/xslt/extras.xslt +26 -0
- data/lib/htmltoooxml/xslt/functions.xslt +34 -0
- data/lib/htmltoooxml/xslt/html_to_ooxml.xslt +307 -0
- data/lib/htmltoooxml/xslt/htmltoooxml.xslt +7 -0
- data/lib/htmltoooxml/xslt/inline_elements.xslt +40 -0
- data/lib/htmltoooxml/xslt/links.xslt +35 -0
- data/lib/htmltoooxml/xslt/tables.xslt +187 -0
- data/lib/htmltoooxml.rb +21 -0
- metadata +109 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
2
|
+
xmlns:a="http://schemas.openxmlformats.org/presentationml/2006/main"
|
3
|
+
xmlns:o="urn:schemas-microsoft-com:office:office"
|
4
|
+
xmlns:v="urn:schemas-microsoft-com:vml"
|
5
|
+
xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
|
6
|
+
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
|
7
|
+
xmlns:w10="urn:schemas-microsoft-com:office:word"
|
8
|
+
xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"
|
9
|
+
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
|
10
|
+
xmlns:ext="http://www.xmllab.net/wordml2html/ext"
|
11
|
+
xmlns:java="http://xml.apache.org/xalan/java"
|
12
|
+
xmlns:str="http://exslt.org/strings"
|
13
|
+
xmlns:func="http://exslt.org/functions"
|
14
|
+
xmlns:fn="http://www.w3.org/2005/xpath-functions"
|
15
|
+
version="1.0"
|
16
|
+
exclude-result-prefixes="java msxsl ext a o v WX aml w10"
|
17
|
+
extension-element-prefixes="func">
|
18
|
+
|
19
|
+
<!-- use block quotes for spacing (can be nested) -->
|
20
|
+
<xsl:template match="blockquote">
|
21
|
+
<a:p>
|
22
|
+
<a:r></a:r>
|
23
|
+
</a:p>
|
24
|
+
<xsl:apply-templates/>
|
25
|
+
</xsl:template>
|
26
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
2
|
+
xmlns:a="http://schemas.openxmlformats.org/presentationml/2006/main"
|
3
|
+
xmlns:o="urn:schemas-microsoft-com:office:office"
|
4
|
+
xmlns:v="urn:schemas-microsoft-com:vml"
|
5
|
+
xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
|
6
|
+
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
|
7
|
+
xmlns:w10="urn:schemas-microsoft-com:office:word"
|
8
|
+
xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"
|
9
|
+
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
|
10
|
+
xmlns:ext="http://www.xmllab.net/wordml2html/ext"
|
11
|
+
xmlns:java="http://xml.apache.org/xalan/java"
|
12
|
+
xmlns:str="http://exslt.org/strings"
|
13
|
+
xmlns:func="http://exslt.org/functions"
|
14
|
+
xmlns:fn="http://www.w3.org/2005/xpath-functions"
|
15
|
+
version="1.0"
|
16
|
+
exclude-result-prefixes="java msxsl ext a o v WX aml w10"
|
17
|
+
extension-element-prefixes="func">
|
18
|
+
|
19
|
+
<!-- support function to return substring-before or everything -->
|
20
|
+
<func:function name="func:substring-before-if-contains">
|
21
|
+
<xsl:param name="arg"/>
|
22
|
+
<xsl:param name="delim"/>
|
23
|
+
<func:result>
|
24
|
+
<xsl:choose>
|
25
|
+
<xsl:when test="contains($arg, $delim)">
|
26
|
+
<xsl:value-of select="substring-before($arg, $delim)"/>
|
27
|
+
</xsl:when>
|
28
|
+
<xsl:otherwise>
|
29
|
+
<xsl:value-of select="$arg"/>
|
30
|
+
</xsl:otherwise>
|
31
|
+
</xsl:choose>
|
32
|
+
</func:result>
|
33
|
+
</func:function>
|
34
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,307 @@
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
2
|
+
version="1.0"
|
3
|
+
exclude-result-prefixes="java msxsl ext w o v WX aml w10">
|
4
|
+
|
5
|
+
|
6
|
+
<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes" indent="yes" />
|
7
|
+
|
8
|
+
<xsl:template match="div[not(ancestor::td) and not(ancestor::th) and not(ancestor::p) and not(descendant::div) and not(descendant::p) and not(descendant::h1) and not(descendant::h2) and not(descendant::h3) and not(descendant::h4) and not(descendant::h5) and not(descendant::h6) and not(descendant::table) and not(descendant::li)]">
|
9
|
+
<xsl:comment>Divs should create a p if nothing above them has and nothing below them will</xsl:comment>
|
10
|
+
<a:p>
|
11
|
+
<xsl:call-template name="text-alignment" />
|
12
|
+
<xsl:apply-templates />
|
13
|
+
</a:p>
|
14
|
+
</xsl:template>
|
15
|
+
|
16
|
+
<xsl:template match="div">
|
17
|
+
<xsl:apply-templates />
|
18
|
+
</xsl:template>
|
19
|
+
|
20
|
+
<!-- TODO: make this prettier. Headings shouldn't enter in template from L51 -->
|
21
|
+
<xsl:template match="body/h1|body/h2|body/h3|body/h4|body/h5|body/h6|h1|h2|h3|h4|h5|h6">
|
22
|
+
<xsl:variable name="length" select="string-length(name(.))"/>
|
23
|
+
<a:p>
|
24
|
+
<a:r>
|
25
|
+
<a:t xml:space="preserve"><xsl:value-of select="."/></a:t>
|
26
|
+
</a:r>
|
27
|
+
</a:p>
|
28
|
+
</xsl:template>
|
29
|
+
|
30
|
+
<xsl:template match="p">
|
31
|
+
<a:p>
|
32
|
+
<a:pPr marL="0" indent="0">
|
33
|
+
<a:spcAft>
|
34
|
+
<a:spcPts val="600"/>
|
35
|
+
</a:spcAft>
|
36
|
+
<a:buNone/>
|
37
|
+
</a:pPr>
|
38
|
+
<xsl:call-template name="text-alignment" />
|
39
|
+
<xsl:apply-templates />
|
40
|
+
</a:p>
|
41
|
+
</xsl:template>
|
42
|
+
|
43
|
+
<xsl:template match="li">
|
44
|
+
<a:p>
|
45
|
+
<a:r>
|
46
|
+
<a:t xml:space="preserve"><xsl:value-of select="."/></a:t>
|
47
|
+
</a:r>
|
48
|
+
</a:p>
|
49
|
+
</xsl:template>
|
50
|
+
|
51
|
+
<xsl:template match="span[not(ancestor::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
|
52
|
+
|a[not(ancestor::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
|
53
|
+
|small[not(ancestor::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
|
54
|
+
|strong[not(ancestor::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
|
55
|
+
|em[not(ancestor::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
|
56
|
+
|i[not(ancestor::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
|
57
|
+
|b[not(ancestor::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
|
58
|
+
|u[not(ancestor::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]">
|
59
|
+
<xsl:comment>
|
60
|
+
In the following situation:
|
61
|
+
|
62
|
+
div
|
63
|
+
h2
|
64
|
+
span
|
65
|
+
textnode
|
66
|
+
span
|
67
|
+
textnode
|
68
|
+
p
|
69
|
+
|
70
|
+
The div template will not create a a:p because the div contains a h2. Therefore we need to wrap the inline elements span|a|small in a p here.
|
71
|
+
</xsl:comment>
|
72
|
+
<a:p>
|
73
|
+
<xsl:apply-templates />
|
74
|
+
</a:p>
|
75
|
+
</xsl:template>
|
76
|
+
|
77
|
+
<xsl:template match="text()[not(parent::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]">
|
78
|
+
<xsl:comment>
|
79
|
+
In the following situation:
|
80
|
+
|
81
|
+
div
|
82
|
+
h2
|
83
|
+
textnode
|
84
|
+
p
|
85
|
+
|
86
|
+
The div template will not create a a:p because the div contains a h2. Therefore we need to wrap the textnode in a p here.
|
87
|
+
</xsl:comment>
|
88
|
+
<a:p>
|
89
|
+
<a:r>
|
90
|
+
<a:rPr lang="en-GB" sz="1800" dirty="0" smtClean="0"/>
|
91
|
+
<a:t xml:space="preserve"><xsl:value-of select="."/></a:t>
|
92
|
+
</a:r>
|
93
|
+
</a:p>
|
94
|
+
</xsl:template>
|
95
|
+
|
96
|
+
<xsl:template match="span[contains(concat(' ', @class, ' '), ' h ')]">
|
97
|
+
<xsl:comment>
|
98
|
+
This template adds MS Word highlighting ability.
|
99
|
+
</xsl:comment>
|
100
|
+
<xsl:variable name="color">
|
101
|
+
<xsl:choose>
|
102
|
+
<xsl:when test="./@data-style='pink'">magenta</xsl:when>
|
103
|
+
<xsl:when test="./@data-style='blue'">cyan</xsl:when>
|
104
|
+
<xsl:when test="./@data-style='orange'">darkYellow</xsl:when>
|
105
|
+
<xsl:otherwise><xsl:value-of select="./@data-style"/></xsl:otherwise>
|
106
|
+
</xsl:choose>
|
107
|
+
</xsl:variable>
|
108
|
+
<xsl:choose>
|
109
|
+
<xsl:when test="preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div">
|
110
|
+
<a:p>
|
111
|
+
<a:r>
|
112
|
+
<a:rPr>
|
113
|
+
<a:highlight a:val="{$color}"/>
|
114
|
+
</a:rPr>
|
115
|
+
<a:t xml:space="preserve"><xsl:value-of select="."/></a:t>
|
116
|
+
</a:r>
|
117
|
+
</a:p>
|
118
|
+
</xsl:when>
|
119
|
+
<xsl:otherwise>
|
120
|
+
<a:r>
|
121
|
+
<a:rPr>
|
122
|
+
<a:highlight a:val="{$color}"/>
|
123
|
+
</a:rPr>
|
124
|
+
<a:t xml:space="preserve"><xsl:value-of select="."/></a:t>
|
125
|
+
</a:r>
|
126
|
+
</xsl:otherwise>
|
127
|
+
</xsl:choose>
|
128
|
+
</xsl:template>
|
129
|
+
|
130
|
+
<xsl:template match="div[contains(concat(' ', @class, ' '), ' -page-break ')]">
|
131
|
+
<a:p>
|
132
|
+
<a:r>
|
133
|
+
<a:br a:type="page" />
|
134
|
+
</a:r>
|
135
|
+
</a:p>
|
136
|
+
<xsl:apply-templates />
|
137
|
+
</xsl:template>
|
138
|
+
|
139
|
+
<xsl:template match="details" />
|
140
|
+
|
141
|
+
<xsl:template name="tableborders">
|
142
|
+
<xsl:variable name="border">
|
143
|
+
<xsl:choose>
|
144
|
+
<xsl:when test="contains(concat(' ', @class, ' '), ' table-bordered ')">6</xsl:when>
|
145
|
+
<xsl:when test="not(@border)">0</xsl:when>
|
146
|
+
<xsl:otherwise><xsl:value-of select="./@border * 6"/></xsl:otherwise>
|
147
|
+
</xsl:choose>
|
148
|
+
</xsl:variable>
|
149
|
+
<xsl:variable name="bordertype">
|
150
|
+
<xsl:choose>
|
151
|
+
<xsl:when test="$border=0">none</xsl:when>
|
152
|
+
<xsl:otherwise>single</xsl:otherwise>
|
153
|
+
</xsl:choose>
|
154
|
+
</xsl:variable>
|
155
|
+
<a:tblBorders>
|
156
|
+
<a:top a:val="{$bordertype}" a:sz="{$border}" a:space="0" a:color="auto"/>
|
157
|
+
<a:left a:val="{$bordertype}" a:sz="{$border}" a:space="0" a:color="auto"/>
|
158
|
+
<a:bottom a:val="{$bordertype}" a:sz="{$border}" a:space="0" a:color="auto"/>
|
159
|
+
<a:right a:val="{$bordertype}" a:sz="{$border}" a:space="0" a:color="auto"/>
|
160
|
+
<a:insideH a:val="{$bordertype}" a:sz="{$border}" a:space="0" a:color="auto"/>
|
161
|
+
<a:insideV a:val="{$bordertype}" a:sz="{$border}" a:space="0" a:color="auto"/>
|
162
|
+
</a:tblBorders>
|
163
|
+
</xsl:template>
|
164
|
+
|
165
|
+
<xsl:template match="table">
|
166
|
+
<a:tbl>
|
167
|
+
<a:tblPr>
|
168
|
+
<a:tblStyle a:val="TableGrid"/>
|
169
|
+
<a:tblW a:w="0" a:type="auto"/>
|
170
|
+
<xsl:call-template name="tableborders"/>
|
171
|
+
<a:tblLook a:val="0600" a:firstRow="0" a:lastRow="0" a:firstColumn="0" a:lastColumn="0" a:noHBand="1" a:noVBand="1"/>
|
172
|
+
</a:tblPr>
|
173
|
+
<a:tblGrid>
|
174
|
+
<a:gridCol a:w="2310"/>
|
175
|
+
<a:gridCol a:w="2310"/>
|
176
|
+
</a:tblGrid>
|
177
|
+
<xsl:apply-templates />
|
178
|
+
</a:tbl>
|
179
|
+
</xsl:template>
|
180
|
+
|
181
|
+
<xsl:template match="tbody">
|
182
|
+
<xsl:apply-templates />
|
183
|
+
</xsl:template>
|
184
|
+
|
185
|
+
<xsl:template match="thead">
|
186
|
+
<xsl:choose>
|
187
|
+
<xsl:when test="count(./tr) = 0">
|
188
|
+
<a:tr><xsl:apply-templates /></a:tr>
|
189
|
+
</xsl:when>
|
190
|
+
<xsl:otherwise>
|
191
|
+
<xsl:apply-templates />
|
192
|
+
</xsl:otherwise>
|
193
|
+
</xsl:choose>
|
194
|
+
</xsl:template>
|
195
|
+
|
196
|
+
<xsl:template match="tr">
|
197
|
+
<xsl:if test="string-length(.) > 0">
|
198
|
+
<a:tr>
|
199
|
+
<xsl:apply-templates />
|
200
|
+
</a:tr>
|
201
|
+
</xsl:if>
|
202
|
+
</xsl:template>
|
203
|
+
|
204
|
+
<xsl:template match="th">
|
205
|
+
<a:tc>
|
206
|
+
<a:p>
|
207
|
+
<a:r>
|
208
|
+
<a:rPr>
|
209
|
+
<a:b />
|
210
|
+
</a:rPr>
|
211
|
+
<a:t xml:space="preserve"><xsl:value-of select="."/></a:t>
|
212
|
+
</a:r>
|
213
|
+
</a:p>
|
214
|
+
</a:tc>
|
215
|
+
</xsl:template>
|
216
|
+
|
217
|
+
<xsl:template match="td">
|
218
|
+
<a:tc>
|
219
|
+
<xsl:call-template name="block">
|
220
|
+
<xsl:with-param name="current" select="." />
|
221
|
+
<xsl:with-param name="class" select="@class" />
|
222
|
+
<xsl:with-param name="style" select="@style" />
|
223
|
+
</xsl:call-template>
|
224
|
+
</a:tc>
|
225
|
+
</xsl:template>
|
226
|
+
|
227
|
+
<xsl:template name="block">
|
228
|
+
<xsl:param name="current" />
|
229
|
+
<xsl:param name="class" />
|
230
|
+
<xsl:param name="style" />
|
231
|
+
<xsl:if test="count($current/*|$current/text()) = 0">
|
232
|
+
<a:p/>
|
233
|
+
</xsl:if>
|
234
|
+
<xsl:for-each select="$current/*|$current/text()">
|
235
|
+
<xsl:choose>
|
236
|
+
<xsl:when test="name(.) = 'table'">
|
237
|
+
<xsl:apply-templates select="." />
|
238
|
+
<a:p/>
|
239
|
+
</xsl:when>
|
240
|
+
<xsl:when test="contains('|p|h1|h2|h3|h4|h5|h6|ul|ol|', concat('|', name(.), '|'))">
|
241
|
+
<xsl:apply-templates select="." />
|
242
|
+
</xsl:when>
|
243
|
+
<xsl:when test="descendant::table|descendant::p|descendant::h1|descendant::h2|descendant::h3|descendant::h4|descendant::h5|descendant::h6|descendant::li">
|
244
|
+
<xsl:call-template name="block">
|
245
|
+
<xsl:with-param name="current" select="."/>
|
246
|
+
</xsl:call-template>
|
247
|
+
</xsl:when>
|
248
|
+
<xsl:otherwise>
|
249
|
+
<a:p>
|
250
|
+
<xsl:call-template name="text-alignment">
|
251
|
+
<xsl:with-param name="class" select="$class" />
|
252
|
+
<xsl:with-param name="style" select="$style" />
|
253
|
+
</xsl:call-template>
|
254
|
+
<xsl:apply-templates select="." />
|
255
|
+
</a:p>
|
256
|
+
</xsl:otherwise>
|
257
|
+
</xsl:choose>
|
258
|
+
</xsl:for-each>
|
259
|
+
</xsl:template>
|
260
|
+
|
261
|
+
<xsl:template match="text()">
|
262
|
+
<xsl:if test="string-length(.) > 0">
|
263
|
+
<a:r>
|
264
|
+
<xsl:if test="ancestor::i or ancestor::em">
|
265
|
+
<a:rPr>
|
266
|
+
<a:i />
|
267
|
+
</a:rPr>
|
268
|
+
</xsl:if>
|
269
|
+
<xsl:if test="ancestor::b or ancestor::strong">
|
270
|
+
<a:rPr>
|
271
|
+
<a:b />
|
272
|
+
</a:rPr>
|
273
|
+
</xsl:if>
|
274
|
+
<xsl:if test="ancestor::u">
|
275
|
+
<a:rPr>
|
276
|
+
<a:u a:val="single"/>
|
277
|
+
</a:rPr>
|
278
|
+
</xsl:if>
|
279
|
+
<a:rPr lang="en-GB" sz="1800" dirty="0" smtClean="0"/>
|
280
|
+
<a:t xml:space="preserve"><xsl:value-of select="."/></a:t>
|
281
|
+
</a:r>
|
282
|
+
</xsl:if>
|
283
|
+
</xsl:template>
|
284
|
+
|
285
|
+
<xsl:template match="*">
|
286
|
+
<xsl:apply-templates/>
|
287
|
+
</xsl:template>
|
288
|
+
|
289
|
+
<xsl:template name="text-alignment">
|
290
|
+
<xsl:param name="class" select="@class" />
|
291
|
+
<xsl:param name="style" select="@style" />
|
292
|
+
<xsl:variable name="alignment">
|
293
|
+
<xsl:choose>
|
294
|
+
<xsl:when test="contains(concat(' ', $class, ' '), ' center ') or contains(translate(normalize-space($style),' ',''), 'text-align:center')">center</xsl:when>
|
295
|
+
<xsl:when test="contains(concat(' ', $class, ' '), ' right ') or contains(translate(normalize-space($style),' ',''), 'text-align:right')">right</xsl:when>
|
296
|
+
<xsl:when test="contains(concat(' ', $class, ' '), ' left ') or contains(translate(normalize-space($style),' ',''), 'text-align:left')">left</xsl:when>
|
297
|
+
<xsl:when test="contains(concat(' ', $class, ' '), ' justify ') or contains(translate(normalize-space($style),' ',''), 'text-align:justify')">both</xsl:when>
|
298
|
+
<xsl:otherwise></xsl:otherwise>
|
299
|
+
</xsl:choose>
|
300
|
+
</xsl:variable>
|
301
|
+
<xsl:if test="string-length(normalize-space($alignment)) > 0">
|
302
|
+
<a:pPr>
|
303
|
+
<a:jc a:val="{$alignment}"/>
|
304
|
+
</a:pPr>
|
305
|
+
</xsl:if>
|
306
|
+
</xsl:template>
|
307
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
2
|
+
version="1.0"
|
3
|
+
exclude-result-prefixes="java msxsl ext w o v WX aml w10">
|
4
|
+
<xsl:import href="./base.xslt"/>
|
5
|
+
<!--Extra templates and customizations-->
|
6
|
+
<xsl:include href="./extras.xslt"/>
|
7
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
2
|
+
<xsl:output encoding="utf-8" omit-xml-declaration="yes" indent="yes" />
|
3
|
+
|
4
|
+
<xsl:strip-space elements="*"/>
|
5
|
+
|
6
|
+
<xsl:template match="node()|@*">
|
7
|
+
<xsl:copy>
|
8
|
+
<xsl:apply-templates select="@*|node()[1]"/>
|
9
|
+
</xsl:copy>
|
10
|
+
<xsl:apply-templates select="following-sibling::node()[1]"/>
|
11
|
+
</xsl:template>
|
12
|
+
|
13
|
+
<!-- get first inline element of a sequence or text having block element siblings... -->
|
14
|
+
<xsl:template match="node()[self::a|self::b|self::i|self::s|self::span|self::sub|self::sup|self::u|self::text()][parent::div|parent::li|parent::td]">
|
15
|
+
<div>
|
16
|
+
<xsl:attribute name="class"><xsl:value-of select="../@class"/></xsl:attribute>
|
17
|
+
<xsl:attribute name="style"><xsl:value-of select="../@style"/></xsl:attribute>
|
18
|
+
<xsl:call-template name="inlineElement"/>
|
19
|
+
</div>
|
20
|
+
<xsl:apply-templates select="following-sibling::node()[not((self::a|self::b|self::i|self::s|self::span|self::sub|self::sup|self::u|self::text())[parent::div|parent::li|parent::td])][1]"/>
|
21
|
+
</xsl:template>
|
22
|
+
|
23
|
+
<!-- get following inline elements... -->
|
24
|
+
<xsl:template match="
|
25
|
+
a[preceding-sibling::node()[1][self::a|self::b|self::i|self::s|self::span|self::sub|self::sup|self::u|self::text()]]
|
26
|
+
|b[preceding-sibling::node()[1][self::a|self::b|self::i|self::s|self::span|self::sub|self::sup|self::u|self::text()]]
|
27
|
+
|i[preceding-sibling::node()[1][self::a|self::b|self::i|self::s|self::span|self::sub|self::sup|self::u|self::text()]]
|
28
|
+
|s[preceding-sibling::node()[1][self::a|self::b|self::i|self::s|self::span|self::sub|self::sup|self::u|self::text()]]
|
29
|
+
|span[preceding-sibling::node()[1][self::a|self::b|self::i|self::s|self::span|self::sub|self::sup|self::u|self::text()]]
|
30
|
+
|sub[preceding-sibling::node()[1][self::a|self::b|self::i|self::s|self::span|self::sub|self::sup|self::u|self::text()]]
|
31
|
+
|sup[preceding-sibling::node()[1][self::a|self::b|self::i|self::s|self::span|self::sub|self::sup|self::u|self::text()]]
|
32
|
+
|u[preceding-sibling::node()[1][self::a|self::b|self::i|self::s|self::span|self::sub|self::sup|self::u|self::text()]]
|
33
|
+
|text()[preceding-sibling::node()[1][self::a|self::b|self::i|self::s|self::span|self::sub|self::sup|self::u|self::text()]]"
|
34
|
+
name="inlineElement">
|
35
|
+
<xsl:copy>
|
36
|
+
<xsl:apply-templates select="@*|node()[1]"/>
|
37
|
+
</xsl:copy>
|
38
|
+
<xsl:apply-templates select="following-sibling::node()[1][self::a|self::b|self::i|self::s|self::span|self::sub|self::sup|self::u|self::text()]"/>
|
39
|
+
</xsl:template>
|
40
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
2
|
+
xmlns:a="http://schemas.openxmlformats.org/presentationml/2006/main"
|
3
|
+
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
4
|
+
xmlns:o="urn:schemas-microsoft-com:office:office"
|
5
|
+
xmlns:v="urn:schemas-microsoft-com:vml"
|
6
|
+
xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
|
7
|
+
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
|
8
|
+
xmlns:w10="urn:schemas-microsoft-com:office:word"
|
9
|
+
xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"
|
10
|
+
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
|
11
|
+
xmlns:ext="http://www.xmllab.net/wordml2html/ext"
|
12
|
+
xmlns:java="http://xml.apache.org/xalan/java"
|
13
|
+
xmlns:str="http://exslt.org/strings"
|
14
|
+
xmlns:func="http://exslt.org/functions"
|
15
|
+
xmlns:fn="http://www.w3.org/2005/xpath-functions"
|
16
|
+
version="1.0"
|
17
|
+
exclude-result-prefixes="java msxsl ext a o v WX aml w10"
|
18
|
+
extension-element-prefixes="func">
|
19
|
+
|
20
|
+
<xsl:template match="a[starts-with(@href, 'http://') or starts-with(@href, 'https://')]" name="link">
|
21
|
+
<a:hyperlink>
|
22
|
+
<xsl:attribute name="r:id">rId<xsl:value-of select="count(preceding::a[starts-with(@href, 'http://') or starts-with(@href, 'https://')]) + 8" /></xsl:attribute>
|
23
|
+
<a:r>
|
24
|
+
<a:rPr>
|
25
|
+
<a:rStyle a:val="Hyperlink"/>
|
26
|
+
<a:color a:val="000080"/>
|
27
|
+
<a:u a:val="single"/>
|
28
|
+
</a:rPr>
|
29
|
+
<a:t xml:space="preserve">
|
30
|
+
<xsl:value-of select="."/>
|
31
|
+
</a:t>
|
32
|
+
</a:r>
|
33
|
+
</a:hyperlink>
|
34
|
+
</xsl:template>
|
35
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,187 @@
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
2
|
+
xmlns:a="http://schemas.openxmlformats.org/presentationml/2006/main"
|
3
|
+
xmlns:o="urn:schemas-microsoft-com:office:office"
|
4
|
+
xmlns:v="urn:schemas-microsoft-com:vml"
|
5
|
+
xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
|
6
|
+
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
|
7
|
+
xmlns:w10="urn:schemas-microsoft-com:office:word"
|
8
|
+
xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"
|
9
|
+
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
|
10
|
+
xmlns:ext="http://www.xmllab.net/wordml2html/ext"
|
11
|
+
xmlns:java="http://xml.apache.org/xalan/java"
|
12
|
+
xmlns:str="http://exslt.org/strings"
|
13
|
+
xmlns:func="http://exslt.org/functions"
|
14
|
+
xmlns:fn="http://www.w3.org/2005/xpath-functions"
|
15
|
+
version="1.0"
|
16
|
+
exclude-result-prefixes="java msxsl ext a o v WX aml w10"
|
17
|
+
extension-element-prefixes="func">
|
18
|
+
|
19
|
+
<!--XSLT support for tables -->
|
20
|
+
|
21
|
+
<!-- Full width tables per default -->
|
22
|
+
<xsl:template match="table">
|
23
|
+
<a:tbl>
|
24
|
+
<a:tblPr>
|
25
|
+
<a:tblStyle a:val="TableGrid"/>
|
26
|
+
<a:tblW a:w="5000" a:type="pct"/>
|
27
|
+
<xsl:call-template name="tableborders"/>
|
28
|
+
<a:tblLook a:val="0600" a:firstRow="0" a:lastRow="0" a:firstColumn="0" a:lastColumn="0" a:noHBand="1" a:noVBand="1"/>
|
29
|
+
</a:tblPr>
|
30
|
+
<xsl:apply-templates />
|
31
|
+
</a:tbl>
|
32
|
+
</xsl:template>
|
33
|
+
|
34
|
+
<xsl:template match="tbody">
|
35
|
+
<xsl:apply-templates />
|
36
|
+
</xsl:template>
|
37
|
+
|
38
|
+
<xsl:template match="thead">
|
39
|
+
<xsl:choose>
|
40
|
+
<xsl:when test="count(./tr) = 0">
|
41
|
+
<a:tr><xsl:apply-templates /></a:tr>
|
42
|
+
</xsl:when>
|
43
|
+
<xsl:otherwise>
|
44
|
+
<xsl:apply-templates />
|
45
|
+
</xsl:otherwise>
|
46
|
+
</xsl:choose>
|
47
|
+
</xsl:template>
|
48
|
+
|
49
|
+
<xsl:template match="tr">
|
50
|
+
<xsl:if test="string-length(.) > 0">
|
51
|
+
<a:tr>
|
52
|
+
<xsl:apply-templates />
|
53
|
+
</a:tr>
|
54
|
+
</xsl:if>
|
55
|
+
</xsl:template>
|
56
|
+
|
57
|
+
<xsl:template match="th">
|
58
|
+
<a:tc>
|
59
|
+
<xsl:call-template name="table-cell-properties"/>
|
60
|
+
<a:p>
|
61
|
+
<a:r>
|
62
|
+
<a:rPr>
|
63
|
+
<a:b />
|
64
|
+
</a:rPr>
|
65
|
+
<a:t xml:space="preserve"><xsl:value-of select="."/></a:t>
|
66
|
+
</a:r>
|
67
|
+
</a:p>
|
68
|
+
</a:tc>
|
69
|
+
</xsl:template>
|
70
|
+
|
71
|
+
<xsl:template match="td">
|
72
|
+
<a:tc>
|
73
|
+
<xsl:call-template name="table-cell-properties"/>
|
74
|
+
<xsl:call-template name="block">
|
75
|
+
<xsl:with-param name="current" select="." />
|
76
|
+
<xsl:with-param name="class" select="@class" />
|
77
|
+
<xsl:with-param name="style" select="@style" />
|
78
|
+
</xsl:call-template>
|
79
|
+
</a:tc>
|
80
|
+
</xsl:template>
|
81
|
+
|
82
|
+
<xsl:template name="block">
|
83
|
+
<xsl:param name="current" />
|
84
|
+
<xsl:param name="class" />
|
85
|
+
<xsl:param name="style" />
|
86
|
+
<xsl:if test="count($current/*|$current/text()) = 0">
|
87
|
+
<a:p/>
|
88
|
+
</xsl:if>
|
89
|
+
<xsl:for-each select="$current/*|$current/text()">
|
90
|
+
<xsl:choose>
|
91
|
+
<xsl:when test="name(.) = 'table'">
|
92
|
+
<xsl:apply-templates select="." />
|
93
|
+
<a:p/>
|
94
|
+
</xsl:when>
|
95
|
+
<xsl:when test="contains('|p|h1|h2|h3|h4|h5|h6|ul|ol|', concat('|', name(.), '|'))">
|
96
|
+
<xsl:apply-templates select="." />
|
97
|
+
</xsl:when>
|
98
|
+
<xsl:when test="descendant::table|descendant::p|descendant::h1|descendant::h2|descendant::h3|descendant::h4|descendant::h5|descendant::h6|descendant::li">
|
99
|
+
<xsl:call-template name="block">
|
100
|
+
<xsl:with-param name="current" select="."/>
|
101
|
+
</xsl:call-template>
|
102
|
+
</xsl:when>
|
103
|
+
<xsl:otherwise>
|
104
|
+
<a:p>
|
105
|
+
<xsl:call-template name="text-alignment">
|
106
|
+
<xsl:with-param name="class" select="$class" />
|
107
|
+
<xsl:with-param name="style" select="$style" />
|
108
|
+
</xsl:call-template>
|
109
|
+
<xsl:apply-templates select="." />
|
110
|
+
</a:p>
|
111
|
+
</xsl:otherwise>
|
112
|
+
</xsl:choose>
|
113
|
+
</xsl:for-each>
|
114
|
+
</xsl:template>
|
115
|
+
|
116
|
+
<xsl:template name="tableborders">
|
117
|
+
<xsl:variable name="border">
|
118
|
+
<xsl:choose>
|
119
|
+
<xsl:when test="contains(concat(' ', @class, ' '), ' table-bordered ')">6</xsl:when>
|
120
|
+
<xsl:when test="not(@border)">0</xsl:when>
|
121
|
+
<xsl:otherwise><xsl:value-of select="./@border * 6"/></xsl:otherwise>
|
122
|
+
</xsl:choose>
|
123
|
+
</xsl:variable>
|
124
|
+
<xsl:variable name="bordertype">
|
125
|
+
<xsl:choose>
|
126
|
+
<xsl:when test="$border=0">none</xsl:when>
|
127
|
+
<xsl:otherwise>single</xsl:otherwise>
|
128
|
+
</xsl:choose>
|
129
|
+
</xsl:variable>
|
130
|
+
<a:tblBorders>
|
131
|
+
<a:top a:val="{$bordertype}" a:sz="{$border}" a:space="0" a:color="auto"/>
|
132
|
+
<a:left a:val="{$bordertype}" a:sz="{$border}" a:space="0" a:color="auto"/>
|
133
|
+
<a:bottom a:val="{$bordertype}" a:sz="{$border}" a:space="0" a:color="auto"/>
|
134
|
+
<a:right a:val="{$bordertype}" a:sz="{$border}" a:space="0" a:color="auto"/>
|
135
|
+
<a:insideH a:val="{$bordertype}" a:sz="{$border}" a:space="0" a:color="auto"/>
|
136
|
+
<a:insideV a:val="{$bordertype}" a:sz="{$border}" a:space="0" a:color="auto"/>
|
137
|
+
</a:tblBorders>
|
138
|
+
</xsl:template>
|
139
|
+
|
140
|
+
<xsl:template name="table-cell-properties">
|
141
|
+
<a:tcPr>
|
142
|
+
<xsl:if test="contains(@class, 'ms-border-')">
|
143
|
+
<a:tcBorders>
|
144
|
+
<xsl:for-each select="str:tokenize(@class, ' ')">
|
145
|
+
<xsl:call-template name="define-border">
|
146
|
+
<xsl:with-param name="class" select="." />
|
147
|
+
</xsl:call-template>
|
148
|
+
</xsl:for-each>
|
149
|
+
</a:tcBorders>
|
150
|
+
</xsl:if>
|
151
|
+
<xsl:if test="contains(@class, 'ms-fill-')">
|
152
|
+
<xsl:variable name="cell-bg" select="str:tokenize(substring-after(@class, 'ms-fill-'), ' ')[1]"/>
|
153
|
+
<a:shd a:val="clear" a:color="auto" a:fill="{$cell-bg}" />
|
154
|
+
</xsl:if>
|
155
|
+
</a:tcPr>
|
156
|
+
</xsl:template>
|
157
|
+
|
158
|
+
<xsl:template name="define-border">
|
159
|
+
<xsl:param name="class" />
|
160
|
+
<xsl:if test="contains($class, 'ms-border-')">
|
161
|
+
<xsl:variable name="border" select="substring-after($class, 'ms-border-')"/>
|
162
|
+
<xsl:variable name="border-properties" select="str:tokenize($border, '-')"/>
|
163
|
+
<xsl:variable name="border-location" select="$border-properties[1]" />
|
164
|
+
<xsl:variable name="border-value" select="$border-properties[2]" />
|
165
|
+
<xsl:variable name="border-color">
|
166
|
+
<xsl:choose>
|
167
|
+
<xsl:when test="string-length($border-properties[3]) > 0"><xsl:value-of select="$border-properties[3]"/></xsl:when>
|
168
|
+
<xsl:otherwise>000000</xsl:otherwise>
|
169
|
+
</xsl:choose>
|
170
|
+
</xsl:variable>
|
171
|
+
<xsl:variable name="border-size">
|
172
|
+
<xsl:choose>
|
173
|
+
<xsl:when test="string-length($border-properties[4]) > 0"><xsl:value-of select="$border-properties[4] * 6"/></xsl:when>
|
174
|
+
<xsl:otherwise>6</xsl:otherwise>
|
175
|
+
</xsl:choose>
|
176
|
+
</xsl:variable>
|
177
|
+
<xsl:element name="a:{$border-location}">
|
178
|
+
<xsl:attribute name="a:val"><xsl:value-of select="$border-value" /></xsl:attribute>
|
179
|
+
<xsl:attribute name="a:sz"><xsl:value-of select="$border-size" /></xsl:attribute>
|
180
|
+
<xsl:attribute name="a:space">0</xsl:attribute>
|
181
|
+
<xsl:attribute name="a:color"><xsl:value-of select="$border-color" /></xsl:attribute>
|
182
|
+
</xsl:element>
|
183
|
+
</xsl:if>
|
184
|
+
</xsl:template>
|
185
|
+
|
186
|
+
|
187
|
+
</xsl:stylesheet>
|