我有一个XML文档,需要在Mime边界下面添加。有人能告诉我我们如何在XSL中做到这一点吗?请注意,Mime边界始终是静态的,XML中不会有任何附件。我们只需要XML周围的边界
MIME-Version: 1.0
Content-Type: multipart/Related; type="text/xml"; boundary=_MIME-Boundary
--_MIME-Boundary
content-type: text/xml
Content-ID: BodyPart
Content-Transfer-Encoding: 7bit
<My XML Goes here>.....
--_MIME-Boundary--谢谢
发布于 2014-05-02 14:39:37
尝试:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:text>MIME-Version: 1.0
Content-Type: multipart/Related; type="text/xml"; boundary=_MIME-Boundary
--_MIME-Boundary
content-type: text/xml
Content-ID: BodyPart
Content-Transfer-Encoding: 7bit
</xsl:text>
<xsl:copy-of select="."/>
<xsl:text>
--_MIME-Boundary--</xsl:text>
</xsl:template>
</xsl:stylesheet>请注意,XSLT应用的编码可能与MIME声明不匹配。
发布于 2014-05-02 14:46:32
这绝对不是你应该做的事,但是.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:text>MIME-Version: 1.0
</xsl:text>
<xsl:text>Content-Type: multipart/Related; type="text/xml"; boundary=_MIME-Boundary
</xsl:text>
<xsl:text>--_MIME-Boundary
</xsl:text>
<xsl:text>content-type: text/xml
</xsl:text>
<xsl:text>Content-ID: BodyPart
</xsl:text>
<xsl:text>Content-Transfer-Encoding: 7bit
</xsl:text>
<xsl:text disable-output-escaping="yes"><?xml version="1.0" encoding="utf-8"?>
</xsl:text>
<xsl:copy-of select="." />
<xsl:text>
--_MIME-Boundary--
</xsl:text>
</xsl:template>
</xsl:stylesheet>注意,XML声明是使用disable-output-escaping手动添加的。
https://stackoverflow.com/questions/23430588
复制相似问题