[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Tree Comparing Algorithm

Subject: Tree Comparing Algorithm
From: "Vasu Chakkera vasucv@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 3 Feb 2020 13:46:44 -0000
 Tree Comparing Algorithm
Hi All,
I am planning to write a XML Tree comparing XSLT using streaming.
The XML Trees look something like this

<root path="" mhash =" ">

  <folder path ="" mhash ="">

    <folder path ="" mhash ="">

       <leaf path ="" mhash ="">

       </leaf>

    </folder>

  </folder>

</root>

There will be two such XML files to compare . These two XMLs are generated
before and after moving a folder from source to destination. Source and
destination could be two different OS.
This is essentially the serialized Merkle Tree output of a folder
structure. The idea is to run a Merkle Tree comparator that will pick the
nodes that did not match. Rules are as follows.

   1. If the root node in both the tree matches, then there is not
   difference in the entire tree(because of how the Merkle tree is generated)
   2. If root node hash does not match, we go to the child container and
   compare the hash of the child container in both the XML files. ( the XML
   folders structure will be identical with respect to the hash, but the
   folder  path may be different because of the linux, windows path
   conventions. Otherwise the folder structure is meant to be the same.)
   3. If the hash of a folder from both the trees are same, the entire tree
   under the folder that matches the hash is ignored.
   4. if the hash of a folder from both the trees are not the same, then
   the tree is further traversed and the step 3 is repeated.
   5. The XSLT keeps writing out the nodes that do not match the hashes in
   the source and target xml files


So at the end of the processing, A comparator tree should be serialized,
that has the nodes that have a non matching leaf node.
Looking at the serialized tree, we can determine, which files got messed up
while doing a transfer from Source to target.



I am able to do this using non streaming xslt, but with streaming, since we
need to stream two trees at a time and match compare the nodes,  i am not
very sure how to proceed.
I am able to do manipulations on one XML with streaming. I tried a few
tricks, but did not get anywhere ( I am not very comfortable copying my
code scribbling here)

I need streaming because the XML files may be big.
If someone has done something similar, or point me to an  intelligent way
to do this, I will be thankful.

Vasu

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.