mitimes-htmltoword 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.
@@ -0,0 +1,21 @@
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:import href="./base.xslt"/>
19
+ <!--Extra templates and customizations-->
20
+ <xsl:include href="./extras.xslt"/>
21
+ </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:w="http://schemas.openxmlformats.org/wordprocessingml/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 w 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
+ <w: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
+ <w:r>
24
+ <w:rPr>
25
+ <w:rStyle w:val="Hyperlink"/>
26
+ <w:color w:val="000080"/>
27
+ <w:u w:val="single"/>
28
+ </w:rPr>
29
+ <w:t xml:space="preserve">
30
+ <xsl:value-of select="."/>
31
+ </w:t>
32
+ </w:r>
33
+ </w:hyperlink>
34
+ </xsl:template>
35
+ </xsl:stylesheet>
@@ -0,0 +1,189 @@
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
+
21
+ <func:function name="func:list-type">
22
+ <xsl:param name="tag_name"/>
23
+ <xsl:param name="style"/>
24
+ <xsl:param name="class"/>
25
+ <func:result>
26
+ <xsl:choose>
27
+ <xsl:when test="contains($style, 'list-style-type:') or string-length(normalize-space($class)) > 0">
28
+ <xsl:variable name="lstyle" select="func:substring-before-if-contains(substring-after($style, 'list-style-type:'), ';')"/>
29
+ <xsl:choose>
30
+ <xsl:when test="contains($lstyle, 'lower-alpha') or contains($lstyle, 'lower-latin') or contains($class, 'alfalower')">lowerLetter</xsl:when>
31
+ <xsl:when test="contains($lstyle, 'upper-alpha') or contains($lstyle, 'upper-latin') or contains($class, 'alfaupper')">upperLetter</xsl:when>
32
+ <xsl:when test="contains($lstyle, 'lower-roman') or contains($class, 'romanlower')">lowerRoman</xsl:when>
33
+ <xsl:when test="contains($lstyle, 'upper-roman') or contains($class, 'romanupper')">upperRoman</xsl:when>
34
+ <xsl:when test="contains($lstyle, 'none') or contains($class, 'manuell')">none</xsl:when>
35
+ <xsl:when test="contains($lstyle, 'decimal') or contains($class, 'num') or contains($class, 'token')">decimal</xsl:when>
36
+ <xsl:when test="contains($lstyle, 'disc')">bullet,&#9655;</xsl:when>
37
+ <xsl:when test="contains($lstyle, 'circle')">bullet,o</xsl:when>
38
+ <xsl:when test="contains($lstyle, 'square')">bullet,■</xsl:when>
39
+ <xsl:otherwise>none</xsl:otherwise>
40
+ </xsl:choose>
41
+ </xsl:when>
42
+ <xsl:otherwise>
43
+ <xsl:choose>
44
+ <xsl:when test="$tag_name = 'ol'">decimal</xsl:when>
45
+ <xsl:otherwise>bullet,&#9655;</xsl:otherwise>
46
+ </xsl:choose>
47
+ </xsl:otherwise>
48
+ </xsl:choose>
49
+ </func:result>
50
+ </func:function>
51
+
52
+ <xsl:template match="/">
53
+ <w:numbering xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"
54
+ xmlns:mo="http://schemas.microsoft.com/office/mac/office/2008/main"
55
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
56
+ xmlns:mv="urn:schemas-microsoft-com:mac:vml" xmlns:o="urn:schemas-microsoft-com:office:office"
57
+ xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
58
+ xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
59
+ xmlns:v="urn:schemas-microsoft-com:vml"
60
+ xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"
61
+ xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
62
+ xmlns:w10="urn:schemas-microsoft-com:office:word"
63
+ xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
64
+ xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
65
+ xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"
66
+ xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk"
67
+ xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"
68
+ xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape">
69
+ <xsl:apply-templates />
70
+ <xsl:variable name="nlists" select="count(//ol[not(ancestor::ol) and not(ancestor::ul)]) + count(//ul[not(ancestor::ol) and not(ancestor::ul)])"/>
71
+ <xsl:call-template name="define-abstractNum"/>
72
+ </w:numbering>
73
+ </xsl:template>
74
+
75
+ <xsl:template name="container" match="ol|ul">
76
+ <xsl:variable name="global_level" select="count(preceding::ol[not(ancestor::ol or ancestor::ul)]) + count(preceding::ul[not(ancestor::ol or ancestor::ul)]) + 1"/>
77
+ <xsl:variable name="style" select="func:list-type(name(.), concat(' ', @style, ' '), concat(' ', @class, ' '))"/>
78
+ <xsl:choose>
79
+ <xsl:when test="not(ancestor::ol or ancestor::ul)">
80
+ <w:abstractNum w:abstractNumId="{$global_level - 1}">
81
+ <w:nsid w:val="{concat('099A08C', $global_level)}"/>
82
+ <w:multiLevelType w:val="hybridMultilevel"/>
83
+ <xsl:call-template name="numbering_level">
84
+ <xsl:with-param name="ilvl" select="0"/>
85
+ <xsl:with-param name="style" select="$style"/>
86
+ </xsl:call-template>
87
+ <xsl:call-template name="item"/>
88
+ <xsl:if test="count(.//ol|.//ul) &lt; 6">
89
+ <xsl:call-template name="autocomplete">
90
+ <xsl:with-param name="ilvl" select="count(.//ol) + count(.//ul)"/>
91
+ <xsl:with-param name="style" select="$style"/>
92
+ </xsl:call-template>
93
+ </xsl:if>
94
+ </w:abstractNum>
95
+ </xsl:when>
96
+ <xsl:otherwise>
97
+ <xsl:call-template name="numbering_level">
98
+ <xsl:with-param name="ilvl" select="count(ancestor::ol) + count(ancestor::ul)"/>
99
+ <xsl:with-param name="style" select="$style"/>
100
+ </xsl:call-template>
101
+ <xsl:call-template name="item"/>
102
+ </xsl:otherwise>
103
+ </xsl:choose>
104
+ </xsl:template>
105
+
106
+ <xsl:template name="item">
107
+ <xsl:for-each select="node()">
108
+ <xsl:choose>
109
+ <xsl:when test="self::ol|self::ul">
110
+ <xsl:call-template name="container"/>
111
+ </xsl:when>
112
+ <xsl:otherwise>
113
+ <xsl:call-template name="item"/>
114
+ </xsl:otherwise>
115
+ </xsl:choose>
116
+ </xsl:for-each>
117
+ </xsl:template>
118
+
119
+ <xsl:template match="*">
120
+ <xsl:apply-templates/>
121
+ </xsl:template>
122
+
123
+ <xsl:template match="text()"/>
124
+
125
+ <xsl:template name="numbering_level">
126
+ <xsl:param name="style" />
127
+ <xsl:param name="ilvl" />
128
+ <w:lvl w:ilvl="{$ilvl}">
129
+ <w:start w:val="1"/>
130
+ <w:numFmt w:val="{func:substring-before-if-contains($style, ',')}"/>
131
+ <xsl:choose>
132
+ <xsl:when test="contains($style, 'bullet')">
133
+ <xsl:variable name="list-symbol" select="substring-after($style, ',')"/>
134
+ <w:lvlText w:val="{$list-symbol}"/>
135
+ </xsl:when>
136
+ <xsl:when test="$style = 'none'">
137
+ <w:lvlText w:val=""/>
138
+ </xsl:when>
139
+ <xsl:otherwise>
140
+ <w:lvlText w:val="%{$ilvl + 1}."/>
141
+ </xsl:otherwise>
142
+ </xsl:choose>
143
+ <w:lvlJc w:val="left"/>
144
+ <w:pPr>
145
+ <w:ind w:left="{720 * ($ilvl + 1)}" w:hanging="360"/>
146
+ </w:pPr>
147
+ <xsl:if test="contains($style, 'bullet')">
148
+ <w:rPr>
149
+ <w:rFonts w:ascii="Symbol" w:hAnsi="Symbol" w:hint="default"/>
150
+ </w:rPr>
151
+ </xsl:if>
152
+ </w:lvl>
153
+ </xsl:template>
154
+
155
+ <xsl:template name="autocomplete">
156
+ <xsl:param name="ilvl"/>
157
+ <xsl:param name="style" />
158
+ <xsl:variable name="current_level">
159
+ <xsl:choose>
160
+ <xsl:when test="$ilvl &lt; 1">1</xsl:when>
161
+ <xsl:otherwise><xsl:value-of select="$ilvl"/></xsl:otherwise>
162
+ </xsl:choose>
163
+ </xsl:variable>
164
+ <xsl:if test="$current_level &lt; 6">
165
+ <xsl:call-template name="numbering_level">
166
+ <xsl:with-param name="ilvl" select="$current_level"/>
167
+ <xsl:with-param name="style" select="$style"/>
168
+ </xsl:call-template>
169
+ <xsl:call-template name="autocomplete">
170
+ <xsl:with-param name="ilvl" select="$current_level + 1"/>
171
+ <xsl:with-param name="style" select="$style"/>
172
+ </xsl:call-template>
173
+ </xsl:if>
174
+ </xsl:template>
175
+
176
+ <xsl:template name="define-abstractNum">
177
+ <xsl:param name="current" select="0"/>
178
+ <xsl:param name="max" select="count(//ol[not(ancestor::ol) and not(ancestor::ul)]) + count(//ul[not(ancestor::ol) and not(ancestor::ul)])"/>
179
+ <xsl:if test="$current &lt; $max">
180
+ <w:num w:numId="{$current + 1}">
181
+ <w:abstractNumId w:val="{$current}"/>
182
+ </w:num>
183
+ <xsl:call-template name="define-abstractNum">
184
+ <xsl:with-param name="current" select="$current + 1"/>
185
+ <xsl:with-param name="max" select="$max"/>
186
+ </xsl:call-template>
187
+ </xsl:if>
188
+ </xsl:template>
189
+ </xsl:stylesheet>
@@ -0,0 +1,26 @@
1
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2
+ xmlns="http://schemas.openxmlformats.org/package/2006/relationships"
3
+ version="1.0">
4
+ <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes" indent="yes" />
5
+
6
+ <xsl:template match="a[starts-with(@href, 'http://') or starts-with(@href, 'https://')]" priority="1">
7
+ <Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="{@href}" TargetMode="External">
8
+ <xsl:attribute name="Id">rId<xsl:value-of select="count(preceding::a[starts-with(@href, 'http://') or starts-with(@href, 'https://')]) + 8"/></xsl:attribute>
9
+ </Relationship>
10
+ </xsl:template>
11
+
12
+ <xsl:template match="/">
13
+ <Relationships>
14
+ <Relationship Id="rId3" Type="http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects" Target="stylesWithEffects.xml"/>
15
+ <Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml"/>
16
+ <Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings" Target="webSettings.xml"/>
17
+ <Relationship Id="rId6" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="fontTable.xml"/>
18
+ <Relationship Id="rId7" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/>
19
+ <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" Target="numbering.xml"/>
20
+ <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>
21
+ <xsl:apply-templates select="*"/>
22
+ </Relationships>
23
+ </xsl:template>
24
+
25
+ <xsl:template match="text()|@*"/>
26
+ </xsl:stylesheet>
@@ -0,0 +1,49 @@
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/common"
13
+ xmlns:fn="http://www.w3.org/2005/xpath-functions"
14
+ version="1.0"
15
+ exclude-result-prefixes="java msxsl ext w o v WX aml w10">
16
+
17
+
18
+ <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no" indent="yes" />
19
+
20
+ <xsl:template match="/ | html">
21
+ <w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mo="http://schemas.microsoft.com/office/mac/office/2008/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="urn:schemas-microsoft-com:mac:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 wp14">
22
+ <xsl:apply-templates select="//body"/>
23
+ </w:document>
24
+ </xsl:template>
25
+
26
+ <xsl:template match="body">
27
+ <w:body>
28
+ <w:p>
29
+ <xsl:apply-templates/>
30
+ </w:p>
31
+ <w:sectPr>
32
+ <w:pgSz w:w="11906" w:h="16838"/>
33
+ <w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="708" w:footer="708" w:gutter="0"/>
34
+ <w:cols w:space="708"/>
35
+ <w:docGrid w:linePitch="360"/>
36
+ </w:sectPr>
37
+ </w:body>
38
+ </xsl:template>
39
+
40
+ <xsl:template match="h1|h2|h3|li|span">
41
+ <w:br/>
42
+ <w:r>
43
+ <xsl:comment>Im block</xsl:comment>
44
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
45
+ </w:r>
46
+ <w:br/>
47
+ </xsl:template>
48
+
49
+ </xsl:stylesheet>
@@ -0,0 +1,187 @@
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
+ <!--XSLT support for tables -->
20
+
21
+ <!-- Full width tables per default -->
22
+ <xsl:template match="table">
23
+ <w:tbl>
24
+ <w:tblPr>
25
+ <w:tblStyle w:val="TableGrid"/>
26
+ <w:tblW w:w="5000" w:type="pct"/>
27
+ <xsl:call-template name="tableborders"/>
28
+ <w:tblLook w:val="0600" w:firstRow="0" w:lastRow="0" w:firstColumn="0" w:lastColumn="0" w:noHBand="1" w:noVBand="1"/>
29
+ </w:tblPr>
30
+ <xsl:apply-templates />
31
+ </w: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
+ <w:tr><xsl:apply-templates /></w: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
+ <w:tr>
52
+ <xsl:apply-templates />
53
+ </w:tr>
54
+ </xsl:if>
55
+ </xsl:template>
56
+
57
+ <xsl:template match="th">
58
+ <w:tc>
59
+ <xsl:call-template name="table-cell-properties"/>
60
+ <w:p>
61
+ <w:r>
62
+ <w:rPr>
63
+ <w:b />
64
+ </w:rPr>
65
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
66
+ </w:r>
67
+ </w:p>
68
+ </w:tc>
69
+ </xsl:template>
70
+
71
+ <xsl:template match="td">
72
+ <w: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
+ </w: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
+ <w: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
+ <w: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
+ <w: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
+ </w: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
+ <w:tblBorders>
131
+ <w:top w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
132
+ <w:left w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
133
+ <w:bottom w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
134
+ <w:right w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
135
+ <w:insideH w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
136
+ <w:insideV w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
137
+ </w:tblBorders>
138
+ </xsl:template>
139
+
140
+ <xsl:template name="table-cell-properties">
141
+ <w:tcPr>
142
+ <xsl:if test="contains(@class, 'ms-border-')">
143
+ <w: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
+ </w: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
+ <w:shd w:val="clear" w:color="auto" w:fill="{$cell-bg}" />
154
+ </xsl:if>
155
+ </w: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="w:{$border-location}">
178
+ <xsl:attribute name="w:val"><xsl:value-of select="$border-value" /></xsl:attribute>
179
+ <xsl:attribute name="w:sz"><xsl:value-of select="$border-size" /></xsl:attribute>
180
+ <xsl:attribute name="w:space">0</xsl:attribute>
181
+ <xsl:attribute name="w:color"><xsl:value-of select="$border-color" /></xsl:attribute>
182
+ </xsl:element>
183
+ </xsl:if>
184
+ </xsl:template>
185
+
186
+
187
+ </xsl:stylesheet>