是否有 Word .docx XML 标签的词汇表?

Is there a glossary of Word .docx XML tags?

我正在尝试创建一个解析器来查找 Word .docx 文件的修订和作者...

我找到了 document.xml 但是标签太多了!是否有所有这些标签代表什么的词汇表?

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

您可以开始在 Stack Overflow docx tag wiki itself 中收集有关它的信息。

.docx 个文件(以及 .xlsx 等其他新的 MS Office 文件)use OOXML format


特别是:

Microsoft Office Open XML WordProcessingML is mostly standardized in ECMA 376 and ISO 29500.

您可以在此处获取相关的 ECMA 标准规范:http://www.ecma-international.org/news/TC45_current_work/TC45_available_docs.htm

您可能要查找的特定文档可能是 Open Office XML, Part 4 : Markup Language Reference

但是当然...这是巨大的(5219 页!)

我强烈建议确定您想要的功能,并查看现有的开源库,这些库已经完成了您想要完成的一些工作。

"Office Open XML" 格式及其 XML 词汇表在 http://www.ecma-international.org/publications/standards/Ecma-376.htm 中有详细描述。

为了给您一个想法,下面的 XSLT 片段应该 只提取有效的结果文本而没有跟踪删除 wordprocessingML 文档, like 将存储在 word/document.xml 下的 .docx 文件(ZIP 存档)中。

<!-- 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 个元素。

您可以使用我的 docx4j webapp,特别是 http://webapp.docx4java.org/OnlineDemo/PartsList.html

有了它你可以点击一个标签,它会带你到规范中的相应定义。

"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.