[Journal - Hacking Like Mad]

Hacking Like Mad

Saturday, February 21, 2004

What happens if you don't have a working XML implementation on an esoteric system, like OS/390, that your application is supposed to run on? Case in point, at work I devised an XML-based document templating solution. There are roughly two dozen of such templates in use; the bulk of the data displayed by the application depends on those. And the XML lib won't parse them, because, well, it's never been intended for EBCDIC.

So this is the perfect situation. I mean, it's what I'm living for. Jump through hoops, use a handful of different technologies, hack arround impossible stuff. The templates are stored in a database (normally read in with embedded SQL, then parsed by the XML lib). So I connect to it via OLE DB. But since somehow DB2 VARCHAR fields, OLE DB, and ADO.NET are somehow too much of a mix for me get working, I switch over to Access, use ODBC, and VBA to export the stuff to files. The files I parse in with System.Xml and C#. A little code generator creates C code that builds the DOM (it's really just about 100 lines, the generator that is, the code is more that 100 time that much; you could say the generator is quite efficient). Since the templates won't be maintained by the customer, a fixed template structure is just fine. Of course, there are more character-set-related problems than just the parsing, so I churn out structs and methods for a simple, but sufficient XML DOM. With typdefs, #defines and #ifdefs, the whole thing is even compatible with the application. It's also a bit faster than the original solution.

Lest you think I'm a coding-obsessed complicado, although both my site and my projects certainly hold some evidence for that view, let me pitifully defend this hackery by stating that it's not my fault. It's cynical to state it that way, but we have some division of labor at my company. Which is not a bad thing. But I'm usually not one to fight turf wars in reverse, and I often debug other people's code. I think that makes sense from a work efficiency angle (I might explain that later). But in this case, code in the XML lib needs to be changed, and I don't have the "rights" to do that. I'm also busy with other stuff. The team responsible for the parser are also rather loaded, with work that is: on a constant refactoring spree, they do now, weeks before shipment, change schemas, rename attributes, start a jihad over upper/lower case issues, reinvent whatever. What goes arround, comes arround.