[microformats-discuss] Parsing and class names

Mark Pilgrim pilgrim at gmail.com
Sun Oct 16 12:39:30 PDT 2005


On 10/16/05, Luke Arno <luke.arno at gmail.com> wrote:
> The atompub WG is kicking around the idea of using a microformat
> for introspection. Someone raised the following concern.
>
>   "I notice, for example, that none of the
>   microformat examples so far have multiple classes assigned, which while
>   being entirely valid xhtml might be forgotten and not properly handled by
>   specialised parsers."

This would be interesting

http://microformats.org/wiki/hcard-examples#2.4.2_VCARD

if it were true

http://microformats.org/wiki/hcard-examples#Example_2_8

but it is neither interesting

http://microformats.org/wiki/hcard-examples#Example_2_11

nor true.

http://microformats.org/wiki/hcard-examples#7.__Authors.27_Addresses

> Does anyone else have any comments on their experiences parsing
> microformats

This is a line of code from my hCard parser,
http://diveintomark.org/projects/greasemonkey/hcard/hcard.user.js :

var xpath = ".//" + sPrefix + "*[contains(concat(' ',
normalize-space(@class) ,' '), ' " + sProperty + " ')]";

If I were parsing microformats in an environment where I could assume
that class attributes contained exactly one class name without leading
or trailing spaces, then this line would become

var xpath = ".//" + sPrefix + "*[@class='" + sProperty + "']";

In other words, multiple class names added exactly 48 bytes of
complexity to my parser.

Your mileage may vary.

--
Cheers,
-Mark


More information about the microformats-discuss mailing list