Tags: xml

Simple file access concurrency in C#

When working without the safety net of a RDBMS in a multi-user environment, file concurrency may become an issue. In a project I’ve been working on recently, XML files are being used as the custom data store. This is all fine and dandy for now—with a user base of 1 (myself)—but when the app is released “into the wild”, concurrency may become a serious problem.

To remedy this problem (in a simple, no-nonsense fashion), I have been relying on a mutex file to exclude concurrent writes to the XML data store; it has been holding up just fine in my simulated scenarios. The mutex allows for one web request to read in the XML, modify it, and write back to it without being usurped by concurrent requests. There is a fail-safe mechanism which will wait for up to 3 seconds (30 attempts to lock the file) before failing outright. Read More →

Browser-independent XSLT with Javascript

To piggy-back on the Javascript function to load an XML document: what can be done to load an XSL stylesheet and apply it to the XML? For the most part, loading it is a snap… but, as is often the case, Internet Explorer is the exception to the rule. So, we write a function that tells every browser except for IE to use our previously-defined loadXML() function, and an exception for Internet Explorer to load the XSL as a “free-threaded document.” Read More →

Browser-independent XML load with Javascript

XML data is, in a word, awesome. It’s standardized, it’s well-formatted, and there are XML parsing methods in nearly every major programming language–including Javascript. However, when using Javascript, the nasty problem of “browser agnosticism” comes into play: a method that works in Firefox may not (read: won’t) work in Internet Explorer; and both methods may fail for WebKit (Safari, Chrome, etc.). Read More →