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

Free Support Forum - aspose.com

Aspose generated wordml comparision shows Style/Font changes that are not made by the user

Hi,

Using Aspose, I converted the DOCX(Sample_docx.docx) to
wordml(converted_wordml.xml), then converted wordml(converted_wordml.xml) to DOCX(converted_docx.docx) and again resulted DOCX(converted_docx.docx) to XML(converted_wordml_1.xml) to ensure both word ml(converted_wordml.xml and converted_wordml_1.xml) contents are same

I used the below code and attached the document
String filename = “C:\Users\\Desktop\Sample\Sample_docx.docx”;
Document doc1 = new Document(filename);
doc1.save(“C:\Users\\Desktop\Sample\converted_wordml.xml”, SaveFormat.WORD_ML);
String filename1 = “C:\Users\\Desktop\Sample\converted_wordml.xml”;
Document doc2 = new Document(filename1);
doc2.save(“C:\Users\\Desktop\Sample\converted_docx.docx”, SaveFormat.DOCX);
String filename2 = “C:\Users\\Desktop\Sample\converted_docx.docx”;
Document doc3 = new Document(filename2);
doc3.save(“C:\Users\\Desktop\Sample\converted_wordml_1.xml”, SaveFormat.WORD_ML);


Both the xml contents are same.
In previously explained sample code, when I make some text change(not any style/font changes) to converted_docx.docx and then generated the wordml converted_wordml_1.xml.

Now when comparing converted_wordml_1.xml with converted_wordml.xml, I expect only the changes I made to be shown in the comparison, but the compared result shows the changes I made along with style change.
i.e It showed me extra style attribute and font changes.
Attached documents for reference.

Please let us know, if the comparison can show only the text changes which I made and not any style/font change that I didn’t make

Thanks,
Muthulakshmi M



Hi Muthulakshmi,


Thanks for your inquiry.
Muthulakshmi:
In previously explained sample code, when I make some text change(not any style/font changes) to converted_docx.docx and then generated the wordml converted_wordml_1.xml.
Are you inserting text using Aspose.Words? If yes then please share piece of source code for testing.

Muthulakshmi:
Now when comparing converted_wordml_1.xml with converted_wordml.xml, I expect only the changes I made to be shown in the comparison, but the compared result shows the changes I made along with style change.
i.e It showed me extra style attribute and font changes.
I have compared converted_wordml.xml and converted_wordml_1.xml using MS Word 2016 and attached a comparison document here for your reference. The only revision I can see in this document is Insertion revision. Please explain how are you comparing these xml files?

PS: Please make sure that you’re using latest version of Aspose.Words for Java i.e. 15.12.0.

Best regards,
Hi,
Please find the inline comments

Are you inserting text using Aspose.Words? If yes then please share piece of source code for testing.
We are inserting the text change using MS Word 2007, not using Aspose Word.

I have compared converted_wordml.xml and converted_wordml_1.xml using MS Word 2016 and attached a comparison document here for your reference. The only revision I can see in this document is Insertion revision. Please explain how are you comparing these xml files?
– We are comparing the xml tags of converted_wordml.xml and converted_wordml_1.xml tag by tag.
We are using Aspose.Words for Java 15.4.0.
Is there any way in Aspose where we can compare two xml files and show the changes made by the user (i.e, text Change, style change, font change, list change, type change)?



Thanks,
Muthulakshmi.M

Hi Muthulakshmi,


Thanks for your inquiry. I am afraid Aspose.Words can’t compare raw xml tags. However, you can compare two WordML documents similar to MS Word’s compare functionality as follows:
Document srcDoc = new Document(getMyDir() + “converted_wordml.xml”);
Document dstDoc = new Document(getMyDir() + “converted_wordml_1.xml”);

srcDoc.compare(dstDoc, “Awais”, new Date());
for (Revision rev : srcDoc.getRevisions()) {
System.out.println(rev.getParentNode().toString(SaveFormat.TEXT));
}
Best regards,

Hi,

wordml comparision using Aspose is giving results correctly. but in our case we need to intimate the user the changes that are made in each and every section one by one.

Example:
Section 1: Section 1 Text - Text change
Section 2: Section 2 Text - Format change
Section 3: Section 3 Text - Style change
Section 4: Section 4 Text - Text delete

when comparison is done I need to intimate the user the section name with the revision type(Insertion, Deletion, Font change etc…)

Is it possible to retrieve the xml information for the revisions made.?
Is it possible to retrieve the bookmarks if it exists for the changes made?


Thanks,
Muthulakshmi

Hi Muthulakshmi,


Thanks for your inquiry. The Document.Compare method compares this document with another document producing changes as number of edit and format Revisions and you can get RevisionType, ParentNode and ParentStyle information from Revision object. It is not possible to get the raw XML however if you get ParentNode then you’ll be able to navigate through the Document’s DOM:
Document Tree Navigation

Best regards,