【发布时间】:2012-07-10 18:17:09
【问题描述】:
我有两个文件:
文档 2 是通过转换过程传递文档 1 的结果,该过程使任何内容和格式保持不变(通过 Word 中的并排比较验证)。
但是,该过程会从 .docx 文件中删除许多 ID 号。
例如,
变成
根据每个文档的转储通过以下代码:
正文 = ((Document)newerPackage.getMainDocumentPart().getJaxbElement()).getBody(); 节点 node = org.docx4j.XmlUtils.marshaltoW3CDomDocument(body).getDocumentElement(); TransformerFactory tf = TransformerFactory.newInstance(); 变压器变压器 = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.INDENT, "是"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); transformer.transform(新 DOMSource(节点), 新的 StreamResult(新的 OutputStreamWriter(System.out, "UTF-8")));使用docx4j Differencer comparison method recommended here,所有内容(除了没有应用格式的第一行)都显示为修改。
问题是:差异是由于缺少 id、格式还是其他原因造成的?
如果它很重要,我们在这种情况下使用 docx4j 对我们的往返过程执行自动健全性/回归测试(即应用“无损失”过程并期望没有差异)
【问题讨论】:
-
Google Docs 不会显示 Document 1。
-
您是否从 Google 文档收到此消息? “很抱歉,我们目前无法生成文档视图,请稍后再试。您也可以点击此处尝试下载原始文档。”如果是这样,您可以使用链接的“此处”文本来获取 docx。我仔细检查了共享,似乎没问题。
标签: docx4j