Word .docx XML标签的词汇表存在吗?

14

我正在尝试创建一个解析器来查找Word .docx文件中跟踪更改和作者的信息...

我找到了document.xml,但是有太多的标签!是否有某个词汇表可以解释这些标签的含义?

如果可能的话,我想避免使用暴力破解的方法。

4个回答

4
你可以从Stack Overflow docx标签百科开始收集相关信息。 .docx文件(以及其他新的MS Office文件,如.xlsx使用OOXML格式
特别是:
Microsoft Office Open XML WordProcessingML 在 ECMA 376 和 ISO 29500 中大多数已经标准化。
您可以在此处获取相关的 ECMA 标准规范:http://www.ecma-international.org/news/TC45_current_work/TC45_available_docs.htm 您可能正在寻找的具体文档可能是 Open Office XML,第4部分:标记语言参考 但是当然...这太庞大了(5219页!)
我强烈建议确定您想要的功能,并查看现有的开源库,这些库已经完成了您想要执行的某些任务。

2
"w:ins" denotes what was inserted when trackedchanges are enabled.
"w:del" denotes what was deleted when  trackedchanges are enabled.
"w:commentRangeStart" denotes the start of a comment
"w:commentRangeEnd" denotes the end of the comment.

All text are found inside 
"w:t" tags.

1

1
"Office Open XML"格式及其XML词汇详细描述在http://www.ecma-international.org/publications/standards/Ecma-376.htm中。为了让您有一个想法,下面的XSLT片段应该提取一个WordprocessingML文档的有效结果文本,不包括已跟踪的删除,例如存储在.docx文件(ZIP存档)中的word/document.xml中。
<!-- Match and output text spans except when
     appearing in w:delText child content -->
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
  <xsl:output method="text"/>
  <xsl:template match="w:t">
    <xsl:value-of select="."/>
  </xsl:template>
  <xsl:template match="w:delText"/>
  <xsl:template match="*">
    <xsl:apply-templates/>
  </xsl:template>
</xsl:stylesheet>

如果您的应用程序需要提取更改,则还需要处理w:ins元素。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接