Some aspects of microformats are useful, and some are but very poor substitutes for XML or even JSON. Regardless, once you have decided to use microformats for a particular purpose it is important not to just shovel the microformats willy-nilly into content, but to declare their presence. The microformats community sets a quiet mandate for such declarations, but they are unfortunately used too rarely. It's very easy and inexpensive to make such declarations, and I'll show how in this article.
A microformat is a lightweight sub-format grafted onto a host language such as HTML, XHTML or Atom. The host language probably has a formal schema, but most microformats prefer informal descriptions in Wiki pages. There has been some effort to create a super-simple description format based on a subset of XHTML. These are called XHTML Meta Data Profiles (XMDP). The XMDP home page (see Resources) says:
[XMDP] is a simple XHTML-based format for defining HTML meta data profiles easy to read and write by both humans and machines. The markup is a [subset] of XHTML. All the microformats blessed by microformats.org have an XMDP profile, placed at a prominent location.
XMDP profiles are a way to explain and share the conventions of a microformat.
References to an XMDP profile on the Web is also supposed to provide some declaration
of the use of a microformat. Users are required to use such links in instance
documents. For XHTML, host language profile references are usually placed as an
attribute of the head element. Listing 1 is an example of
the first few lines of an XHTML document using the XML Friends Network (XFN)
microformat, with the important bit in bold font.
Listing 1. Example of an XHTML document using the XFN microformat
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<title>Sample document</title>
</head>
|
profile is a valid attribute in HTML 4 and XHTML 1.x. For a document using multiple microformats the convention is to use a list of URIs separated by spaces. This is a bit unusual because the intent of the XHTML DTDs seem to be that profile is a single URI, although if you look carefully, a space-separated URI list meets the letter of the CDATA data type used in the DTD. This is a lucky stroke for microformatters because of the expressive limitations of DTDs.
With profile links a microformats processor can be smart enough to only parse
declared profiles, which reduces some of the potential for clashes and confusion. The
Semantic Web community wants to take advantage of formal profiles for microformats by
using them as a hook to extract structured metadata from instance documents. The
sharp end of this effort is Gleaning Resource Descriptions from Dialects of Languages
(GRDDL), a way to extract RDF from (generally) XML using a transform technology,
typically XSLT. A GRDDL processor would check a document for a special sort of
profile that provides a link to a transform for RDF extraction. So a GRDDL-friendly
document using XFN specifies a profile link of http://www.w3.org/2003/g/data-view rather than http://gmpg.org/xfn/11. The latter is XFN-specific, while the GRDDL form is instead a general-purpose profile for XHTML. To specify the use of XFN, a GRDDL-friendly document also specifies a transform link to a specialized XFN extractor. Listing 2 shows the first few lines of such a document.
Listing 2. Example of GRDDL-friendly document that also specifies a transform link to a specialized XFN extractor
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://www.w3.org/2003/g/data-view">
<title>Sample document</title>
<link rel="transformation"
href="http://www.w3.org/2003/12/rdf-in-xhtml-xslts/grokXFN.xsl"/>
</head>
|
The added link element specifies an XSLT for extracting RDF from XFN snippets.
Plain Microformats have more market buzz than GRDDL, so it might make sense to stick to the microformats-blessed profile links, and for GRDDL processors to be smart enough to automatically understand the translation from Listing 1 to Listing 2. All this does you no good if you don't even use the basic profile links, and as microformats grow into more territory you will almost certainly have cause to be thankful for adding profile links in target documents. Profile links are required, although this requirement is too often ignored. They cost nothing, and the main reason they are not more widespread is that the microformats community has been too quiet in pushing for them. Now that you understand them better, be sure to put them to good use in your instance documents.
Learn
-
Microformats
in Context (O'Reilly XML.com, April 2006) and Microformats the XML way (developerWorks, May 2007): Learn more about some of the problems with microformats in both these articles by Uche Ogbuji.
-
wordpress
+ kubrick + hReview = trouble: Preview the problems that can occur with microformats clashes and confusion, a Weblog entry by microformats advocate Ryan King. He hastily dismisses some of the fundamental problems, but you can see why at the very minimum a profile link is important.
-
GRDDL
Primer: Discover GRDDL and, to learn why such a technology is useful see The future of the Web is
Semantic (Naveen Balani, developerWorks, October2005).
-
IBM XML certification: Find out how you can become an IBM-Certified Developer in XML and related technologies.
-
XML technical library: See the developerWorks XML zone for a wide range of technical articles and tips, tutorials, standards, and IBM Redbooks.
-
developerWorks technical events and webcasts: Stay current with technology in these sessions.
-
developer Works XML zone: Find more XML resources here, including articles, tutorials, tips, and standards. For a complete list of XML tips to date, check out the tips summary page.
- Browse the technology bookstore for books on these and other technical topics.
Get products and technologies
-
microformats home page and XMDP: Find all the basic material for microformats and learn about a companion technology.
-
IBM trial software: Build your next development project with trial software available for download directly from developerWorks.
Discuss
- Participate in the discussion forum.
-
developerWorks XML zone: Share your thoughts: Share your ideas and comments about XML zone content with the Linda Meyer, the XML zone editor.
-
XML zone discussion forums: Participate in any of several XML-centered forums.
-
developerWorks blogs: Check out these blogs and get involved in the developerWorks community.

Uche Ogbuji is Principal at Uli, LLC, a services firm specializing in next generation Web technologies. Mr. Ogbuji is lead developer of 4Suite, an open source platform for XML, RDF and knowledge-management applications and lead developer of the Versa RDF query language. He is a Computer Engineer and writer born in Nigeria, living and working in Boulder, Colorado, USA. You can find more about Mr. Ogbuji at his Weblog Copia.





