Re: [xsl] String hashing code

Subject: Re: [xsl] String hashing code
From: Abel Braaksma <>
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="";>
<xsl:variable name="filename" select="doc('')/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