[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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. 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))
|
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
|