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

Re: String hashing code

Subject: Re: String hashing code
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Sat, 15 Dec 2007 01:48:51 +0100
Re:  String hashing code
Deborah Pickett wrote:
Since I can't be sure that only one XSLT processor instance will process
*all* my files, I can't rely on the uniqueness of generate-id($node)
where $node is a locally-scoped variable containing a document (` la
Abel's UUID thread, which was nonetheless fascinating).

If you looked carefully, you must've seen it also uses a timestamp. Together it should provide uniqueness, both within one run and between runs. Unless of course you have a system where all are runs run simultaneously in the same microsecond (which is not likely since starting a processor alone takes somewhere between 20 and 400 ms). But I can't judge your system, perhaps relying on clock and node is not enough to guarantee stability?


If the problem you are facing is the possibility of names of files already existing, you can combine two methods. One: try the most randomizing way of creating a filename, two: use unparsed-text-available(...) to check whether a previous run already created that file, or better, let it loop with a counter until it finds a free "slot" (use the high significant bit of the random number of the UID or simply add another counter yourself).

These two techniques combined will guarantee that 0.1% that wasn't guaranteed by this "UUID"-lookalike algorithm ;)

HTH,
Cheers,
-- Abel --

PS: of course, using a hash can be a close to perfect solution too. But remember that on small strings hashes have the tendency to overlap in some xxx% of the cases. So, even with hashes, it is probably best to also add a both a counter (extra-run) and a function to provide uniqueness (intra-run).

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.