MagicTree Documentation: Merging Data

Importing XML Data | Table of Contents | Re-Arranging Tree Nodes >

MagicTree allows to easily combine data coming from different sources in a meaningful way. This is done by the merge function. Merge takes two trees and builds a new tree so that all the data in both trees is retained, but not duplicated.

Consider the following two trees:

<A>A
<B>B
<C>C</C>
</B>
</A>

<A>A
<B>B
<C>D</C>
</B>
</A>

If we want to combine them preserving the structure and the data, we should get a tree like this:

<A>A
<B>B
<C>C</C>
<D>D</C>
</B>
</A>

The nodes A and B that are present in both trees remain the same in the resulting tree, and the nodes C and D are both preserved, but remain separate.

MagicTree merge algorithm works like this:

  1. Compare the root nodes in two trees

  2. If the two root nodes are not equal, stop the merge process and complain.

  3. If the nodes are equal, merge them together. Most of the time merging two equal nodes won't do anything to the node data. In some special cases, such as Cross-Reference nodes or Task nodes, special processing is done at this step. For mode details on how merging is handled by different kinds of nodes, see Node Types

  4. Go through all the child nodes of the current node in the second tree. For each child node, check if the currently node in the first tree has an equal child node. If so, merge the two child nodes, starting from step 3 above. If the current node in the first tree does not have an equal child node, add the current child node (and its whole subtree) from the second tree as a child node to the current node in the first tree.

  5. When all child nodes are merged, stop.

Merge process also handles cross-references in both trees gracefully. The resulting tree should haave all cross-references intact, pointing to the right nodes.

Merging can be used for sharing and combining data produced by several members of the team. For example, one penetration tester can start a project, start several tasks, and then give a copy of MagicTree project file to a collegue. The second tester can start working on the same project executing tasks, and importing data in the tree. In the end of the project (or at any other time) the two files can be merged without losing any data or compromising its integrity. See also Node Types for information on how tasks and data generated by them is merged.

Importing XML Data | Table of Contents | Re-Arranging Tree Nodes >