implementation-guidelines

From Microformats Wiki
Revision as of 07:38, 30 July 2005 by MarkRickerby (talk | contribs)
Jump to navigation Jump to search

Guidelines and Strategies for Implementing Microformats

Publishers

  • Embedding in XHTML documents. See XMDP FAQ.
  • Microformats can be embedded in Atom entries:
 <entry>
   <title>Review of Some Object</title>
   <link href="http://microformats.org/wiki/" />
   <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
   <updated>20050730T1900-0700</updated>
   <content type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">
     <div class="hreview">
       <h3 class="summary"><span class="item fn">Some Object</span> Being Reviewed</h4>
       <p>Reviewer: <span class="reviewer fn">author name</span> - 
       <abbr class="dtreviewed" title="20050730T1900-0700">July 30, 2005</abbr></p>
       <blockquote class="description"><p>The review content</p></blockquote>
       <span><span class="rating">5</span> out of 5</span>
     </div>
    </div>
   </content>
 </entry>

Questions:

  • Should an XMDP profile be linked to the Atom entry?
  • Should the hreview class appear in the content container div?

Identification

Javascript/XPath example which runs in Mozilla:

var mf = 'hreview';

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

var mc = document.evaluate(micropath, document, null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < mc.snapshotLength; i++) {
    iNode = mc.snapshotItem(i);
    if (iNode.className.match(micromatch))
        doSomething();
}