|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||

Cart








