Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

compare xml dom documents

Thread view: 
asaf.lahav@gmail.com - 28 Dec 2005 12:37 GMT
Hi all,

I'm looking for an infrastructure that will enable  me to compare two
xml dom document instances.
Preferrably the infrastructure will generate a differences map between
the two documents maybe based  on a schema or xpaths.

I would appreciate any pointers...
Thanks in advance,
Stefan Schulz - 31 Dec 2005 04:44 GMT
On Wed, 28 Dec 2005 04:37:33 -0800, asaf.lahav wrote:

> Hi all,
>
[quoted text clipped - 5 lines]
> I would appreciate any pointers...
> Thanks in advance,

This problem is decidedly non-trivial. What do you want to do? Do your
documents necessarily have something in common? Do they allow only some
modifications to be applied (for example, only add / delete subtrees)?

I am not currently aware of a "out of the box" solution for the problem,
but the more specific you are, the more likely someone will be able to
point you in the right direction.

Consider:
<A>
 <B foo="bar"/>
 <C/>
</A>
------------------------------
<N>
 <B foo="bar"/>
 <D number="0"/>
</N>

What would the differences be?

* Delete root node, all children, and create new tree.
* Change root node from A to N, delete child C, create child D
* Change root node from A to N, change child C to D, add attribute "number"

Something else still?

Signature

You can't run away forever,
But there's nothing wrong with getting a good head start.
          --- Jim Steinman, "Rock and Roll Dreams Come Through"
         

EricF - 31 Dec 2005 06:48 GMT
>On Wed, 28 Dec 2005 04:37:33 -0800, asaf.lahav wrote:
>
[quoted text clipped - 34 lines]
>
>Something else still?

Google for XML Diff
mrandywarner@gmail.com - 31 Dec 2005 15:34 GMT
I did some research on this while back for a project I was working on
and came across a graduate student who was working on this as his
thesis.  The more general of a solution that you need, the harder the
problem becomes, (the grad student had a proof that the problem
allowing a subtree from one document to appear in the second document,
possibly altered, possibly multiple times, is NP Complete).  If you
have a particular schema that both docs are known to be valid against I
think you're most likely to get the best solution by doing this one
yourself where you can optimize when appropriate.  The xml I was
parsing was actually custom built to serialize a java object in a
database, so I ended up finding it easier to simply build to objects
and write code that would find the differences in the objects since
that is a more concrete problem space.  But that also depends on what
you're using it for.  If you're diff is going to be performed a lot on
a performance intensive environment, parsing and constructing the
objects might end up being slower.  Everything's a trade off.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.