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

Re: Comparing 2 XML Documents

Subject: Re: Comparing 2 XML Documents
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 9 Nov 2005 12:45:44 GMT
comparing 2 xml with xpath
there are lost of ways of doing this, mainly because there are lots of
different answers.

<x>
 <a/>
 <b/>
 <c/>
</x>

<x>
 <z/>
 <a/>
 <b/>
 <c/>
</x>

Is that one difference, an extra z in the second case, or four
differences
a->z, b-> a, c-> b, c inserted.

textual difference programs have lots of heuristics to generate "small"
difference lists, but the problem is harder in XML where there is more
variablity to start with.

In Xpath2 it's probably easier and there is a built-in deep-equal()
function that can give true/false test whetjer two trees are equivalent
for some (slightly eccentric) notion of equivalence.

One approach is to traverse the first tree, generate an xpath to where
you are (using templates or an extension function) then use that xpath
on the other tree and test what you find.

Another approach is to have a named template that takes teh two trees as
parameters and traverses them in parallel, that's a bit tricker to code
but more efficient if you want to stop if you find any differences, as
you have more direct control over whether or not to recurse into a new
branch.



David


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.