XSLT解析XML生成Word文档

发布于 2024-09-16 06:42:45 字数 502 浏览 2 评论 0原文

我有一个 XLST 文件,该文件应该解析 XML 文件并生成 Word 文档。但是当我在 Visual Studio 中解析它时,它会生成另一个 XML,因为它的标头是:

<xsl:output method="xml" omit-xml-declaration="no" version="1.0" encoding="utf-8" standalone="yes" />
<xsl:template match="/">
    <xsl:processing-instruction name="mso-application">
        <xsl:text>progid="Word.Document"</xsl:text>
    </xsl:processing-instruction>

我尝试了 method=“text”,但它生成了一个没有格式的纯文本。 我应该指定什么属性,以便在运行转换时将结果保存在 Word 文档中?

I have an XLST file that is supposed to parse an XML file and generate Word document. But when I parse it in Visual Studio it produces another XML because its header is:

<xsl:output method="xml" omit-xml-declaration="no" version="1.0" encoding="utf-8" standalone="yes" />
<xsl:template match="/">
    <xsl:processing-instruction name="mso-application">
        <xsl:text>progid="Word.Document"</xsl:text>
    </xsl:processing-instruction>

I tried the method= "text" but it generates a plain text with no formatting.
what property should I specify so that when I run the transformation it saves the result in a Word document?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

穿越时光隧道 2024-09-23 06:42:45

另一种选择可能是简单地生成 HTML(并将输出方法指定为 HTML)并使用 .doc 扩展名保存文件。

MS Word 将打开该文件而不会发出任何抱怨(尽管它仍然知道这是一个网页)

Another option might be to simply generate HTML (and specify the output method as HTML) and save the file with a .doc extension.

MS Word will open the file without complaining (though it still knows that it's a web page)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文