Edit online

Compare Files Tool

The built-in Compare Files tool can be used to compare files or XML file fragments. The tool provides a mechanism for comparing two files or fragments, as well as the mechanism for a three-way comparison. The utility is available from the Tools > Comparison Tools menu or can be opened as a stand-alone application from the Oxygen XML installation folder (diffFiles.exe). The utility is available as a stand-alone application and can be opened by running its executable file (diffFiles.exe) from the Syncro SVN Client installation folder. The functionality of this standalone tool is similar to the comparison feature in the Syncro SVN client with a few slight differences in the interface and some options.

Figure 1. Compare Files Tool

Two-Way Comparisons

The Compare Files tool can be used to compare the differences between two files or XML fragments.

Compare Files
To perform a two-way comparison, follow these steps:
  1. Open a file in the left panel and the file you want to compare it to in the right panel.

    Step Result: The selected files are opened in the two side-by-side editors. A text editing mode is used to offer a better view of the differences.

  2. To highlight the differences between the two files, click the Perform File Differencing button from the toolbar.
  3. You can use the drop-down menu on the left side of the toolbar to change the algorithm for the operation.
  4. You can also use the Diff Options button to access the Files Comparison preferences page where you can choose to ignore certain types of markup and configure various options.
  5. If you are comparing XML documents using the XML Fast or XML Accurate algorithms, you can enter an XPath 2.0 expression in the Ignore nodes by XPath text field to ignore certain nodes from the comparison.
The resulting comparison will show you differences between the two files. The line numbers on each side and colored marks on the right-side vertical stripe help you to quickly identify the locations of the differences. Adjacent changes are grouped into blocks of changes. This layout allows you to easily identify and focus on a group of related changes.
Figure 2. Two-Way Differences
Highlighting Colors
The differences are also highlighted in several colors, depending on the type of change, and dynamic lines connect the compared fragments in the middle section between the two panes. The highlighting colors can be customized in the Files Comparison / Appearance preferences page, but the default colors and their shades mean the following:
  • Pink - Identifies modifications on either side.
  • Gray - Identifies an addition of a node in the left side (your outgoing changes).
  • Blue - Identifies an addition of a node in the right side (incoming changes).
  • Lighter Shade - Identifies blocks of changes that can be merged in their entirety.
  • Darker Shade - Identifies specific changes within the blocks that can be merged more precisely.
Comparing Fragments (Copy/Paste)
To compare XML file fragments, you need to copy and paste the fragments you want to compare into each side, without selecting a file. If a file is already selected, you need to close it using the Close () button, before pasting the fragments. Other notes for pasting fragments:
  • As long as the fragment is more than 10 characters, the application will attempt to automatically detect the content type. It can detect the following types: XML, DTD, CSS, JSON, and Markdown (if it starts with #). If one of those content types is detected, the fragments will be displayed with syntax highlights.
  • If you save modified fragments, a dialog box opens that allows you to save the changes as a new document.
Two-Way Diff Algorithms
Oxygen XML offers the following two-way diff algorithms to compare files or fragments:
  • Syntax Aware - Computes differences for known file types or fragments. This algorithm splits the files or fragments into sequences of tokens and computes the differences between them. The meaning of a token depends on the type of compared files or fragments.

    Known file types include those listed in the New dialog box, such as XML file types (XSLT files, XSL-FO files, XSD files, RNG files, NVDL files, etc.), XQuery file types (.xquery, .xq, .xqy, .xqm extensions), DTD file types (.dtd, .ent, .mod extensions), TEXT file type (.txt extension), or PHP file type (.php extension).

    For example:
    • When comparing XML files or fragments, a token can be one of the following:
      • The name of an XML tag
      • The < character
      • The /> sequence of characters
      • The name of an attribute inside an XML tag
      • The = sign
      • The " character
      • An attribute value
      • The text string between the start tag and the end tag (a text node that is a child of the XML element corresponding to the XML tag that encloses the text string)
    • When comparing plain text, a token can be any continuous sequence of characters or any continuous sequence of whitespaces, including a new line character.

Three-Way Comparisons

Oxygen XML also includes a three-way comparison feature to help you solve conflicts and merge changes between multiple modifications. It is especially helpful for teams who have multiple authors editing and committing the same documents. It provides a comparison between a local change, another change, and the original base revision. Some additional advantages include:
  • Visualize and merge content that was modified by you and another member of your team.
  • Marks differences correctly even when the document structure is rearranged.
  • Allows you to merge XML-relevant modifications.
Figure 3. Three-Way Comparison
Compare Files
To perform a three-way comparison, follow these steps:
  1. Open a file in the left panel and the file you want to compare it to in the right panel.

    Step Result: The selected files are opened in the two side-by-side editors. A text editing mode is used to offer a better view of the differences.

  2. Click the Three-Way Comparison button on the toolbar and select the base (original) file in the Base field.
  3. To highlight the differences, click the Perform File Differencing button on the toolbar.
  4. You can use the drop-down menu on the left side of the toolbar to change the algorithm for the operation.
  5. You can also use the Diff Options button to access the Files Comparison preferences page where you can choose to ignore certain types of markup and configure various options.
The resulting comparison will show you differences between the two files, as well as differences between either of them and the base (original) file. The line numbers on each side and colored marks on the right-side vertical stripe help you to quickly identify the locations of the differences. Adjacent changes are grouped into blocks of changes.
Figure 4. Three-Way Differences
Three-Way Diff Algorithms
Oxygen XML offers the following three-way diff algorithms to compare files:

Second-Level Comparisons

For both two-way and three-way comparisons, Oxygen XML automatically performs a second-level comparison for the Lines, XML Fast, and XML Accurate algorithms. After the first comparison is finished, the second-level comparison for the Lines algorithm is processed on text nodes using a word level comparison, meaning that it looks for identical words. For the XML Fast and XML Accurate algorithms, the second-level comparison is processed using a syntax-aware comparison, meaning that it looks for identical tokens. This second-level comparison makes it easier to spot precise differences and you can merge or reject the precise modifications.

Figure 5. Second-Level Diff Comparison
Note:
If a modified text fragment contains XML markup (such as processing instructions, XML comments, CData, or elements), the second-level comparison will not automatically be performed. In this case you can manually select a second-level comparison by doing a word level or character level comparison.

To do a word level comparison, select Show word level details from the contextual menu or Compare menu.

Figure 6. Word Level Comparison

To do a character level comparison, select Show Character Level details from the contextual menu or Compare menu.

Figure 7. Character Level Comparison

Author Visual Mode

The Compare Files tool includes an Author comparison mode that displays the files in a visual mode similar to the Author editing mode in Oxygen XML Editor/Author. This makes it easier to see how the compared changes will look in the final output. This visual mode is available when the compared files are detected as being XML. To determine whether the files are initially opened in the merge tool's Text or Author comparison mode, it detects the Initial Edit Mode in the Document Type Association configuration and the mode the files were last opened in Oxygen XML Editor/Author.
Note:
This mode is not available if the Enable file comparison in Author mode option is not selected in the Diff > Files Comparison preferences page.

This visual mode includes unique features such as a Tags Display Mode drop-down button on the toolbar that allows you to select the amount of tags to display in this visual mode. This mode also presents differences that were made using the Track Changes feature (although the Track Changes feature is not available in the comparison tool).

Figure 8. File Comparison Tool - Author Mode

Author Mode Algorithms

The visual Author comparison mode offers the following diff algorithms to compare files:

Author Mode Second-Level Comparisons

The visual Author comparison mode automatically performs a second-level comparison for the XML Fast and XML Accurate algorithms. After the first comparison is finished, the second-level comparisons is processed on text nodes using a word-level comparison, meaning that it looks for identical words. This second-level comparison makes it easier to spot precise differences and you can merge or reject the precise modifications.