You can use the Compare and Merge Tool for XML to compare the XML files generated from project models based on node identification, and then merge them. You can decide which differences to include in the resultant, merged file.
You can use the tool in two specific scenarios: you can review changes that you made to a file over a course of time, and you can merge the changes if you want to, or you can use the tool to review and consolidate changes made to a single XML file by different users, who essentially work on the project in a team development environment.
Note: To eliminate any inconsistencies that might exist in the resulting model, you can use another tool called the Model Consistency Checker.
Comparing XML Files
The Compare and Merge Tool for XML asks you to specify a base XML file, and a
modified file to compare it with.
The tool determines the identity of a node by examining certain attributes in the following sequence:
If it is not successful after this pass, it repeats the procedure with a child node. The comparisons works best when all the elements have attributes of type ID, or an "id" or "name" attribute.
The tool uses symbols and color to highlight the differences between the base and modified XML files in a tree display of the combination (XML format) in the left-hand, Merged View pane. The tool works at the XML element level, which is higher than the file level.
Panes of the Compare and Merge Tool for XML
The tool has the following panes:
The Merged View pane
This pane shows all the XML elements from the two files using a DTD grammar structure. The
preliminary "merged", hierarchical view of the two XML files draws your
attention to disparate nodes.
There are four kinds of nodes:
Base File pane
This is a read-only pane that shows the code for the base file: the XML content
of the node (file, module, interface, or implementation), which you select in the Merged
View pane.
Modified File pane
This is a read-only pane that shows the code for the modified file: the XML content of the
node (file, module, interface, or implementation), which you select in the Merged View
pane.
When you select a new node in the Merged View pane, the Base File pane will be blank. When you select a deleted node in the Merged View pane, the Modified File pane will not have any content. When you select a changed node in the Merged View pane, you will be able to see the differences in the content in the two right-hand panes.
Merging XML Files
You can walk through the changed nodes and decide whether the change should be
incorporated in the merged file from either the base file, or the modified file.
Every modified node in the tree (the deleted, changed, and new nodes) has an associated pop-up menu with the following choices:
These choices are also available from the Selected menu.
For the unresolved nodes in the tree that are below the current, parent node, the same menu choice is applied as selected from the pop-up menu on the parent node, or the parent of the parent, and so on. That is, the changes are automatically propagated up and down the tree, so that you do not have to perform the action on an individual node basis if a global decision can be made. For example, if you select a new node to be part of the merged file (Use modified file for node and unresolved children), then all its children will also be in the merged file; in addition, if this was the only node with a conflict under its parent, then the parent would be marked as resolved (its red cross-bar will disappear). Similarly, if you use the modified file as the source for change propagation for a deleted node, the node and all its children will not be present in the merged file.
Whenever the changes of all the child nodes are resolved, the parent node and all its child nodes will have a checkmark in front of them.
Editing Your Work
Saving Your Work
When you quit the tool (File - Exit), or save your work (File -
Save), merged changes are written to the resultant XML file that you
specify. Modified nodes for which you do not indicate the action to be taken (those
marked with an X) are resolved as in the base file.
Compare Files with the Compare and Merge Tool for XML
Merge Files with the Compare and Merge Tool for XML