[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 15:38:14 +0100
Re:  String hashing code
Deborah Pickett wrote:
True, though years of multithread programming has taught me a strong
aversion to the inherent race condition in non-atomic test-and-create
operations like this.  It can't possibly be as big a risk as hash
collision, but it doesn't stop me feeling any less dirty.

As always, perfection is impossible, so ultimately it comes down to how
much effort I am willing to go to for that extra nine of reliability.

From another angle, not sure whether your system allows this, but getting a unique filename, or a unique number or whatever, without the use of non-XSLT functions, becomes inherently easy if you can use some internet service. In other words: if you can allow for a dependency to some internet (intranet or even localhost) web site, you can use that for creating a guaranteed-unique name, possibly with the information of your original filename.

For instance, I found one internet service that returns a UUID. You can do about the same with any method of uniqueness you want:

<xsl:template match="/" xpath-default-namespace="http://www.w3.org/1999/xhtml">
<xsl:variable name="filename" select="doc('http://www.famkruithof.net/uuid/uuidgen')/html/body/table/tr/td/h3[1]" />
<xsl:result-document href="{$filename}" >...</xsl:result-document>

(code tested)

Setting up a system to provide a UUID is as simple as using any Windows 2000 or higher machine, using the following the VBScript (and I am sure something equally easy can be done in a Unix-like environment) and put it somewhere in the path of IIS. And if you don't like the UUID syntax, you can send a parameter along with the filename and let it be MD5'ed, of course ;)

' VBScript to create a UUID:
Set TypeLib = CreateObject("Scriptlet.TypeLib")
NewGUID = TypeLib.Guid
WScript.Echo(left(NewGUID, len(NewGUID)-2))

Cheers, -- Abel Braaksma

Current Thread


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.
First Name
Last Name
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.