When I do a title like this, I want to include audio that does the dramatic organ sound, “Dah, dah, DAH!”- you know, kind of scary like. Why a little scary? Here’s the deal: I’m all about using custom XML schemas for my Word or Excel documents, but there are a few irksome issues, dates in schemas being one of them. If you are new to Office and XML, in the words of Morpheus: Welcome to the real world.
Now, one of the hang-ups I have with using ISO 8601 compliant XML schemas is that the date datatype requires that dates be formatted this way: YYYY-MM-DD. The logic here (and it’s good) is that to help XML live up to its promise of universal data exchange, we should all standardize around a universal date format.
But, the world doesn’t work this way. This date format is just not the what a lot of business exchanges expect. Sure, we can run off on a tangent about ethnocentrism (big topic when I was in my Ph.D. courses), but I think it has less to do with sinister selfishness and arrogance and more to do with the adage that simply old habits die hard. As Natalie Merchant says, “Give ’em what they want.” So, if you attach your fully compliant XSD with the date datatype in it to a Microsoft Word 2003 document, you will see this (structured pane on top, with what the user sees in the doc below):
So, if you feel like you have sufficient clout in your company to impose the date format from your developer desk cluttered with soda cans and Visio diagram print outs, go for it (European’s, though their desks are just as cluttered, are cool with the format already, so there is less of an issue- except with doing business across the pond!).
What are your options?
1) Don’t use the xsd:date format. Go with a string.
2) Use XSL to transform dates after the fact. For example, we include a function, ms:date-format() to do this sort of thing
3) Create your own type for dates in the schema. Kirk Allen discusses this in a blog post wherein he discusses the merits of some of the issues. It’s a good read, and he links to Oleg’s blog (no shock there). Both great blogs.
4) Click your heels three times and say, “There’s no place like home”
In any case, these are things you need to think through. Intriguingly, I had been preparing this post last Friday when I was contacted by Catherine Heller (Tech Evangelist Extraordinaire) to see if I wanted to present some stuff around these various issues at an up-coming event. Strange coincidence. She’s cool.
Rock Thought for the day: 1971- That’s when the song Planet Caravan, was released by Black Sabbath. If you have never heard it, give it a listen. It still holds up after all these years (34!). The strong affinity with the era that brought us Pink Floyd and others is clear. The vocals are saturated and dreamy. The lyrics are nothing scary: just a ride toward the planet mars, hazy skies, psychedelic thoughts. It’s a song that has been too often overlooked.