Re: [xsl] String hashing code

Subject: Re: [xsl] String hashing code
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Sat, 15 Dec 2007 15:38:14 +0100
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>
</xsl:template>


(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