forked from pear/Mail_mimeDecode
-
Notifications
You must be signed in to change notification settings - Fork 7
/
xmail.xsl
executable file
·70 lines (55 loc) · 2.08 KB
/
xmail.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
<xsl:preserve-space elements="headervalue paramvalue body"/>
<xsl:template name="mimepart">
<xsl:variable name="boundary">
<xsl:for-each select="./header">
<xsl:if test="string(./headername) = 'Content-Type'">
<xsl:for-each select="./parameter">
<xsl:if test="string(./paramname) = 'boundary'">
<xsl:value-of select="paramvalue"/>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="header">
<xsl:value-of select="headername"/>
<xsl:text>: </xsl:text>
<xsl:value-of select="headervalue"/>
<xsl:if test="count(./parameter) = 0">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:for-each select="parameter">
<xsl:text>; 	</xsl:text>
<xsl:value-of select="paramname"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="paramvalue"/>
<xsl:text>"</xsl:text>
</xsl:for-each>
<xsl:if test="count(./parameter) > 0">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text> </xsl:text>
<!-- Which to do, print a body or process subparts? -->
<xsl:choose>
<xsl:when test="count(./mimepart) = 0">
<xsl:value-of select="body"/>
<xsl:text> </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="mimepart">
<xsl:text>--</xsl:text><xsl:value-of select="$boundary"/><xsl:text> </xsl:text>
<xsl:call-template name="mimepart"/>
</xsl:for-each>
<xsl:text>--</xsl:text><xsl:value-of select="$boundary"/><xsl:text>-- </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- This is where the stylesheet really starts, matching the top level email element -->
<xsl:template match="email">
<xsl:call-template name="mimepart"/>
</xsl:template>
</xsl:stylesheet>