janie-htmltoword 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +194 -0
- data/Rakefile +4 -0
- data/bin/htmltoword +36 -0
- data/lib/htmltoword.rb +29 -0
- data/lib/htmltoword/configuration.rb +12 -0
- data/lib/htmltoword/document.rb +155 -0
- data/lib/htmltoword/helpers/templates_helper.rb +9 -0
- data/lib/htmltoword/helpers/xslt_helper.rb +17 -0
- data/lib/htmltoword/railtie.rb +25 -0
- data/lib/htmltoword/renderer.rb +43 -0
- data/lib/htmltoword/templates/default.docx +0 -0
- data/lib/htmltoword/version.rb +3 -0
- data/lib/htmltoword/xslt/base.xslt +363 -0
- data/lib/htmltoword/xslt/cleanup.xslt +71 -0
- data/lib/htmltoword/xslt/extras.xslt +26 -0
- data/lib/htmltoword/xslt/functions.xslt +37 -0
- data/lib/htmltoword/xslt/header.xslt +34 -0
- data/lib/htmltoword/xslt/htmltoword.xslt +22 -0
- data/lib/htmltoword/xslt/image_functions.xslt +148 -0
- data/lib/htmltoword/xslt/images.xslt +136 -0
- data/lib/htmltoword/xslt/inline_elements.xslt +40 -0
- data/lib/htmltoword/xslt/links.xslt +34 -0
- data/lib/htmltoword/xslt/numbering.xslt +189 -0
- data/lib/htmltoword/xslt/relations.xslt +58 -0
- data/lib/htmltoword/xslt/style2.xslt +49 -0
- data/lib/htmltoword/xslt/tables.xslt +190 -0
- metadata +185 -0
@@ -0,0 +1,71 @@
|
|
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="img[not(starts-with(@src, 'http://')) and not(starts-with(@src, 'https://'))]"/>
|
27
|
+
<xsl:template match="isindex"/>
|
28
|
+
<xsl:template match="map"/>
|
29
|
+
<xsl:template match="noframes"/>
|
30
|
+
<xsl:template match="noscript"/>
|
31
|
+
<xsl:template match="object"/>
|
32
|
+
<xsl:template match="param"/>
|
33
|
+
<xsl:template match="script"/>
|
34
|
+
<xsl:template match="source"/>
|
35
|
+
<xsl:template match="style"/>
|
36
|
+
<xsl:template match="video"/>
|
37
|
+
|
38
|
+
<!-- Elements currently being handled as normal text. Remove tags only -->
|
39
|
+
<xsl:template match="abbr"><xsl:apply-templates/></xsl:template>
|
40
|
+
<xsl:template match="acronym"><xsl:apply-templates/></xsl:template>
|
41
|
+
<xsl:template match="bdi"><xsl:apply-templates/></xsl:template>
|
42
|
+
<xsl:template match="bdo"><xsl:apply-templates/></xsl:template>
|
43
|
+
<xsl:template match="big"><xsl:apply-templates/></xsl:template>
|
44
|
+
<xsl:template match="code"><xsl:apply-templates/></xsl:template>
|
45
|
+
<xsl:template match="kbd"><xsl:apply-templates/></xsl:template>
|
46
|
+
<xsl:template match="samp"><xsl:apply-templates/></xsl:template>
|
47
|
+
<xsl:template match="small"><xsl:apply-templates/></xsl:template>
|
48
|
+
<xsl:template match="tt"><xsl:apply-templates/></xsl:template>
|
49
|
+
<xsl:template match="var"><xsl:apply-templates/></xsl:template>
|
50
|
+
|
51
|
+
<!-- Inline elements transformations -->
|
52
|
+
<xsl:template match="cite"><i><xsl:apply-templates/></i></xsl:template>
|
53
|
+
<xsl:template match="del"><s><xsl:apply-templates/></s></xsl:template>
|
54
|
+
<xsl:template match="dfn"><i><xsl:apply-templates/></i></xsl:template>
|
55
|
+
<xsl:template match="em"><i><xsl:apply-templates/></i></xsl:template>
|
56
|
+
<xsl:template match="ins"><u><xsl:apply-templates/></u></xsl:template>
|
57
|
+
<xsl:template match="mark"><span class="h" data-style="yellow"><xsl:apply-templates/></span></xsl:template>
|
58
|
+
<xsl:template match="q">"<xsl:apply-templates/>"</xsl:template>
|
59
|
+
<xsl:template match="strike"><s><xsl:apply-templates/></s></xsl:template>
|
60
|
+
<xsl:template match="strong"><b><xsl:apply-templates/></b></xsl:template>
|
61
|
+
|
62
|
+
<!-- Block elements transformations -->
|
63
|
+
<xsl:template match="section"><div class="{@class}" style="{@style}"><xsl:apply-templates/></div></xsl:template>
|
64
|
+
<xsl:template match="article"><div class="{@class}" style="{@style}"><xsl:apply-templates/></div></xsl:template>
|
65
|
+
|
66
|
+
<xsl:template match="@*|node()">
|
67
|
+
<xsl:copy>
|
68
|
+
<xsl:apply-templates select="@*|node()"/>
|
69
|
+
</xsl:copy>
|
70
|
+
</xsl:template>
|
71
|
+
</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>
|
@@ -0,0 +1,37 @@
|
|
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
|
+
<!-- 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
|
+
|
35
|
+
<!-- template as function used to return the relationship id of the element (currently links or images) -->
|
36
|
+
<xsl:template name="relationship-id">rId<xsl:value-of select="count(preceding::a[starts-with(@href, 'http://') or starts-with(@href, 'https://')])+count(preceding::img)+8"/></xsl:template>
|
37
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
3
|
+
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
|
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
|
+
<!-- use block quotes for spacing (can be nested) -->
|
21
|
+
<xsl:template match="header">
|
22
|
+
<w:style w:type="paragraph" w:styleId="Header" >
|
23
|
+
<w:name w:val="header"/>
|
24
|
+
<w:basedOn w:val="Normal"/>
|
25
|
+
<w:pPr>
|
26
|
+
<w:pStyle w:val="Header"/>
|
27
|
+
<w:tabs>
|
28
|
+
<w:tab w:val="center" w:pos="4320"/>
|
29
|
+
<w:tab w:val="right" w:pos="8640"/>
|
30
|
+
</w:tabs>
|
31
|
+
</w:pPr>
|
32
|
+
</w:style>
|
33
|
+
</xsl:template>
|
34
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,22 @@
|
|
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:include href="./header.xslt"/>
|
22
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,148 @@
|
|
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
|
+
<!-- template as function used to return the file extension of an image. -->
|
21
|
+
<xsl:template name="image-extension">
|
22
|
+
<xsl:param name="data-filename" select="." />
|
23
|
+
<xsl:param name="source" select="." />
|
24
|
+
<xsl:variable name="filename">
|
25
|
+
<xsl:call-template name="image-name">
|
26
|
+
<xsl:with-param name="source" select="$source"/>
|
27
|
+
<xsl:with-param name="data-filename" select="$data-filename"/>
|
28
|
+
</xsl:call-template>
|
29
|
+
</xsl:variable>
|
30
|
+
<xsl:value-of select="substring-after($filename,'.')"/>
|
31
|
+
</xsl:template>
|
32
|
+
|
33
|
+
<!-- template as function used to return the name of an image. -->
|
34
|
+
<xsl:template name="image-name">
|
35
|
+
<xsl:param name="data-filename" select="." />
|
36
|
+
<xsl:param name="source" select="." />
|
37
|
+
<xsl:choose>
|
38
|
+
<xsl:when test="string-length($data-filename) > 0">
|
39
|
+
<xsl:value-of select="$data-filename"/>
|
40
|
+
</xsl:when>
|
41
|
+
<xsl:otherwise>
|
42
|
+
<xsl:call-template name="extract-filename-from-path">
|
43
|
+
<xsl:with-param name="path" select="$source"/>
|
44
|
+
</xsl:call-template>
|
45
|
+
</xsl:otherwise>
|
46
|
+
</xsl:choose>
|
47
|
+
</xsl:template>
|
48
|
+
|
49
|
+
<!-- template as function used to extract the filename from the image source. Can't use tokenize or other functions which return a fragment tree as xpath can't process them. -->
|
50
|
+
<xsl:template name="extract-filename-from-path">
|
51
|
+
<xsl:param name="path" select="." />
|
52
|
+
<xsl:choose>
|
53
|
+
<xsl:when test="not(contains($path, '/'))">
|
54
|
+
<xsl:value-of select="$path" />
|
55
|
+
</xsl:when>
|
56
|
+
<xsl:otherwise>
|
57
|
+
<xsl:call-template name="extract-filename-from-path">
|
58
|
+
<xsl:with-param name="path" select="substring-after($path, '/')" />
|
59
|
+
</xsl:call-template>
|
60
|
+
</xsl:otherwise>
|
61
|
+
</xsl:choose>
|
62
|
+
</xsl:template>
|
63
|
+
|
64
|
+
<!--
|
65
|
+
Returns the unqualified dimension from a length specification copied from:
|
66
|
+
http://docbook.sourceforge.net/release/xsl/1.76.1/doc/lib/length-magnitude.html
|
67
|
+
-->
|
68
|
+
|
69
|
+
<xsl:template name="length-magnitude">
|
70
|
+
<xsl:param name="length" select="'0pt'"></xsl:param>
|
71
|
+
|
72
|
+
<xsl:choose>
|
73
|
+
<xsl:when test="string-length($length) = 0"></xsl:when>
|
74
|
+
<xsl:when test="substring($length,1,1) = '0' or substring($length,1,1) = '1' or substring($length,1,1) = '2' or substring($length,1,1) = '3' or substring($length,1,1) = '4' or substring($length,1,1) = '5' or substring($length,1,1) = '6' or substring($length,1,1) = '7' or substring($length,1,1) = '8' or substring($length,1,1) = '9' or substring($length,1,1) = '.'">
|
75
|
+
<xsl:value-of select="substring($length,1,1)"></xsl:value-of>
|
76
|
+
<xsl:call-template name="length-magnitude">
|
77
|
+
<xsl:with-param name="length" select="substring($length,2)"></xsl:with-param>
|
78
|
+
</xsl:call-template>
|
79
|
+
</xsl:when>
|
80
|
+
</xsl:choose>
|
81
|
+
</xsl:template>
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
<!-- Convert em and pixel sizes to inches. Inspired by from:
|
87
|
+
http://docbook.sourceforge.net/release/xsl/1.76.1/doc/lib/length-in-points.html
|
88
|
+
EMU info from: https://startbigthinksmall.wordpress.com/2010/01/04/points-inches-and-emus-measuring-units-in-office-open-xml/
|
89
|
+
-->
|
90
|
+
<xsl:template name="length-in-emus">
|
91
|
+
<xsl:param name="length" select="'0px'"/>
|
92
|
+
<xsl:param name="em.size" select="6.02250006023"/>
|
93
|
+
<xsl:param name="pixels.per.inch" select="90"/>
|
94
|
+
<xsl:variable name="emus.per.inch" select="914400"/>
|
95
|
+
|
96
|
+
<xsl:variable name="magnitude">
|
97
|
+
<xsl:call-template name="length-magnitude">
|
98
|
+
<xsl:with-param name="length" select="$length"/>
|
99
|
+
</xsl:call-template>
|
100
|
+
</xsl:variable>
|
101
|
+
|
102
|
+
<xsl:variable name="units">
|
103
|
+
<xsl:value-of select="substring($length, string-length($magnitude)+1)"/>
|
104
|
+
</xsl:variable>
|
105
|
+
|
106
|
+
<xsl:variable name="inches">
|
107
|
+
<xsl:choose>
|
108
|
+
<xsl:when test="$units = 'px'">
|
109
|
+
<xsl:value-of select="$magnitude div $pixels.per.inch"/>
|
110
|
+
</xsl:when>
|
111
|
+
<xsl:when test="$units = 'em'">
|
112
|
+
<xsl:value-of select="$magnitude div $em.size"/>
|
113
|
+
</xsl:when>
|
114
|
+
<xsl:otherwise>
|
115
|
+
<xsl:message>
|
116
|
+
<xsl:text>Unrecognized unit of measure: </xsl:text>
|
117
|
+
<xsl:value-of select="$units"></xsl:value-of>
|
118
|
+
<xsl:text>.</xsl:text>
|
119
|
+
</xsl:message>
|
120
|
+
</xsl:otherwise>
|
121
|
+
</xsl:choose>
|
122
|
+
</xsl:variable>
|
123
|
+
|
124
|
+
<xsl:value-of select="$inches * $emus.per.inch"/>
|
125
|
+
</xsl:template>
|
126
|
+
|
127
|
+
<!-- template as function used to get the width or height of an image in points. -->
|
128
|
+
<xsl:template name="image-dimention">
|
129
|
+
<xsl:param name="style" />
|
130
|
+
<xsl:param name="data-value" />
|
131
|
+
<xsl:param name="type" />
|
132
|
+
|
133
|
+
<xsl:variable name="size">
|
134
|
+
<xsl:choose>
|
135
|
+
<xsl:when test="string-length($data-value) > 0">
|
136
|
+
<xsl:value-of select="$data-value" />
|
137
|
+
</xsl:when>
|
138
|
+
<xsl:when test="contains($style, concat($type,':'))">
|
139
|
+
<xsl:value-of select="translate(str:tokenize(substring-after($style, concat($type,':')), ';')[1],' 	
','')" />
|
140
|
+
</xsl:when>
|
141
|
+
<xsl:otherwise>1</xsl:otherwise>
|
142
|
+
</xsl:choose>
|
143
|
+
</xsl:variable>
|
144
|
+
<xsl:call-template name="length-in-emus">
|
145
|
+
<xsl:with-param name="length" select="$size"/>
|
146
|
+
</xsl:call-template>
|
147
|
+
</xsl:template>
|
148
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,136 @@
|
|
1
|
+
<xsl:stylesheet xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"
|
2
|
+
xmlns:mo="http://schemas.microsoft.com/office/mac/office/2008/main"
|
3
|
+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
4
|
+
xmlns:mv="urn:schemas-microsoft-com:mac:vml"
|
5
|
+
xmlns:o="urn:schemas-microsoft-com:office:office"
|
6
|
+
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
7
|
+
xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
|
8
|
+
xmlns:v="urn:schemas-microsoft-com:vml"
|
9
|
+
xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"
|
10
|
+
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
|
11
|
+
xmlns:w10="urn:schemas-microsoft-com:office:word"
|
12
|
+
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
|
13
|
+
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
|
14
|
+
xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml"
|
15
|
+
xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"
|
16
|
+
xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk"
|
17
|
+
xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"
|
18
|
+
xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
|
19
|
+
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
|
20
|
+
xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main"
|
21
|
+
xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"
|
22
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
23
|
+
xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
|
24
|
+
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
|
25
|
+
xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"
|
26
|
+
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
|
27
|
+
xmlns:ext="http://www.xmllab.net/wordml2html/ext"
|
28
|
+
xmlns:java="http://xml.apache.org/xalan/java"
|
29
|
+
xmlns:str="http://exslt.org/strings"
|
30
|
+
xmlns:func="http://exslt.org/functions"
|
31
|
+
xmlns:fn="http://www.w3.org/2005/xpath-functions"
|
32
|
+
mc:Ignorable="w14 w15 wp14 a14"
|
33
|
+
version="1.0"
|
34
|
+
exclude-result-prefixes="java msxsl ext w o v WX aml w10"
|
35
|
+
extension-element-prefixes="func">
|
36
|
+
|
37
|
+
<xsl:include href="./image_functions.xslt"/>
|
38
|
+
|
39
|
+
<xsl:template match="img|body/img" name="image">
|
40
|
+
<xsl:choose>
|
41
|
+
<xsl:when test="not(@data-width) and not(@data-height) and not(contains(@style, 'width')) and not(contains(@style, 'height'))">
|
42
|
+
<!-- Do not transfor images unless width and height are correctly specified -->
|
43
|
+
</xsl:when>
|
44
|
+
<xsl:otherwise>
|
45
|
+
<w:drawing>
|
46
|
+
<wp:inline distT="0" distB="0" distL="0" distR="0">
|
47
|
+
<wp:extent>
|
48
|
+
<xsl:call-template name="image-dimention-attributes"/>
|
49
|
+
</wp:extent>
|
50
|
+
<wp:effectExtent l="0" t="0" r="0" b="0"/>
|
51
|
+
<wp:docPr>
|
52
|
+
<xsl:attribute name="id"><xsl:value-of select="count(preceding::img)+1" /></xsl:attribute>
|
53
|
+
<xsl:attribute name="name">Picture <xsl:value-of select="count(preceding::img)+1" /></xsl:attribute>
|
54
|
+
</wp:docPr>
|
55
|
+
<wp:cNvGraphicFramePr>
|
56
|
+
<a:graphicFrameLocks noChangeAspect="1"/>
|
57
|
+
</wp:cNvGraphicFramePr>
|
58
|
+
<a:graphic>
|
59
|
+
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
|
60
|
+
<pic:pic>
|
61
|
+
<pic:nvPicPr>
|
62
|
+
<pic:cNvPr>
|
63
|
+
<xsl:attribute name="id"><xsl:value-of select="count(preceding::img)+1" /></xsl:attribute>
|
64
|
+
<xsl:attribute name="title"><xsl:value-of select="@alt" /></xsl:attribute>
|
65
|
+
<xsl:attribute name="name"><xsl:call-template name="image-name">
|
66
|
+
<xsl:with-param name="source" select="@src"/>
|
67
|
+
<xsl:with-param name="data-filename" select="@data-filename"/>
|
68
|
+
</xsl:call-template></xsl:attribute>
|
69
|
+
</pic:cNvPr>
|
70
|
+
<pic:cNvPicPr/>
|
71
|
+
</pic:nvPicPr>
|
72
|
+
<pic:blipFill>
|
73
|
+
<a:blip>
|
74
|
+
<xsl:attribute name="r:embed"><xsl:call-template name="relationship-id"/></xsl:attribute>
|
75
|
+
<a:extLst>
|
76
|
+
<a:ext uri="{{28A0092B-C50C-407E-A947-70E740481C1C}}">
|
77
|
+
<a14:useLocalDpi val="0"/>
|
78
|
+
</a:ext>
|
79
|
+
</a:extLst>
|
80
|
+
</a:blip>
|
81
|
+
<a:stretch>
|
82
|
+
<a:fillRect/>
|
83
|
+
</a:stretch>
|
84
|
+
</pic:blipFill>
|
85
|
+
<pic:spPr>
|
86
|
+
<a:xfrm>
|
87
|
+
<a:off x="0" y="0"/>
|
88
|
+
<a:ext>
|
89
|
+
<xsl:call-template name="image-dimention-attributes"/>
|
90
|
+
</a:ext>
|
91
|
+
</a:xfrm>
|
92
|
+
<a:prstGeom prst="rect">
|
93
|
+
<a:avLst/>
|
94
|
+
</a:prstGeom>
|
95
|
+
</pic:spPr>
|
96
|
+
</pic:pic>
|
97
|
+
</a:graphicData>
|
98
|
+
</a:graphic>
|
99
|
+
</wp:inline>
|
100
|
+
</w:drawing>
|
101
|
+
</xsl:otherwise>
|
102
|
+
</xsl:choose>
|
103
|
+
</xsl:template>
|
104
|
+
|
105
|
+
<!--
|
106
|
+
A style specifiying the width and height is required to render an image correctly in word.
|
107
|
+
Styles can be provided either via data attributes:
|
108
|
+
img src="pathtosomeimage" data-width="200px" data-height="250px"
|
109
|
+
|
110
|
+
or via the html style attribute
|
111
|
+
img src="pathtosomeimage" style="width:150px;height:200px"
|
112
|
+
|
113
|
+
If both a style and data attributes are provided then data attributes take president.
|
114
|
+
e.g.
|
115
|
+
img src="pathtosomeimage" data-width="200em" style="width:150px;height:200px"
|
116
|
+
becomes: width:200em;height:200px
|
117
|
+
|
118
|
+
Note: All sizes must be in pixles or em
|
119
|
+
-->
|
120
|
+
<xsl:template name="image-dimention-attributes">
|
121
|
+
<xsl:attribute name="cx">
|
122
|
+
<xsl:call-template name="image-dimention">
|
123
|
+
<xsl:with-param name="style" select="@style" />
|
124
|
+
<xsl:with-param name="data-value" select="@data-width" />
|
125
|
+
<xsl:with-param name="type" select="'width'" />
|
126
|
+
</xsl:call-template>
|
127
|
+
</xsl:attribute>
|
128
|
+
<xsl:attribute name="cy">
|
129
|
+
<xsl:call-template name="image-dimention">
|
130
|
+
<xsl:with-param name="style" select="@style" />
|
131
|
+
<xsl:with-param name="data-value" select="@data-height" />
|
132
|
+
<xsl:with-param name="type" select="'height'" />
|
133
|
+
</xsl:call-template>
|
134
|
+
</xsl:attribute>
|
135
|
+
</xsl:template>
|
136
|
+
</xsl:stylesheet>
|