I tend to assume most people know what they’re talking about, especially if they’re talking about something I don’t really understand. Sometimes it takes a really blatant example of just what it is they’re saying before I realize they’re talking out of their posteriors.
For instance, I used to think homeopathy was a vaguely reasonable practice based on traditional herbal medicine. Then one day I was stuck at the pharmacist for fifteen minutes waiting for a prescription. Since I had nothing better to do, I picked up a pamphlet about the principles of homeopathy and started to read. Almost immediately it became clear that there was nothing in the little glass vials except plain water, that there was no possible way any of these “remedies” could do anything except through the placebo effect, and that the whole field was complete and utter bunk.
It’s important to note here that I didn’t read some detailed scientific study about homeopathy. I didn’t read an article in the Skeptical Inquirer debunking homeopathy. I read a really well-written piece by an advocate of homeopathy that explained exactly what homeopathy was and why they thought it worked; and that clear explanation showed me (or anyone with a layperson’s understanding of chemistry) that homeopathy was completely bogus. I have recently had the same experience with microformats.
I confess for a while I just didn’t get the whole microformat brouhaha. I hadn’t paid a lot of attention to it, and I didn’t feel like I needed to. It didn’t seem to solve any of my problems. I had this vague picture in my head that it involved embedding non-HTML markup in HTML documents; and that struck me as a reasonable thing, if not quite as powerful as the full-blown XML I was using. (Just like herbal medicine seemed like a reasonable option when modern pharmaceuticals weren’t available.) But then I read recent article about microformats by Jack D. Herrington; and suddenly I realized just what the microformatters were so excited about, and just as suddenly I realized it was bunk.
Let me explain. Here’s the first example from Herrington’s article. It shows embedding some additional metadata in an HTML document to identify events and dates:
<html> <body> <div class="vevent"> <a class="url" href="http://myevent.com"> <abbr class="dtstart" title="20060501">May 1</abbr> - <abbr class="dtend" title="20060502">02, 2006</abbr> <span class="summary">My Conference opening</span> - at <span class="location">Hollywood, CA</span> </a> <div class="description">The opening days of the conference</div> </div> </body> </html>
But why would anyone write markup like this? It brings exactly nothing to the table.* It is substantially more opaque and harder to work with than traditional XML like this:
<html> <body> <vevent> <a href="http://myevent.com"> <date> <abbr title="20060501">May 1</abbr> - <abbr title="20060502">02, 2006</abbr> </date> <summary>My Conference opening</summary> - at <location>Hollywood, CA</location> </a> <description> <div>The opening days of the conference</div> </description> </vevent> </body> </html>
Sure, you could use XSLT, SAX, DOM and other tools on the microformat version; but years of experience teaches me that you’ll have a much easier time with the basic element structure I’ve outlined above. Why wouldn’t you do that? For example, Herrington’s article has lots of XPath queries like
.//*[contains(@class,'description'). These now become simpler (and possibly faster) queries like
.//description. The more complex the document and the more complex the format, the greater the simplicity you’ll achieve by moving to a macroformat instead of a microformat.
This brings up another point. Microformats are strictly limited in the amount of structure they can impose. All you can comfortably put in an attribute value is a single name. Full-blown element structures are much more extensible. With macroformats you can add namespaces, attributes, and other XML structure to your non-HTML markup.
I’ll tell you something else: web browsers will handle the macroformatted example just fine. I’ve been using this technique on Cafe au Lait and Cafe con Leche for years and it causes exactly zero problems. All web browsers back to Mosaic 1.0 simply drop out tags they don’t recognize. Feel free to sprinkle as much XML tag spice into your documents as you like. You won’t cause any problems for browsers. They’ll just render the HTML as usual. More modern browsers (pretty much everything since IE 5) even allow you to key off the new tags in XSLT.
The only reason I can imagine you might choose a microformat over a macroformat is because macroformats are invalid XHTML, but so what? XML doesn’t have to be valid! That’s a deliberate design decision in XML. Some say invalidity is the real revolution in XML. It’s what XML brings to the table that SGML never had.
Microformats bring exactly nothing to the table. All they do is complexify the markup and make it far harder to address with XPath and other XML tools. They don’t make pages any easier to index. They don’t make pages any easier to style. They don’t make pages easier to search or look better in web browsers. They certainly don’t make the pages easier to validate if you should want to do that (not that you really need to). There’s simply no advantage to microformats compared to macroformats. Microformats do solve a real problem (embedding extra non-HTML markup in web pages) but they were invented by people who apparently didn’t realize that this problem had been solved years ago, and much more effectively. It’s like someone realized they needed a tool to eat soup and invented the fork, without paying any attention to the spoons sitting in their kitchen drawers. Microformats are the wrong answer. Using them will only make your work harder and more complicated.