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

Free Support Forum - aspose.com

Revision.accept on a FORMAT_CHANGE-type revision also accepts the containing deletion

I have a document (attached) including the following XML (simplified here for clarity):

<w:del w:id="1">
  <w:r>
    <w:rPr>
      <w:sz w:val="40"/>
      <w:szCs w:val="40"/>
      <w:rPrChange w:id="1">
        <w:rPr/>
      </w:rPrChange>
    </w:rPr>
    <w:delText>This is another sentence.</w:delText>
  </w:r>
  <w:r>
    <w:delText xml:space="preserve"> </w:delText>
  </w:r>
</w:del>

I want to accept the rPrChange but not any other changes. That is, I would like to end up with

<w:del w:id="1">
  <w:r>
    <w:rPr/> <!-- or this rPr can be removed entirely, it doesn't matter -->
    <w:delText>This is another sentence.</w:delText>
  </w:r>
  <w:r>
    <w:delText xml:space="preserve"> </w:delText>
  </w:r>
</w:del>

I attempted to do this with the following snippet:

for (Revision revision : document.getRevisions()) {
  if (revision.getRevisionType() == RevisionType.FORMAT_CHANGE) {
    formatRevisions.add(revision);
  }
}

for (Revision revision : formatRevisions) {
  revision.accept();
}

This does not work. Instead, it also accepts the entire next delText, resulting in:

<w:del w:id="0">
  <w:r>
    <w:delText xml:space="preserve"> </w:delText>
  </w:r>
</w:del>

This is unexpected, especially since Aspose reports that this document has 3 revisions, only one of which is a FORMAT_CHANGE, yet accepting that one revision brings the total to 1. Java, version 21.12.

convert.docx (12.1 KB)

(Filed internally as #4626.)

@icsk The issue is resolved in the latest 22.1 version of Aspose.Words for java. It was addressed by another issue reported by you filled as WORDSNET-22956.

Got it, thank you! I’ll be sure to file any further issues with the latest version (I had not yet had a chance to update).