xml:space="保留"在 Word 2003 XML 文档中

发布于 2024-09-16 17:30:12 字数 598 浏览 2 评论 0 原文

我正在使用 XSLT 模板生成 XML 格式的 Word 文档。

我遇到的问题是空格(特别是制表符)。

这是 xml 文档中段落内选项卡的示例:

<w:p>
<w:r xml:space="preserve">
<w:tab />
<w:t>This is some text after tab</w:t>
</w:r>
</w:p>

我添加了 xml:space="preserve" 来保存选项卡生成的空白,这在 Word2007 中有效(它可以正确打开),但是Word2003 中没有。 对于Word2003,我必须将xml:space="preserve" 标记放入w:wordDocument 的根元素内。这是一个问题,因为我们生成的 xml 中确实有很多空格,并且默认情况下需要忽略它们。

我知道微软的应用程序往往会忽略标准的滥用,而只是假设用户想要什么而不显示错误。我认为这可能是这里的错误,因为 word2003 和 2007 对相同格式有不同的解释。如果是这种情况 - 如何正确设置?

I'm using XSLT templates to generate word documents in XML format.

The problem I'm having is with whitespaces (specifically - tabs).

This is an example of a tab inside a paragraph in xml doc:

<w:p>
<w:r xml:space="preserve">
<w:tab />
<w:t>This is some text after tab</w:t>
</w:r>
</w:p>

I added xml:space="preserve" to save the whitespace generated by tab, and this works in Word2007 (it opens up correctly) but it doesn't in Word2003.
For Word2003 I have to put xml:space="preserve" tag inside the root element of w:wordDocument. This is a problem, since we do have a lot of spaces in our generated xml's and the default of ignoring them is a requirement.

I know that Microsofts apps tend to ignore standards misuse and just assume what the user wanted without showing error. I thought that might be the error here since the word2003 and 2007 have different interpretation of the same format. If that's the case - how to correctly set this?

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

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

发布评论

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

评论(1

鸠魁 2024-09-23 17:30:12

Word 2007 在需要时将 xml:space="preserve" 放在 w:t 元素上。

Word 2007 puts xml:space="preserve" on the w:t element when required.

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