Skip to main content

Tip: Apply profile links to microformats

Learn how to use simple signals to announce that a document uses microformats

Uche Ogbuji (uche@ogbuji.net), Principal, Uli, LLC
Photo of Uche Ogbuji
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.

Summary:  Microformats are a popular way to incorporate structured data into regular Web pages. Unfortunately, using microformats without some measure of control can lead to confusion and technical problems. Learn how formal profile declarations in your documents can improve the value of your microformats.

View more content in this series

Date:  26 Jun 2007
Level:  Intermediate
Activity:  1345 views
Comments:  

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.

Microformat profile

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.

Link to profile

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.

A semantic angle

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.


Wrap up

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.


Resources

Learn

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

About the author

Photo of Uche Ogbuji

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.

Comments



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML
ArticleID=227418
ArticleTitle=Tip: Apply profile links to microformats
publish-date=06262007
author1-email=uche@ogbuji.net
author1-email-cc=dwxed@us.ibm.com

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers