We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Comparing DOCXs is not stable w/r/t numbering.xml

I’m comparing the two attached documents (left and right) using the following snippet with version 21.10 (Java):

private static void compare(String leftPath, String rightPath, String outputPath) throws Exception {
  InputStream leftStream = new FileInputStream(new File(leftPath));
  InputStream rightStream = new FileInputStream(new File(rightPath));

  Document left = new Document(leftStream);
  Document right = new Document(rightStream);

  left.compare(right, "author", new Date(2000, 1, 1, 0, 0, 0));

  OutputStream output = new FileOutputStream(new File(outputPath));

  left.save(output, new OoxmlSaveOptions());
}

The comparison is not stable, in that running it multiple times can produce slightly different results. In particular, I have observed that numbering.xml is not always compared the same way. The issue does not always reproduce immediately; for instance, it took 3 attempts to produce the two diffs that I have attached here.

It’s important to note that the output comparison documents are semantically equivalent in these cases. That is, compare seems to reorder w:abstractNum nodes (and gives them different w:abstractNumId attributes) but then also changes the the way it assigns w:num nodes to w:abstractNumId so that the end result describes the same thing, even though the structure is different.

However, I depend on this code to produce the same inputs for the same outputs, and this unstable comparison is producing false positives.

left.docx (12.7 KB)
right.docx (12.3 KB)
diff-attempt-1.docx (11.0 KB)
diff-attempt-2.docx (11.0 KB)

@icsk Thank you for reporting this problem to us. I have logged it as WORDSNET-23251. We will keep you informed and let you know once it is resolved or we have some news about it.