Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8313711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:34:56+00:00 2026-06-08T20:34:56+00:00

I have two documents: Document 1 (input) Document 2 (output) Document 2 is the

  • 0

I have two documents:

  1. Document 1 (input)
  2. Document 2 (output)

Document 2 is the result of passing Document 1 through a transformation process which leaves any content and formatting intact (verified by side-by-side compare in Word).

However, the process removes many id numbers from the .docx files.

For example,

      <w:p w:rsidP="00B600D6" w:rsidR="00F55D78" w:rsidRDefault="00B600D6">

becomes

      <w:p>

according to a dump of each document via the following code:

Body body = ((Document)newerPackage.getMainDocumentPart().getJaxbElement()).getBody();
Node node = org.docx4j.XmlUtils.marshaltoW3CDomDocument(body).getDocumentElement();
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
transformer.transform(new DOMSource(node), 
             new StreamResult(new OutputStreamWriter(System.out, "UTF-8")));

Using the docx4j Differencer comparison method recommended here, everything (except the first line which has no formatting applied) is shown as a modification.

Question is: Are the diffs a result of the missing id’s, the formatting or something else?

In case it’s important, we’re using docx4j in this context to perform automated sanity/regression tests on our round-tripping proceess (i.e. apply the “loss-less” process and expect no differences)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:34:58+00:00Added an answer on June 8, 2026 at 8:34 pm

    Disclosure: I work on docx4j

    If the only difference between paragraphs is the rsid attributes, they will still be detected as different.

    You could “clean” the documents before performing the comparison, so that neither docx has rsid attributes. See the Filter sample.

    By the way, an easier way to see the XML for an object (eg a single paragraph, or the entire body) is to use XmlUtils.marshaltoString

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mongo collection which has documents with two fields fieldA and fieldB,
I have two input fields, Id and Desc. I need a javascript which enters
I have two documents - main.html (parent document) and enterKey.html (child document) . Within
Suppose I have two documents that are identical except the lines are shuffled. Is
I have two tables document (id, file) similarity(id1,id2,similarityvalue) where id1 and id2 are foreign
I have an HTML document where I have two different tables. One is class
i have two opposing requirements related to an xml document and its related xsd.
I have a loop that calculates the similarity between two documents. It collects all
this is my situation: I have two org.w3c.dom.Document created from two xml files. What
I have two XmlDocuments that both have a namespace attribute specified. Both documents have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.