10 yrs in, XML is the langua franca

2008-02-16 @ 11:53#

i've read a number of posts on the 10 year birthday of XML. and i found it kinda 'ho-hum.' why the fuss over XML, anyway? i use it. it works. big deal.

that's when it hit me. that *is* a big deal. XML has become so ingrained, so a priori that most of us never even think about it. it's just *there.* like the electric service.

and, no doubt in my mind, XML is the language of servers. it's just so easy to leverage server power to read, validate, and transform XML documents into just about anything else (binary media notwithstanding). sure lots of clients use XML (even when we don't know it). but when it comes to building scalable (HTTP/REST) web apps, XML is really the server's food.

yes, that *does not* mean the XML is the best *client* language. in the last few years, JSON has emerged as a popular data format for javascript clients. that's cool. clients can send and receive application/json encoded data when talking to servers - no biggie. that's what the content-type and accept HTTP Headers are all about.

although most of the 'sturm und drang' has passed, i still see references to arguments on the relative merits of one data format over the other. as most realize now, this entirely misses the point. HTTP was expressly designed to *not* be a monolithic world. you can use any format you wish. as long as the server and client agree on them.

and that's the point - agreement

most folks get their knickers in a twist over format issues when they think they can't mix and match as they please. this is mostly a *server* issue. more accurately a server implementation issue. the people who are in charge of building HTTP server implementations are missing out when they fail to implement flexible representation patterns in their apps. dude, learn the meaning and use of content-type and accept headers. leverage them! you'll be a hero.

ok, back to my XML point. when it comes to the server-side, why *not* use XML to process incoming text? while there may be some cases where XML can be overkill, it's a server! you've got CPU and memory there - use it. the state of the XML/XSLT/XSD world is such that you can easily validate and transform just about any meaningful data. sure, incoming non-XML data can present a challenge, but - again - that's what mime-types are for. take some time to build a translator that consistently converts your target mime-type to a valid XML document. it's not all that hard. and once you have this done, *all* documents in that target mime-type can be converted to XML safely. now you're all set, you can use XSD to validate and XSLT, etc. to transform it into what you need. as many times as you need, too.

so there. happy birthday XML. you're cool.

code