avv2word 1.0.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.
@@ -0,0 +1,495 @@
1
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2
+ xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/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 w o v WX aml w10"
17
+ extension-element-prefixes="func">
18
+ <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes" indent="yes" />
19
+ <xsl:include href="./functions.xslt"/>
20
+ <xsl:include href="./tables.xslt"/>
21
+ <xsl:include href="./links.xslt"/>
22
+ <xsl:include href="./images.xslt"/>
23
+ <xsl:template match="/">
24
+ <xsl:apply-templates />
25
+ </xsl:template>
26
+
27
+ <xsl:template match="head" />
28
+
29
+ <xsl:template match="body">
30
+ <xsl:comment>
31
+ KNOWN BUGS:
32
+ div
33
+ h2
34
+ div
35
+ textnode (WONT BE WRAPPED IN A W:P)
36
+ div
37
+ table
38
+ span
39
+ text
40
+ </xsl:comment>
41
+ <xsl:apply-templates/>
42
+ </xsl:template>
43
+
44
+ <xsl:template match="body/*[not(*)]">
45
+ <w:p>
46
+ <xsl:call-template name="text-alignment" />
47
+ <w:r>
48
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
49
+ </w:r>
50
+ </w:p>
51
+ </xsl:template>
52
+
53
+ <xsl:template match="toc-ref">
54
+ <xsl:variable name="data-reference-id" select="@data-reference-id"></xsl:variable>
55
+ <xsl:variable name="first" select="@first"></xsl:variable>
56
+ <xsl:variable name="last" select="@last"></xsl:variable>
57
+ <w:p>
58
+ <w:pPr>
59
+ <w:tabs>
60
+ <w:tab w:val="right" w:pos="9300" w:leader="dot"/>
61
+ </w:tabs>
62
+ <w:rPr/>
63
+ </w:pPr>
64
+ <xsl:choose>
65
+ <xsl:when test="string-length(normalize-space($first)) > 0">
66
+ <w:r>
67
+ <w:fldChar w:fldCharType="begin"/>
68
+ </w:r>
69
+ <w:r>
70
+ <w:rPr>
71
+ <w:rStyle w:val="IndexLink"/>
72
+ </w:rPr>
73
+ <w:instrText> TOC </w:instrText>
74
+ </w:r>
75
+ <w:r>
76
+ <w:rPr>
77
+ <w:rStyle w:val="IndexLink"/>
78
+ </w:rPr>
79
+ <w:fldChar w:fldCharType="separate"/>
80
+ </w:r>
81
+ </xsl:when>
82
+ </xsl:choose>
83
+ <w:hyperlink w:anchor="__RefHeading___Toc_{$data-reference-id}">
84
+ <w:r>
85
+ <w:rPr>
86
+ <w:rStyle w:val="IndexLink"/>
87
+ </w:rPr>
88
+ <w:t xml:space="preserve"> </w:t>
89
+ </w:r>
90
+ <w:r>
91
+ <w:rPr>
92
+ <w:rStyle w:val="IndexLink"/>
93
+ </w:rPr>
94
+ <w:t><xsl:value-of select="."/></w:t>
95
+ <w:tab/>
96
+ <w:t>#</w:t>
97
+ </w:r>
98
+ </w:hyperlink>
99
+ <xsl:choose>
100
+ <xsl:when test="string-length(normalize-space($last)) > 0">
101
+ <w:r>
102
+ <w:rPr>
103
+ <w:rStyle w:val="IndexLink"/>
104
+ </w:rPr>
105
+ <w:fldChar w:fldCharType="end"/>
106
+ </w:r>
107
+ </xsl:when>
108
+ </xsl:choose>
109
+ </w:p>
110
+ </xsl:template>
111
+
112
+ <xsl:template match="cross-ref">
113
+ <xsl:variable name="data-reference-id" select="@data-reference-id"></xsl:variable>
114
+ <w:r>
115
+ <w:fldChar w:fldCharType="begin"/>
116
+ </w:r>
117
+ <w:r>
118
+ <w:instrText xml:space="preserve"> REF _Ref<xsl:value-of select="@data-reference-id"/> \r \h </w:instrText>
119
+ </w:r>
120
+ <w:r>
121
+ <w:fldChar w:fldCharType="separate"/>
122
+ </w:r>
123
+ <w:r>
124
+ <w:t><xsl:value-of select="."/></w:t>
125
+ </w:r>
126
+ <w:r>
127
+ <w:fldChar w:fldCharType="end"/>
128
+ </w:r>
129
+ </xsl:template>
130
+
131
+ <xsl:template match="br[not(ancestor::p) and not(ancestor::div) and not(ancestor::td|ancestor::li) or
132
+ (preceding-sibling::div or following-sibling::div or preceding-sibling::p or following-sibling::p)]">
133
+ <w:p>
134
+ <w:r></w:r>
135
+ </w:p>
136
+ </xsl:template>
137
+
138
+ <xsl:template match="br[(ancestor::li or ancestor::td) and
139
+ (preceding-sibling::div or following-sibling::div or preceding-sibling::p or following-sibling::p)]">
140
+ <w:r>
141
+ <w:br />
142
+ </w:r>
143
+ </xsl:template>
144
+
145
+ <xsl:template match="br">
146
+ <w:r>
147
+ <w:br />
148
+ </w:r>
149
+ </xsl:template>
150
+
151
+ <xsl:template match="pre">
152
+ <w:p>
153
+ <xsl:apply-templates />
154
+ </w:p>
155
+ </xsl:template>
156
+
157
+ <xsl:template match="div[not(ancestor::li) and 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) and not (descendant::pre)]">
158
+ <xsl:comment>Divs should create a p if nothing above them has and nothing below them will</xsl:comment>
159
+ <w:p>
160
+ <xsl:call-template name="text-alignment" />
161
+ <xsl:apply-templates />
162
+ </w:p>
163
+ </xsl:template>
164
+
165
+ <xsl:template match="div">
166
+ <xsl:apply-templates />
167
+ </xsl:template>
168
+
169
+ <!-- TODO: make this prettier. Headings shouldn't enter in template from L51 -->
170
+ <xsl:template match="body/h1|body/h2|body/h3|body/h4|body/h5|body/h6|h1|h2|h3|h4|h5|h6">
171
+ <xsl:variable name="length" select="string-length(name(.))"/>
172
+ <w:p>
173
+ <w:pPr>
174
+ <w:pStyle w:val="Heading{substring(name(.),$length)}"/>
175
+ <xsl:call-template name="heading-alignment" />
176
+ </w:pPr>
177
+ <w:r>
178
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
179
+ </w:r>
180
+ </w:p>
181
+ </xsl:template>
182
+
183
+ <xsl:template match="p[not(ancestor::li)]">
184
+ <w:p>
185
+ <xsl:call-template name="text-alignment" />
186
+ <xsl:apply-templates />
187
+ </w:p>
188
+ </xsl:template>
189
+
190
+ <xsl:template name="listItem" match="li">
191
+ <xsl:variable name="global_level" select="@global_level"></xsl:variable>
192
+ <xsl:variable name="ilvl" select="@level"></xsl:variable>
193
+ <xsl:variable name="toc-ref" select="@toc-ref" />
194
+ <xsl:variable name="cross-ref" select="@cross-ref" />
195
+ <w:p>
196
+ <w:pPr>
197
+ <xsl:choose>
198
+ <xsl:when test="string-length(normalize-space($toc-ref)) > 0">
199
+ <w:pStyle w:val="Heading{$ilvl+1}"/>
200
+ </xsl:when>
201
+ <xsl:otherwise>
202
+ <w:pStyle w:val="ListParagraph"/>
203
+ </xsl:otherwise>
204
+ </xsl:choose>
205
+ <w:numPr>
206
+ <w:ilvl w:val="{$ilvl}"/>
207
+ <w:numId w:val="{$global_level}"/>
208
+ </w:numPr>
209
+ <xsl:call-template name="li-alignment" />
210
+ </w:pPr>
211
+ <xsl:choose>
212
+ <xsl:when test="string-length(normalize-space($toc-ref)) > 0">
213
+ <w:bookmarkStart w:id="{$toc-ref}" w:name="__RefHeading___Toc_{$toc-ref}"/><w:bookmarkEnd w:id="{$toc-ref}"/>
214
+ </xsl:when>
215
+ <xsl:when test="string-length(normalize-space($cross-ref)) > 0">
216
+ <w:bookmarkStart w:id="{$cross-ref}" w:name="_Ref{$cross-ref}"/>
217
+ </xsl:when>
218
+ </xsl:choose>
219
+ <xsl:apply-templates />
220
+ <xsl:choose>
221
+ <xsl:when test="string-length(normalize-space($cross-ref)) > 0">
222
+ <w:bookmarkEnd w:id="{$cross-ref}"/>
223
+ </xsl:when>
224
+ </xsl:choose>
225
+ </w:p>
226
+ </xsl:template>
227
+
228
+ <xsl:template match="span[not(ancestor::td) and not(ancestor::li) 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)]
229
+ |a[not(ancestor::td) and not(ancestor::li) 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)]
230
+ |small[not(ancestor::td) and not(ancestor::li) 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)]
231
+ |strong[not(ancestor::td) and not(ancestor::li) 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)]
232
+ |em[not(ancestor::td) and not(ancestor::li) 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)]
233
+ |i[not(ancestor::td) and not(ancestor::li) 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)]
234
+ |b[not(ancestor::td) and not(ancestor::li) 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)]
235
+ |u[not(ancestor::td) and not(ancestor::li) 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)]">
236
+ <xsl:comment>
237
+ In the following situation:
238
+
239
+ div
240
+ h2
241
+ span
242
+ textnode
243
+ span
244
+ textnode
245
+ p
246
+
247
+ The div template will not create a w:p because the div contains a h2. Therefore we need to wrap the inline elements span|a|small in a p here.
248
+ </xsl:comment>
249
+ <w:p>
250
+ <xsl:choose>
251
+ <xsl:when test="self::a[starts-with(@href, 'http://') or starts-with(@href, 'https://')]">
252
+ <xsl:call-template name="link" />
253
+ </xsl:when>
254
+ <xsl:when test="self::img">
255
+ <xsl:comment>
256
+ This template adds images.
257
+ </xsl:comment>
258
+ <xsl:call-template name="image"/>
259
+ </xsl:when>
260
+ <xsl:otherwise>
261
+ <xsl:apply-templates />
262
+ </xsl:otherwise>
263
+ </xsl:choose>
264
+ </w:p>
265
+ </xsl:template>
266
+
267
+ <xsl:template match="text()[not(parent::li) and not(parent::td) and not(parent::pre) 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)]">
268
+ <xsl:comment>
269
+ In the following situation:
270
+
271
+ div
272
+ h2
273
+ textnode
274
+ p
275
+
276
+ The div template will not create a w:p because the div contains a h2. Therefore we need to wrap the textnode in a p here.
277
+ </xsl:comment>
278
+ <w:p>
279
+ <w:r>
280
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
281
+ </w:r>
282
+ </w:p>
283
+ </xsl:template>
284
+
285
+ <xsl:template match="span[contains(concat(' ', @class, ' '), ' h ')]">
286
+ <xsl:comment>
287
+ This template adds MS Word highlighting ability.
288
+ </xsl:comment>
289
+ <xsl:variable name="color">
290
+ <xsl:choose>
291
+ <xsl:when test="./@data-style='pink'">magenta</xsl:when>
292
+ <xsl:when test="./@data-style='blue'">cyan</xsl:when>
293
+ <xsl:when test="./@data-style='orange'">darkYellow</xsl:when>
294
+ <xsl:otherwise><xsl:value-of select="./@data-style"/></xsl:otherwise>
295
+ </xsl:choose>
296
+ </xsl:variable>
297
+ <xsl:choose>
298
+ <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">
299
+ <w:p>
300
+ <w:r>
301
+ <w:rPr>
302
+ <w:highlight w:val="{$color}"/>
303
+ </w:rPr>
304
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
305
+ </w:r>
306
+ </w:p>
307
+ </xsl:when>
308
+ <xsl:otherwise>
309
+ <w:r>
310
+ <w:rPr>
311
+ <w:highlight w:val="{$color}"/>
312
+ </w:rPr>
313
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
314
+ </w:r>
315
+ </xsl:otherwise>
316
+ </xsl:choose>
317
+ </xsl:template>
318
+
319
+ <xsl:template match="div[contains(concat(' ', @class, ' '), ' -page-break ')]">
320
+ <w:p>
321
+ <w:r>
322
+ <w:br w:type="page" />
323
+ </w:r>
324
+ </w:p>
325
+ <xsl:apply-templates />
326
+ </xsl:template>
327
+
328
+ <xsl:template match="details" />
329
+
330
+ <xsl:template match="text()">
331
+ <xsl:if test="string-length(.) > 0">
332
+ <w:r>
333
+ <xsl:if test="ancestor::i">
334
+ <w:rPr>
335
+ <w:i />
336
+ </w:rPr>
337
+ </xsl:if>
338
+ <xsl:if test="ancestor::b">
339
+ <w:rPr>
340
+ <w:b />
341
+ </w:rPr>
342
+ </xsl:if>
343
+ <xsl:if test="ancestor::u">
344
+ <w:rPr>
345
+ <w:u w:val="single"/>
346
+ </w:rPr>
347
+ </xsl:if>
348
+ <xsl:if test="ancestor::s">
349
+ <w:rPr>
350
+ <w:strike w:val="true"/>
351
+ </w:rPr>
352
+ </xsl:if>
353
+ <xsl:if test="ancestor::sub">
354
+ <w:rPr>
355
+ <w:vertAlign w:val="subscript"/>
356
+ </w:rPr>
357
+ </xsl:if>
358
+ <xsl:if test="ancestor::sup">
359
+ <w:rPr>
360
+ <w:vertAlign w:val="superscript"/>
361
+ </w:rPr>
362
+ </xsl:if>
363
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
364
+ </w:r>
365
+ </xsl:if>
366
+ </xsl:template>
367
+
368
+ <xsl:template match="*">
369
+ <xsl:apply-templates/>
370
+ </xsl:template>
371
+
372
+ <xsl:template name="text-alignment">
373
+ <xsl:param name="class" select="@class" />
374
+ <xsl:param name="style" select="@style" />
375
+ <xsl:param name="line-height" select="@line-height" />
376
+ <xsl:param name="margin-bottom" select="@margin-bottom" />
377
+ <xsl:param name="margin-top" select="@margin-top" />
378
+ <xsl:param name="text-indent" select="@text-indent" />
379
+ <xsl:param name="text-hanging" select="@text-hanging" />
380
+ <xsl:variable name="alignment">
381
+ <xsl:choose>
382
+ <xsl:when test="contains(concat(' ', $class, ' '), ' center ') or contains(translate(normalize-space($style),' ',''), 'text-align:center')">center</xsl:when>
383
+ <xsl:when test="contains(concat(' ', $class, ' '), ' right ') or contains(translate(normalize-space($style),' ',''), 'text-align:right')">right</xsl:when>
384
+ <xsl:when test="contains(concat(' ', $class, ' '), ' left ') or contains(translate(normalize-space($style),' ',''), 'text-align:left')">left</xsl:when>
385
+ <xsl:when test="contains(concat(' ', $class, ' '), ' justify ') or contains(translate(normalize-space($style),' ',''), 'text-align:justify')">both</xsl:when>
386
+ <xsl:otherwise></xsl:otherwise>
387
+ </xsl:choose>
388
+ </xsl:variable>
389
+ <xsl:variable name="indent">
390
+ <xsl:choose>
391
+ <xsl:when test="$text-indent &gt; 0"><xsl:value-of select="$text-indent"/></xsl:when>
392
+ <xsl:otherwise></xsl:otherwise>
393
+ </xsl:choose>
394
+ </xsl:variable>
395
+ <xsl:variable name="hanging">
396
+ <xsl:choose>
397
+ <xsl:when test="string-length(normalize-space($indent)) > 0 and string-length(normalize-space($text-hanging)) > 0"><xsl:value-of select="$text-hanging"/></xsl:when>
398
+ <xsl:when test="string-length(normalize-space($indent)) > 0">0</xsl:when>
399
+ <xsl:otherwise></xsl:otherwise>
400
+ </xsl:choose>
401
+ </xsl:variable>
402
+ <xsl:variable name="height">
403
+ <xsl:choose>
404
+ <xsl:when test="string-length($line-height) > 0"><xsl:value-of select="@line-height"/></xsl:when>
405
+ <xsl:otherwise>336</xsl:otherwise>
406
+ </xsl:choose>
407
+ </xsl:variable>
408
+ <xsl:variable name="bottom">
409
+ <xsl:choose>
410
+ <xsl:when test="string-length($margin-bottom) > 0"><xsl:value-of select="@margin-bottom"/></xsl:when>
411
+ <xsl:otherwise>112</xsl:otherwise>
412
+ </xsl:choose>
413
+ </xsl:variable>
414
+ <xsl:variable name="top">
415
+ <xsl:choose>
416
+ <xsl:when test="string-length($margin-top) > 0"><xsl:value-of select="@margin-top"/></xsl:when>
417
+ <xsl:otherwise>0</xsl:otherwise>
418
+ </xsl:choose>
419
+ </xsl:variable>
420
+ <w:pPr>
421
+ <w:spacing w:lineRule="atLeast" w:line="{$height}" w:before="{$top}" w:after="{$bottom}"/>
422
+ <xsl:choose>
423
+ <xsl:when test="string-length(normalize-space($alignment)) > 0 and string-length(normalize-space($indent)) > 0">
424
+ <w:ind w:left="{$indent}" w:hanging="{$hanging}"/>
425
+ <w:jc w:val="{$alignment}"/>
426
+ </xsl:when>
427
+ <xsl:when test="string-length(normalize-space($indent)) > 0">
428
+ <w:ind w:left="{$indent}" w:hanging="{$hanging}"/>
429
+ </xsl:when>
430
+ <xsl:when test="string-length(normalize-space($alignment)) > 0">
431
+ <w:jc w:val="{$alignment}"/>
432
+ </xsl:when>
433
+ </xsl:choose>
434
+ </w:pPr>
435
+ </xsl:template>
436
+
437
+ <xsl:template name="li-alignment">
438
+ <xsl:param name="class" select="@class" />
439
+ <xsl:param name="line-height" select="@line-height" />
440
+ <xsl:param name="margin-bottom" select="@margin-bottom" />
441
+ <xsl:param name="margin-top" select="@margin-top" />
442
+ <xsl:variable name="alignment">
443
+ <xsl:choose>
444
+ <xsl:when test="string-length(normalize-space($class)) > 0 and contains(concat(' ', $class, ' '), ' center ')">center</xsl:when>
445
+ <xsl:when test="string-length(normalize-space($class)) > 0 and contains(concat(' ', $class, ' '), ' right ')">right</xsl:when>
446
+ <xsl:when test="string-length(normalize-space($class)) > 0 and contains(concat(' ', $class, ' '), ' left ')"></xsl:when>
447
+ <xsl:when test="string-length(normalize-space($class)) > 0 and contains(concat(' ', $class, ' '), ' justify ')">both</xsl:when>
448
+ <xsl:otherwise></xsl:otherwise>
449
+ </xsl:choose>
450
+ </xsl:variable>
451
+ <xsl:variable name="height">
452
+ <xsl:choose>
453
+ <xsl:when test="string-length($line-height) > 0"><xsl:value-of select="@line-height"/></xsl:when>
454
+ <xsl:otherwise>336</xsl:otherwise>
455
+ </xsl:choose>
456
+ </xsl:variable>
457
+ <xsl:variable name="bottom">
458
+ <xsl:choose>
459
+ <xsl:when test="string-length($margin-bottom) > 0"><xsl:value-of select="@margin-bottom"/></xsl:when>
460
+ <xsl:otherwise>112</xsl:otherwise>
461
+ </xsl:choose>
462
+ </xsl:variable>
463
+ <xsl:variable name="top">
464
+ <xsl:choose>
465
+ <xsl:when test="string-length($margin-top) > 0"><xsl:value-of select="@margin-top"/></xsl:when>
466
+ <xsl:otherwise>0</xsl:otherwise>
467
+ </xsl:choose>
468
+ </xsl:variable>
469
+ <w:spacing w:lineRule="atLeast" w:line="{$height}" w:before="{$top}" w:after="{$bottom}"/>
470
+ <xsl:choose>
471
+ <xsl:when test="string-length(normalize-space($alignment)) > 0">
472
+ <w:jc w:val="{$alignment}"/>
473
+ </xsl:when>
474
+ </xsl:choose>
475
+ </xsl:template>
476
+
477
+ <xsl:template name="heading-alignment">
478
+ <xsl:param name="class" select="@class" />
479
+ <xsl:variable name="alignment">
480
+ <xsl:choose>
481
+ <xsl:when test="string-length(normalize-space($class)) > 0 and contains(concat(' ', $class, ' '), ' center ')">center</xsl:when>
482
+ <xsl:when test="string-length(normalize-space($class)) > 0 and contains(concat(' ', $class, ' '), ' right ')">right</xsl:when>
483
+ <xsl:when test="string-length(normalize-space($class)) > 0 and contains(concat(' ', $class, ' '), ' left ')"></xsl:when>
484
+ <xsl:when test="string-length(normalize-space($class)) > 0 and contains(concat(' ', $class, ' '), ' justify ')">both</xsl:when>
485
+ <xsl:otherwise></xsl:otherwise>
486
+ </xsl:choose>
487
+ </xsl:variable>
488
+ <xsl:choose>
489
+ <xsl:when test="string-length(normalize-space($alignment)) > 0">
490
+ <w:jc w:val="{$alignment}"/>
491
+ </xsl:when>
492
+ </xsl:choose>
493
+ </xsl:template>
494
+
495
+ </xsl:stylesheet>
@@ -0,0 +1,72 @@
1
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2
+ xmlns:str="http://exslt.org/strings"
3
+ xmlns:func="http://exslt.org/functions"
4
+ xmlns:fn="http://www.w3.org/2005/xpath-functions"
5
+ version="1.0"
6
+ exclude-result-prefixes="java msxsl ext w o v WX aml w10"
7
+ extension-element-prefixes="func">
8
+ <xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" indent="yes"/>
9
+
10
+ <xsl:template match="/">
11
+ <xsl:apply-templates/>
12
+ </xsl:template>
13
+
14
+ <xsl:template match="head"/>
15
+
16
+ <!-- Elements not supported -->
17
+ <xsl:template match="applet"/>
18
+ <xsl:template match="area"/>
19
+ <xsl:template match="audio"/>
20
+ <xsl:template match="base"/>
21
+ <xsl:template match="basefont"/>
22
+ <xsl:template match="canvas"/>
23
+ <xsl:template match="command"/>
24
+ <xsl:template match="font"/>
25
+ <xsl:template match="iframe"/>
26
+ <xsl:template match="isindex"/>
27
+ <xsl:template match="map"/>
28
+ <xsl:template match="noframes"/>
29
+ <xsl:template match="noscript"/>
30
+ <xsl:template match="object"/>
31
+ <xsl:template match="param"/>
32
+ <xsl:template match="script"/>
33
+ <xsl:template match="source"/>
34
+ <xsl:template match="style"/>
35
+ <xsl:template match="video"/>
36
+ <xsl:template match="header"/>
37
+ <xsl:template match="footer"/>
38
+
39
+ <!-- Elements currently being handled as normal text. Remove tags only -->
40
+ <xsl:template match="abbr"><xsl:apply-templates/></xsl:template>
41
+ <xsl:template match="acronym"><xsl:apply-templates/></xsl:template>
42
+ <xsl:template match="bdi"><xsl:apply-templates/></xsl:template>
43
+ <xsl:template match="bdo"><xsl:apply-templates/></xsl:template>
44
+ <xsl:template match="big"><xsl:apply-templates/></xsl:template>
45
+ <xsl:template match="code"><xsl:apply-templates/></xsl:template>
46
+ <xsl:template match="kbd"><xsl:apply-templates/></xsl:template>
47
+ <xsl:template match="samp"><xsl:apply-templates/></xsl:template>
48
+ <xsl:template match="small"><xsl:apply-templates/></xsl:template>
49
+ <xsl:template match="tt"><xsl:apply-templates/></xsl:template>
50
+ <xsl:template match="var"><xsl:apply-templates/></xsl:template>
51
+
52
+ <!-- Inline elements transformations -->
53
+ <xsl:template match="cite"><i><xsl:apply-templates/></i></xsl:template>
54
+ <xsl:template match="del"><s><xsl:apply-templates/></s></xsl:template>
55
+ <xsl:template match="dfn"><i><xsl:apply-templates/></i></xsl:template>
56
+ <xsl:template match="em"><i><xsl:apply-templates/></i></xsl:template>
57
+ <xsl:template match="ins"><u><xsl:apply-templates/></u></xsl:template>
58
+ <xsl:template match="mark"><span class="h" data-style="yellow"><xsl:apply-templates/></span></xsl:template>
59
+ <xsl:template match="q">"<xsl:apply-templates/>"</xsl:template>
60
+ <xsl:template match="strike"><s><xsl:apply-templates/></s></xsl:template>
61
+ <xsl:template match="strong"><b><xsl:apply-templates/></b></xsl:template>
62
+
63
+ <!-- Block elements transformations -->
64
+ <xsl:template match="section"><div class="{@class}" style="{@style}"><xsl:apply-templates/></div></xsl:template>
65
+ <xsl:template match="article"><div class="{@class}" style="{@style}"><xsl:apply-templates/></div></xsl:template>
66
+
67
+ <xsl:template match="@*|node()">
68
+ <xsl:copy>
69
+ <xsl:apply-templates select="@*|node()"/>
70
+ </xsl:copy>
71
+ </xsl:template>
72
+ </xsl:stylesheet>
@@ -0,0 +1,26 @@
1
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2
+ xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/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 w 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
+ <w:p>
22
+ <w:r></w:r>
23
+ </w:p>
24
+ <xsl:apply-templates/>
25
+ </xsl:template>
26
+ </xsl:stylesheet>