Lists in Microformats: Suggested Optimisation

Based on my extensive experience of applying microformats to templates in Wikipedia (and other MediaWiki installations) I’ve come to the following conclusion…

For attributes which can occur more than once (such as nickname or category in hCard), lists having, or in container having, that property should be parsed as lists of individual instances of that property.

For example:

<div class="category">
<ul>
<li>ornithologist</li>
<li>driver</li>
<li>gardener</li>
</ul>
</div>

and:

<ul class="category">
<li>ornithologist</li>
<li>driver</li>
<li>gardener</li>
</ul>

should be treated as equivalent to:

<ul>
<li class="category">ornithologist</li>
<li class="category">driver</li>
<li class="category">gardener</li>
</ul>

Advertisements

Tags: , , ,

3 Responses to “Lists in Microformats: Suggested Optimisation”

  1. Michael Kaply Says:

    I like the ul case, I don’t like the div case.

    The ul class is very specifically defined.

  2. pigsonthewing Says:

    Mike,

    Thanks for the prompt feedback. The <div> case (actually, any container, most often <td>) is for cases where, in templates, the class is applied to the container with the expectation that a single value is entered, but occasionally a list is used. I see this happen quite often.

    Perhaps the rule should be “where a single value is expected, but a list is encountered, treat each item in that list as a single value”?

    Would you be willing to implement something like this in Operator?

  3. Sarven Capadisli Says:

    I agree with Michael that the class on the listing elements (ul, ol, dl and perhaps we can chalk table in there?) is more specific than the div case and it is also less error prone. I think the div case also goes against the optimization definition you’ve provided, since the individual instances are not closely tied with the parent element e.g., li to ul.

    I may have misunderstood something here, but this optimization might raise some complications for authors and intended parsing. Perhaps you did not intend to do the optimization for all formats, in which case you can discard the following, but consider how these cases will be treated:

    <ul>
    <li class="hentry"></li>
    <li class="hentry"></li>
    <li class="hentry"></li>
    </ul>
    

    and

    <ul class="hentry">
    <li></li>
    <li></li>
    <li></li>
    </ul>
    

Comments are closed.


%d bloggers like this: