Good article. Unfortunately we are stuck with a vendor that thinks XML is the best and only solution to data transfers, yet they have not idea how to properly format the XML and don't believe in a DTD's or schemas. Basically all they deliver is a text file with tags and all we get is a bunch of headaches. I still believe XML has it’s place but after being forced to use it, I'm starting to think that it’s just a buzz-word used by management and resumes.
Thanks for all your kind words. A few thoughts.
As it says in the heading in italics, I originally wrote this 7 years ago. I couldn't get it published then, because it was (and still is, really) counter to the current orthodoxy. I really don't understand the allure of what is essentially a failed idea.
What are XML languages good for? A major clue is in their name: markup languages. Markup languages are created for marking up text. They're not created for, nor are they good at, data transfer or data storage.
Finally, if you do use XML for whatever reason, I strongly recommend sticking with DTD's, as opposed to the far cooler XML Schemas. In my opinion, the extra you get from schemas is not worth the extra obfuscation; in addition, schema processing is still pretty immature. During my time trying to implement the SPL project for the FDA, the official schema compiled in XMLSpy (as an XML file) but didn't compile in another tool (as a schema). What do you do in that case?
Very good article! Although there's a point I don't agree with: XML is a markup language technology (as it's name clearly states), and as such, it can be used for anything we want (yes, including data storage/transfer/formatting/etc... just as HTML).
XML is not the problem. The real problem begin with us (developers), trying to use it for everything. As an old saying goes: "With a hammer in my hand, every problem looks like a nail".
IMO, XML has its place somewhere... it's up to us to find such place, that is most likely different for each one of us. Try to see if the nail has some markings on its head before you start hammering away. Yes, a hammer will drive the screw in any way, but maybe a screwdriver can get the job done faster and without so much effort.
"How do you create or consume XML from within your programs?"
First of all, let's ban the word "consume" from any discussion of data . That includes "web services"
Oracle has very nice conversion functionality between XML and its relational model. I'd look there first.
"XML is a markup language technology (as it's name clearly states), and as such, it can be used for anything we want (yes, including data storage/transfer/formatting/etc... just as HTML)"
No argument there. My point is that XML languages (I feel like the GNU/Linux guy) don't do anything but markup text well. I can buy a car with dimes. Why would I want to?
Just to throw some balance to the discussion, let me be the lonely voice of dissent.
What the author says about XML could be said about almost any other technology available to store/share data. There is no universal solution that can be adapted to every case. For simple cases, an old fashioned text file is more than enough, but as the complexity increases so does the solution. Files used by a single application can be whatever a programmer wants and they usually work fine, but as applications begin to interact with one another the simple solutions show their limitations. Interaction implies well defined interfaces, and XML provides an great way to describe and publish an interface. Not the only way, for sure, but it has distinctive advantages over other ways like COM, IDL, header files or EDI. If you program in an isolated environment this is a non issue, but if you need to write programs that consume data from vastly different sources, you need some standard. Enter XML. The wide adoption of this format has made it the de-facto standard, and that's something GOOD if you are in the business of data publishing/consumption.
By claiming that XML is overly complex, the author is ignoring one of its key features, which is the fact that there is a standard, and this fact has made possible the development of many tools and language constructs (most of them freely available) designed specifically to deal with all the complexities of XML. This is what makes XML a good choice for many projects (notice I don't say "for every project"). As an example, compare with the still popular comma delimited file: If you are processing information sent in that format, you either trust each line has the same number of fields or write code to deal with exceptions. Same for the actual data: if the third field has to be a date, you have to write your own code to check for it. In general, you end up writing code that is custom made for a particular file, and if the the file format changes, you usually need to change your code. Compare that with the XML solution: once you agree on a particular schema (including a DTD), all the grunt work is already coded in most XML frameworks, you only worry about processing the data.
Maybe in the old days XML had to be manually processed and validated, but we've come a long way, and nowadays most XML traveling the net is never seen directly by any user, it's just processed by highly optimized code that works precisely because for once we have a format with almost universal acceptance. I don't see anything wrong with that.
If you don't like XML, you are free to use whatever format you like, but if you need to interchange information with the rest of the world, don't expect everyone to adapt to your own format. In fact, just about everybody already adapted to XML, so why not use that to your advantage?.
"No argument there. My point is that XML languages (I feel like the GNU/Linux guy) don't do anything but markup text well. I can buy a car with dimes. Why would I want to?"
That's a good point. But still, a tool is a tool, and as such, you can't expect it to do the work for you, nor it will make it better if you don't use it properly. Think of it as two different car dealers. Each of them has a sign out front. The first one reads: "Mustang for sale: $100.000". The second one reads "Mustang for sale: $100.000. 5% Discount if you pay with dimes". My point is that the "Why would I want to?" part can have a lot of explanations. But it's still up to us to choose one. In this particular case, I would put $5.000 against my laziness to gather the dimes. Tuff call...
Yes, XML does nothing more than formatting text well. But, if that's what I need, it just might worth the shot. Why not? Everyone else seems be using it! (just kidding... )