The Community Engine Blog

News, tools, and analysis for innovating in the information economy

  • Main
  • RSS 2.0

« Greasemonkey & microformats: Getting started | | Microformats in Business — Structuring Content for Search & Collaboration »

Follow-up to Greasemonkey & Microformats

We are nearing the point where we can write a full tutorial on microformats identification. In the next post, I'll discuss how all of this can fit into a business model.

Sections:

Topics:

The point of my last, rather technical post was to start to provide a tutorial for newcomers to microformat development. The post led to a good amount of follow-up from the micrformats community. The basic strategy of using the user agent's (i.e., browser's) native ability to parse html and isolate parts of the markup based on attribute values is sound. That said, there are a couple of refinements in order.

First, although Internet Explorer supports the XPath web standard, it cannot be directly accessed for web pages. Dimitri Glazkov has written a javascript library that provides the same functionality for Internet Explorer as last week's post showed for Firefox. However the library has performance issues, and a better prototype may come from Danny Goodman's Javascript & DHTML Cookbook.

Second, Alf Eaton points out that my original code for identifying microformats allows for collisions between different microformats if the identifier of one microformat is contained within another. He suggests a solution using regular expressions. Here's the solution I gave in my last post, with his solution:

var allDivs, thisDiv;
var mf = 'xfolkentry';

var micropath = “//*[contains(@class,'” + mf + “')]”;
var micromatch = new RegExp('\\b' + mf + '\\b');

allDivs = document.evaluate(
    micropath,
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);
		
for (var i = 0; i < allDivs.snapshotLength; i++) {
    thisDiv = allDivs.snapshotItem(i);
    // do something here.  For example, change the background color to red.
    if (iNode.className.match(micromatch)) // apply the regex test
    thisDiv.style.backgroundColor = 'red';
}

My sense is that we are heading to the point where we have enough material to write a full tutorial on microformat identification in web browsers. In my next post, I'll discuss how all of this fits into a potential microformats business model.

Bud posted this on July 31, 2005

Trackback Pings

TrackBack URL for this entry:
http://thecommunityengine.com/cgi-sys/cgiwrap/fpgibson/thecommunityengine.com/mt/mt-tb.cgi/679

Comments

Post a comment




Remember Me?