首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >添加Mime边界

添加Mime边界
EN

Stack Overflow用户
提问于 2014-05-02 14:30:31
回答 2查看 453关注 0票数 0

我有一个XML文档,需要在Mime边界下面添加。有人能告诉我我们如何在XSL中做到这一点吗?请注意,Mime边界始终是静态的,XML中不会有任何附件。我们只需要XML周围的边界

代码语言:javascript
复制
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--

谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-05-02 14:39:37

尝试:

代码语言:javascript
复制
<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声明不匹配。

票数 0
EN

Stack Overflow用户

发布于 2014-05-02 14:46:32

这绝对不是你应该做的事,但是.

代码语言:javascript
复制
<?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&#xa;</xsl:text>
    <xsl:text>Content-Type: multipart/Related; type="text/xml"; boundary=_MIME-Boundary&#xa;</xsl:text>
    <xsl:text>--_MIME-Boundary&#xa;</xsl:text>
    <xsl:text>content-type: text/xml&#xa;</xsl:text>
    <xsl:text>Content-ID: BodyPart&#xa;</xsl:text>
    <xsl:text>Content-Transfer-Encoding: 7bit&#xa;</xsl:text>
    <xsl:text disable-output-escaping="yes">&lt;?xml version="1.0" encoding="utf-8"?&gt;&#xa;</xsl:text>
    <xsl:copy-of select="." />
    <xsl:text>&#xa;--_MIME-Boundary--&#xa;</xsl:text>
  </xsl:template>


</xsl:stylesheet>

注意,XML声明是使用disable-output-escaping手动添加的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23430588

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档