Skip to content

Instantly share code, notes, and snippets.

@gioele
Last active August 29, 2015 14:20
Show Gist options
  • Save gioele/a27355041c6f46a5ea17 to your computer and use it in GitHub Desktop.
Save gioele/a27355041c6f46a5ea17 to your computer and use it in GitHub Desktop.
Diff for MOM

First approximation

Preparatory steps

  1. serialize the base document (version 0) in the variable String ver0_string;
  2. serialize the modified document (version 1) in the variable String ver1_string;
  3. create a ByteArrayOutputStream diff_result object.

The call

Call

InputStream ver0 = new ByteArrayInputStream(ver0_string.getBytes(StandardCharsets.UTF_8));
InputStream ver1 = new ByteArrayInputStream(ver1_string.getBytes(StandardCharsets.UTF_8));

fc.xml.diff.Diff.diff(InputStream ver0, InputStream ver1, OutputStream diff_result)

Now the differences (in textual form) are in diff_result.

Elaboration of the results

Get a string for the result calling

String diff_result_string = diff_result.toString(StandardCharsets.UTF_8)

Output diff_result_string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment