Thursday, June 15, 2006

XML Woes

Amongst the many roles I seem to undertake at my current employer (.NET Evangelist, NHibernate Evangelist, ATLAS Evangelist and so on), I also spend a large amount of my time dealing with XML technologies - whether it be transformation, serialization, querying or whatever.

Over time I've seen some truly awful implementations of so-called XML 'solutions'; one of my favourites involved the DVLA here in the UK. They proudly announced that they'd implemented an XML based system to enable the querying of Driving Licence details (whether the driver was banned, how many points on the licence and so on). So, given an XSD schema describing the object graph required for the query I coded up a simple .NET application to produce the correct XML fragment.

The DVLA instantly rejected it because:

  1. Every element needed to start on a new line
  2. There was an 'encoding' attribute in the XML declaration
  3. Even though the source XSD had specified a target namespace, namespace declarations were not understood

Aaaargh!

Even worse was the size of the response - every single line in the response document was padded to over 200 characters, and with one element on each line this produced a document that was 62,771,702 bytes long.

A simple

cat results.xml | tidy -xml -indent -o parsed.xml

produced a document that was a mere 8,604,602 bytes in length.

Now this is a bit of an extreme example, but I've seen several variations along this theme in active use and nearly all of them stem from one single problem - string concatenated XML, like this:

Console.WriteLine(@"<?xml version='1.0' encoding='utf8'?>");
Console.WriteLine("<root><element attribute='value' /></root>");

XML has a problem in that it is very easy to read and understand, but there are enough pitfalls for the unwary/lazy. I've had documents in the past where the encoding has been specified as UTF-8, but the characters supplied have been ISO-8859-1 which lead to some truly awful hacking with 'awk' and 'sed' later in a complex overnight batch process.

The MSDN article "Five Ways to Emit Test Results as XML" by James McCaffrey provides some interesting XML generation options for the .NET framework which I fully agree with - except for the end of Technique 1.

There are many, many toolkits out there for XML processing and generation - don't resort to string concatenation, you'll get it wrong!

 Saturday, April 01, 2006

All Hail The Real Kersal Massive

Well, it seems that those young scallies I featured in my previous post are actually as genuine as a bunch of lip-syncing pop idol muppets. Thanks to the real Kersal Massive for pointing out my mistake. Consider this a public apology! ;-)

 Friday, March 24, 2006

All Hail The Kersal Massive

This had me in fits of laughter when I first saw it a few moments ago. A finer example of chavdom would be hard to find - the only thing missing as far as I could make out was the fake Burberry baseball caps.

"Got on the bus with me Day Saver..."

Classic.

 Monday, January 30, 2006

Hmmmm, toasty...

The Dante's Inferno Test has banished you to the Sixth Level of Hell - The City of Dis!
Here is how you matched up against all the levels:
LevelScore
Purgatory (Repenting Believers)Very Low
Level 1 - Limbo (Virtuous Non-Believers)Moderate
Level 2 (Lustful)High
Level 3 (Gluttonous)High
Level 4 (Prodigal and Avaricious)Moderate
Level 5 (Wrathful and Gloomy)High
Level 6 - The City of Dis (Heretics)Very High
Level 7 (Violent)High
Level 8- the Malebolge (Fraudulent, Malicious, Panderers)High
Level 9 - Cocytus (Treacherous)Moderate

Take the Dante's Inferno Hell Test

 Friday, January 27, 2006

Microsoft Technical Support Rules!

... and no I'm not being sarcastic either.

It has to be said; Microsoft does make some of the best PC hardware around. Like a lot of people, I've been using their mice for some considerable time, but it wasn't until I started experiencing excruciating pain in my wrists and along the back of my hands that I started to use their 'Natural' keyboard range.

Within days of using the Natural MultiMedia Keyboard at home all the pain from my hands had disappeared and my typing speed was as good if not better than it was before I switched over - impressed, I got my employers to order an identical unit for when I'm in the office. However, apart from the annoying double-sized Delete key and the infuriating F-Lock status on startup there appears to be a slight design flaw with these keyboards. On both units, the feet that raise the keyboard at the rear snapped during normal use. To be honest, this was not a huge issue for me - I simply used a couple of old paperbacks to raise the rear of the units when in use at home, and a couple of unused DAT cartridge cases at work.

However, it occurred to me a couple of weeks ago that maybe Microsoft could send me a couple of spare sets of feet - I was quite willing to pay for them - to make my work environments slighly less messy. So, I phoned Microsoft Technical Support. Or at least I tried to - the Indian support call screening centre that I was routed through at first refused point black to give me a support request number or to let me speak to anyone at Technical Support. Undeterred, I used the online support request system on the Microsoft site - and within a hour I had a phone call back.

I explained that all I was after were a couple of sets of replacement feet, and that I was quite willing to pay for them, at which point the technical support representative asked for my home and email addresses. "Terribly sorry", explained the representative, "but we don't carry any spare keyboard stands - so I've ordered you a pair of brand new keyboards. Are you happy with the service you've received from Microsoft today?"

Sure enough, two brand new Natural Ergonomic Keyboard 4000 units arrived at my front door earlier this week. Now that is what I call customer service.