我正在使用 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?
发布评论
评论(1)
Word 2007 在需要时将 xml:space="preserve" 放在 w:t 元素上。
Word 2007 puts xml:space="preserve" on the w:t element when required.