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

Re: hashing


re hashing
Eric Hanson wrote:

> I have a large collection of XML documents, and want to find and
> group any duplicates.  The obvious but slow way of doing this is
> to just compare them all to each other.  Is there a better
> approach?

You figured it out in the next paragraph.

> Particularly, is there any APIs or standards for "hashing" a
> document so that duplicates could be identified in a similar way
> to what you'd do with a hash table?

The quick-and-dirty approach would be to run all of them through an XML 
normalizer (such as any SAX parser hooked up to XML-Writer).  You could add 
some SAX filters in-between the parser and the writer to tweak the 
normalization for any business rules, such as ignoring certain attributes, 
supplying default values, case insensitivity, numerical precision, etc.  If 
you don't want to play with SAX, you can do something similar with an XSLT 
transformation.

Next, create a list of all the normalized copies, sorted by file size or 
hash, and run Unix cmp or the Windows equivalent on any files with the same 
byte size or hash code.

If this isn't a one-off, then it would not be too hard to write your own 
hash generator based on SAX events, again, applying local business rules as 
appropriate.


All the best,


David

  • References:
    • hashing
      • From: Eric Hanson <eric@a...>

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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.