avv2word 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,36 @@
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
+
21
+ <xsl:template match="a[starts-with(@href, 'http://') or starts-with(@href, 'https://')]" name="link">
22
+ <w:hyperlink>
23
+ <xsl:attribute name="r:id"><xsl:call-template name="relationship-id"/></xsl:attribute>
24
+ <w:r>
25
+ <w:rPr>
26
+ <w:rStyle w:val="Hyperlink"/>
27
+ <w:color w:val="000080"/>
28
+ <w:u w:val="single"/>
29
+ </w:rPr>
30
+ <w:t xml:space="preserve">
31
+ <xsl:value-of select="."/>
32
+ </w:t>
33
+ </w:r>
34
+ </w:hyperlink>
35
+ </xsl:template>
36
+ </xsl:stylesheet>
@@ -0,0 +1,171 @@
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="style"/>
23
+ <func:result>
24
+ <xsl:choose>
25
+ <xsl:when test="$style = 'alfalower'">lowerLetter</xsl:when>
26
+ <xsl:when test="$style = 'alfaupper'">upperLetter</xsl:when>
27
+ <xsl:when test="$style = 'romanlower'">lowerRoman</xsl:when>
28
+ <xsl:when test="$style = 'romanupper'">upperRoman</xsl:when>
29
+ <xsl:when test="$style = 'manuell'">none</xsl:when>
30
+ <xsl:when test="$style = 'num'">decimal</xsl:when>
31
+ <xsl:when test="$style = 'disc'">bullet,●</xsl:when>
32
+ <xsl:when test="$style = 'circle'">bullet,o</xsl:when>
33
+ <xsl:when test="$style = 'square'">bullet,■</xsl:when>
34
+ <xsl:otherwise>none</xsl:otherwise>
35
+ </xsl:choose>
36
+ </func:result>
37
+ </func:function>
38
+
39
+ <xsl:template match="/">
40
+ <w:numbering xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"
41
+ xmlns:mo="http://schemas.microsoft.com/office/mac/office/2008/main"
42
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
43
+ xmlns:mv="urn:schemas-microsoft-com:mac:vml" xmlns:o="urn:schemas-microsoft-com:office:office"
44
+ xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
45
+ xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
46
+ xmlns:v="urn:schemas-microsoft-com:vml"
47
+ xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"
48
+ xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
49
+ xmlns:w10="urn:schemas-microsoft-com:office:word"
50
+ xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
51
+ xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
52
+ xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"
53
+ xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk"
54
+ xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"
55
+ xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape">
56
+ <xsl:apply-templates />
57
+ <xsl:variable name="nlists" select="count(//ol[not(ancestor::ol) and not(ancestor::ul)]) + count(//ul[not(ancestor::ol) and not(ancestor::ul)])"/>
58
+ <xsl:call-template name="define-abstractNum"/>
59
+ </w:numbering>
60
+ </xsl:template>
61
+
62
+ <xsl:template name="container" match="ol|ul">
63
+ <xsl:variable name="global_level" select="@global_level"/>
64
+ <xsl:variable name="style" select="func:list-type(@style)"/>
65
+ <xsl:choose>
66
+ <xsl:when test="not(ancestor::ol or ancestor::ul)">
67
+ <w:abstractNum w:abstractNumId="{$global_level}">
68
+ <w:nsid w:val="{concat('099A08C', $global_level)}"/>
69
+ <w:multiLevelType w:val="hybridMultilevel"/>
70
+ <xsl:call-template name="numbering_level">
71
+ <xsl:with-param name="ilvl" select="0"/>
72
+ <xsl:with-param name="style" select="$style"/>
73
+ <xsl:with-param name="indent" select="@indent"/>
74
+ <xsl:with-param name="hanging" select="@hanging"/>
75
+ <xsl:with-param name="style-format" select="@style-format"/>
76
+ </xsl:call-template>
77
+ <xsl:call-template name="item"/>
78
+ </w:abstractNum>
79
+ </xsl:when>
80
+ <xsl:when test="@level &gt; 0">
81
+ <xsl:call-template name="numbering_level">
82
+ <xsl:with-param name="ilvl" select="@level"/>
83
+ <xsl:with-param name="style" select="$style"/>
84
+ <xsl:with-param name="indent" select="@indent"/>
85
+ <xsl:with-param name="hanging" select="@hanging"/>
86
+ <xsl:with-param name="style-format" select="@style-format"/>
87
+ </xsl:call-template>
88
+ <xsl:call-template name="item"/>
89
+ </xsl:when>
90
+ <xsl:otherwise>
91
+ <xsl:call-template name="item"/>
92
+ </xsl:otherwise>
93
+ </xsl:choose>
94
+ </xsl:template>
95
+
96
+ <xsl:template name="item">
97
+ <xsl:for-each select="node()">
98
+ <xsl:choose>
99
+ <xsl:when test="self::ol|self::ul">
100
+ <xsl:call-template name="container"/>
101
+ </xsl:when>
102
+ <xsl:otherwise>
103
+ <xsl:call-template name="item"/>
104
+ </xsl:otherwise>
105
+ </xsl:choose>
106
+ </xsl:for-each>
107
+ </xsl:template>
108
+
109
+ <xsl:template match="*">
110
+ <xsl:apply-templates/>
111
+ </xsl:template>
112
+
113
+ <xsl:template match="text()"/>
114
+
115
+ <xsl:template name="numbering_level">
116
+ <xsl:param name="style" />
117
+ <xsl:param name="ilvl" />
118
+ <xsl:param name="indent" />
119
+ <xsl:param name="hanging" />
120
+ <xsl:param name="style-format" />
121
+ <w:lvl w:ilvl="{$ilvl}">
122
+ <w:start w:val="1"/>
123
+ <w:numFmt w:val="{func:substring-before-if-contains($style, ',')}"/>
124
+ <w:lvlText w:val="{$style-format}"/>
125
+ <w:lvlJc w:val="left"/>
126
+ <w:pPr>
127
+ <w:ind w:left="{$indent}" w:hanging="{$hanging}"/>
128
+ </w:pPr>
129
+ <xsl:if test="contains($style, 'bullet')">
130
+ <w:rPr>
131
+ <w:u w:val="none"/>
132
+ </w:rPr>
133
+ </xsl:if>
134
+ </w:lvl>
135
+ </xsl:template>
136
+
137
+ <xsl:template name="autocomplete">
138
+ <xsl:param name="ilvl"/>
139
+ <xsl:param name="style" />
140
+ <xsl:variable name="current_level">
141
+ <xsl:choose>
142
+ <xsl:when test="$ilvl &lt; 1">1</xsl:when>
143
+ <xsl:otherwise><xsl:value-of select="$ilvl"/></xsl:otherwise>
144
+ </xsl:choose>
145
+ </xsl:variable>
146
+ <xsl:if test="$current_level &lt; 6">
147
+ <xsl:call-template name="numbering_level">
148
+ <xsl:with-param name="ilvl" select="$current_level"/>
149
+ <xsl:with-param name="style" select="$style"/>
150
+ </xsl:call-template>
151
+ <xsl:call-template name="autocomplete">
152
+ <xsl:with-param name="ilvl" select="$current_level + 1"/>
153
+ <xsl:with-param name="style" select="$style"/>
154
+ </xsl:call-template>
155
+ </xsl:if>
156
+ </xsl:template>
157
+
158
+ <xsl:template name="define-abstractNum">
159
+ <xsl:param name="current" select="0"/>
160
+ <xsl:param name="max" select="count(//ol[not(ancestor::ol) and not(ancestor::ul)]) + count(//ul[not(ancestor::ol) and not(ancestor::ul)])"/>
161
+ <xsl:if test="$current &lt; $max">
162
+ <w:num w:numId="{$current + 1}">
163
+ <w:abstractNumId w:val="{$current}"/>
164
+ </w:num>
165
+ <xsl:call-template name="define-abstractNum">
166
+ <xsl:with-param name="current" select="$current + 1"/>
167
+ <xsl:with-param name="max" select="$max"/>
168
+ </xsl:call-template>
169
+ </xsl:if>
170
+ </xsl:template>
171
+ </xsl:stylesheet>
@@ -0,0 +1,58 @@
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:include href="./image_functions.xslt"/>
7
+ <xsl:include href="./functions.xslt"/>
8
+
9
+ <xsl:template match="a[starts-with(@href, 'http://') or starts-with(@href, 'https://')]" priority="1">
10
+ <Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="{@href}" TargetMode="External" Id="rId100">
11
+ <xsl:attribute name="Id"><xsl:call-template name="relationship-id"/></xsl:attribute>
12
+ </Relationship>
13
+ </xsl:template>
14
+
15
+ <!--
16
+ Images can either be embedded in the document or referenced via the external url.
17
+ By default images are embedded and a copy will be stored in the final zip folder.
18
+ If you want your images to be referenced externally (don't store the image files) then add data-external="true" to your image tag(s).
19
+ If you are embedding them images need a filename. You can either define one by passing the name and extension to data-filename or rely on the defaul which is the last part of the source url.
20
+ **Word files can be corrupted if an extension isn't present so if you are relying on the source url ensure that is has an extension.**
21
+ -->
22
+ <xsl:template match="img" priority="0">
23
+ <Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Id="rId101" Target="#">
24
+ <xsl:choose>
25
+ <xsl:when test="@data-external = 'true'">
26
+ <xsl:attribute name="Target"><xsl:value-of select="@src"/></xsl:attribute>
27
+ <xsl:attribute name="TargetMode">External</xsl:attribute>
28
+ </xsl:when>
29
+
30
+ <xsl:otherwise>
31
+ <xsl:attribute name="Target">media/image<xsl:value-of select="count(preceding::img)+1"/>.<xsl:call-template name="image-extension">
32
+ <xsl:with-param name="source" select="@src"/>
33
+ <xsl:with-param name="data-filename" select="@data-filename"/>
34
+ </xsl:call-template>
35
+ </xsl:attribute>
36
+ </xsl:otherwise>
37
+ </xsl:choose>
38
+
39
+ <xsl:attribute name="Id"><xsl:call-template name="relationship-id"/></xsl:attribute>
40
+ </Relationship>
41
+ </xsl:template>
42
+
43
+ <xsl:template match="/">
44
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
45
+ <Relationships>
46
+ <Relationship Id="rId3" Type="http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects" Target="stylesWithEffects.xml"/>
47
+ <Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml"/>
48
+ <Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings" Target="webSettings.xml"/>
49
+ <Relationship Id="rId6" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="fontTable.xml"/>
50
+ <Relationship Id="rId7" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/>
51
+ <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" Target="numbering.xml"/>
52
+ <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>
53
+ <Relationship Id="rId8" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" Target="header.xml"/>
54
+ <Relationship Id="rId9" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" Target="footer.xml"/>
55
+ </Relationships>
56
+ </xsl:template>
57
+
58
+ </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,201 @@
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:jc w:val="left"/>
27
+ <w:tblInd w:w="0.0" w:type="dxa"/>
28
+ <xsl:call-template name="tableborders"/>
29
+ <w:tblLayout w:type="fixed"/>
30
+ <w:tblLook w:val="0600"/>
31
+ </w:tblPr>
32
+ <w:tblGrid>
33
+ <xsl:value-of select="./@tablegrid"/>
34
+ </w:tblGrid>
35
+ <xsl:apply-templates />
36
+ </w:tbl>
37
+ </xsl:template>
38
+
39
+ <xsl:template match="tbody">
40
+ <xsl:apply-templates />
41
+ </xsl:template>
42
+
43
+ <xsl:template match="thead">
44
+ <xsl:choose>
45
+ <xsl:when test="count(./tr) = 0">
46
+ <w:tr><xsl:apply-templates /></w:tr>
47
+ </xsl:when>
48
+ <xsl:otherwise>
49
+ <xsl:apply-templates />
50
+ </xsl:otherwise>
51
+ </xsl:choose>
52
+ </xsl:template>
53
+
54
+ <xsl:template match="tr">
55
+ <xsl:if test="string-length(.) > 0">
56
+ <w:tr>
57
+ <xsl:apply-templates />
58
+ </w:tr>
59
+ </xsl:if>
60
+ </xsl:template>
61
+
62
+ <xsl:template match="th">
63
+ <w:tc>
64
+ <xsl:call-template name="table-cell-properties"/>
65
+ <w:p>
66
+ <w:r>
67
+ <w:rPr>
68
+ <w:b />
69
+ </w:rPr>
70
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
71
+ </w:r>
72
+ </w:p>
73
+ </w:tc>
74
+ </xsl:template>
75
+
76
+ <xsl:template match="td">
77
+ <w:tc>
78
+ <xsl:call-template name="table-cell-properties"/>
79
+ <xsl:call-template name="block">
80
+ <xsl:with-param name="current" select="." />
81
+ <xsl:with-param name="class" select="@class" />
82
+ <xsl:with-param name="style" select="@style" />
83
+ </xsl:call-template>
84
+ </w:tc>
85
+ </xsl:template>
86
+
87
+ <xsl:template name="block">
88
+ <xsl:param name="current" />
89
+ <xsl:param name="class" />
90
+ <xsl:param name="style" />
91
+ <xsl:if test="count($current/*|$current/text()) = 0">
92
+ <w:p/>
93
+ </xsl:if>
94
+ <xsl:for-each select="$current/*|$current/text()">
95
+ <xsl:choose>
96
+ <xsl:when test="name(.) = 'table'">
97
+ <xsl:apply-templates select="." />
98
+ <w:p/>
99
+ </xsl:when>
100
+ <xsl:when test="contains('|p|h1|h2|h3|h4|h5|h6|ul|ol|', concat('|', name(.), '|'))">
101
+ <xsl:apply-templates select="." />
102
+ </xsl:when>
103
+ <xsl:when test="descendant::table|descendant::p|descendant::h1|descendant::h2|descendant::h3|descendant::h4|descendant::h5|descendant::h6|descendant::li">
104
+ <xsl:call-template name="block">
105
+ <xsl:with-param name="current" select="."/>
106
+ </xsl:call-template>
107
+ </xsl:when>
108
+ <xsl:otherwise>
109
+ <w:p>
110
+ <xsl:call-template name="text-alignment">
111
+ <xsl:with-param name="class" select="$class" />
112
+ <xsl:with-param name="style" select="$style" />
113
+ </xsl:call-template>
114
+ <xsl:apply-templates select="." />
115
+ </w:p>
116
+ </xsl:otherwise>
117
+ </xsl:choose>
118
+ </xsl:for-each>
119
+ </xsl:template>
120
+
121
+ <xsl:template name="tableborders">
122
+ <xsl:variable name="border">
123
+ <xsl:choose>
124
+ <xsl:when test="contains(concat(' ', @class, ' '), ' table-bordered ')">6</xsl:when>
125
+ <xsl:when test="not(@border)">0</xsl:when>
126
+ <xsl:otherwise><xsl:value-of select="./@border * 6"/></xsl:otherwise>
127
+ </xsl:choose>
128
+ </xsl:variable>
129
+ <xsl:variable name="bordertype">
130
+ <xsl:choose>
131
+ <xsl:when test="$border=0">none</xsl:when>
132
+ <xsl:otherwise>single</xsl:otherwise>
133
+ </xsl:choose>
134
+ </xsl:variable>
135
+ <w:tblBorders>
136
+ <w:top w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
137
+ <w:left w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
138
+ <w:bottom w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
139
+ <w:right w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
140
+ <w:insideH w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
141
+ <w:insideV w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
142
+ </w:tblBorders>
143
+ </xsl:template>
144
+
145
+ <xsl:template name="table-cell-properties">
146
+ <w:tcPr>
147
+ <xsl:if test="contains(@class, 'ms-border-')">
148
+ <w:tcBorders>
149
+ <xsl:for-each select="str:tokenize(@class, ' ')">
150
+ <xsl:call-template name="define-border">
151
+ <xsl:with-param name="class" select="." />
152
+ </xsl:call-template>
153
+ </xsl:for-each>
154
+ </w:tcBorders>
155
+ </xsl:if>
156
+ <xsl:if test="contains(@class, 'ms-fill-')">
157
+ <xsl:variable name="cell-bg" select="str:tokenize(substring-after(@class, 'ms-fill-'), ' ')[1]"/>
158
+ <w:shd w:val="clear" w:color="auto" w:fill="{$cell-bg}" />
159
+ </xsl:if>
160
+ <xsl:if test="@colspan &gt; 1">
161
+ <w:gridSpan w:val="{@colspan}"/>
162
+ </xsl:if>
163
+ <xsl:if test="@rowspan &gt; 0">
164
+ <w:vMerge w:val="restart"/>
165
+ </xsl:if>
166
+ <xsl:if test="@rowspan=0">
167
+ <w:vMerge/>
168
+ </xsl:if>
169
+ </w:tcPr>
170
+ </xsl:template>
171
+
172
+ <xsl:template name="define-border">
173
+ <xsl:param name="class" />
174
+ <xsl:if test="contains($class, 'ms-border-')">
175
+ <xsl:variable name="border" select="substring-after($class, 'ms-border-')"/>
176
+ <xsl:variable name="border-properties" select="str:tokenize($border, '-')"/>
177
+ <xsl:variable name="border-location" select="$border-properties[1]" />
178
+ <xsl:variable name="border-value" select="$border-properties[2]" />
179
+ <xsl:variable name="border-color">
180
+ <xsl:choose>
181
+ <xsl:when test="string-length($border-properties[3]) > 0"><xsl:value-of select="$border-properties[3]"/></xsl:when>
182
+ <xsl:otherwise>000000</xsl:otherwise>
183
+ </xsl:choose>
184
+ </xsl:variable>
185
+ <xsl:variable name="border-size">
186
+ <xsl:choose>
187
+ <xsl:when test="string-length($border-properties[4]) > 0"><xsl:value-of select="$border-properties[4] * 6"/></xsl:when>
188
+ <xsl:otherwise>6</xsl:otherwise>
189
+ </xsl:choose>
190
+ </xsl:variable>
191
+ <xsl:element name="w:{$border-location}">
192
+ <xsl:attribute name="w:val"><xsl:value-of select="$border-value" /></xsl:attribute>
193
+ <xsl:attribute name="w:sz"><xsl:value-of select="$border-size" /></xsl:attribute>
194
+ <xsl:attribute name="w:space">0</xsl:attribute>
195
+ <xsl:attribute name="w:color"><xsl:value-of select="$border-color" /></xsl:attribute>
196
+ </xsl:element>
197
+ </xsl:if>
198
+ </xsl:template>
199
+
200
+
201
+ </xsl:stylesheet>
data/lib/avv2word.rb ADDED
@@ -0,0 +1,29 @@
1
+ # encoding: UTF-8
2
+ require 'nokogiri'
3
+ require 'zip'
4
+ require 'open-uri'
5
+ require_relative 'avv2word/configuration'
6
+
7
+ module Avv2word
8
+ class << self
9
+ def configure
10
+ yield configuration
11
+ end
12
+
13
+ def configuration
14
+ @configuration ||= Configuration.new
15
+ end
16
+
17
+ alias_method :config, :configuration
18
+ end
19
+ end
20
+
21
+ require_relative 'avv2word/version'
22
+ require_relative 'avv2word/helpers/templates_helper'
23
+ require_relative 'avv2word/helpers/xslt_helper'
24
+ require_relative 'avv2word/document'
25
+
26
+ if defined?(Rails)
27
+ require_relative 'avv2word/renderer'
28
+ require_relative 'avv2word/railtie'
29
+ end