{"id":67,"date":"2006-03-27T17:02:58","date_gmt":"2006-03-28T00:02:58","guid":{"rendered":"http:\/\/www.redmonk.com\/cote\/wp\/?p=67"},"modified":"2006-03-27T17:02:58","modified_gmt":"2006-03-28T00:02:58","slug":"testing-out-microformats-hcard","status":"publish","type":"post","link":"https:\/\/redmonk.com\/cote\/2006\/03\/27\/testing-out-microformats-hcard\/","title":{"rendered":"Testing Out Microformats: hCard"},"content":{"rendered":"<p>Since I&#8217;ve been talking a big KISS-game recently, I thought I&#8217;d get my hands dirty with a couple <a href=\"http:\/\/microformats.org\/\">microformats<\/a>. Today I went for <a href=\"http:\/\/microformats.org\/wiki\/hcard\">hCard, which is a XHTML version of vCard, which itself is just a way to markup your contact info<\/a>. There are <a>marking up your links and <code>cite<\/code>s to other people<\/a>. But, for now, I&#8217;m just interested in one person (me) declaring their contact info.<\/p>\n<h2>The Page<\/h2>\n<p>If you look at the sidebar of <a href=\"http:\/\/www.peopleoverprocess.com\">the main page for the blog<\/a>, you&#8217;ll see:<\/p>\n<p>\n<a href=\"http:\/\/www.flickr.com\/photos\/cote\/118975915\/\" title=\"Photo Sharing\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/static.flickr.com\/11\/118975915_2515e6be53_m.jpg\" width=\"90\" height=\"240\" alt=\"Rendered hCard\" \/><\/a>\n<\/p>\n<p>Which is pretty much what it was before I started playing with it, sans the IM links and time zone. The point is: the visual rendering of the page and even the CSS didn&#8217;t need to change to use hCard. The microformat is unobtrusive, which is fancy-talk for &#8220;cheap to implement.&#8221;<\/p>\n<h2>The Code<\/h2>\n<p>Here&#8217;s what the &#8220;code&#8221; (to use the term loosely) looks like:<\/p>\n<pre>\n&lt;address class=&quot;vcard&quot;&gt;\n\t&lt;div id=&quot;about&quot;&gt;\n\t\t&lt;h2&gt;About&lt;\/h2&gt;\n\n\t\t&lt;p class=&quot;pic&quot; id=&quot;portrait&quot;&gt;\n\t\t\t&lt;a href=&quot;http:\/\/www.flickr.com\/photos\/cote\/&quot;\n\t\t\t   title=&quot;More photos&quot;&gt;\n\t\t\t   &lt;img src=&quot;http:\/\/static.flickr.com\/31\/101406173_5dad3bf43a_m.jpg&quot;\n\t\t\t        width=&quot;160&quot; height=&quot;240&quot; alt=&quot;Cot&eacute;&quot; class=&quot;photo&quot; \/&gt;&lt;\/a&gt;\n\t  &lt;\/p&gt;\n\n\t\t&lt;p&gt;I&apos;m &lt;a class=&quot;url fn&quot; href=&quot;http:\/\/www.peopleoverprocess.com&quot;&gt;Cot&eacute;&lt;\/a&gt;,\n\t\t\ta software &lt;span class=&quot;title&quot;&gt;Industry Analyst&lt;\/span&gt;\n\t\t\twith &lt;a href=&quot;http:\/\/www.redmonk.com&quot;&gt;&lt;span class=&quot;org&quot;&gt;RedMonk&lt;\/span&gt;&lt;\/a&gt;.\n\t\t\tI cover a wide range of topics in the software and technology world.\n\t\t\tThese opinions are my own, but whose else would they be?&lt;\/p&gt;\n\t&lt;\/div&gt;\n\n\t&lt;div id=&quot;contact&quot;&gt;\n\t\t&lt;h2&gt;Contact&lt;\/h2&gt;\n\t\t&lt;span class=&quot;email&quot;&gt;\n\t\t\t&lt;span class=&quot;type&quot;&gt;Email&lt;\/span&gt;:\n\t\t\t&lt;a class=&quot;email&quot; href=&quot;mailto:cote@redmonk.com&quot;&gt;cote@redmonk.com&lt;\/a&gt;\n\t\t&lt;\/span&gt;\n\t\t&lt;br\/&gt;\n\t\tY!: &lt;a class=&quot;url&quot; href=&quot;ymsgr:sendIM?bushwald&quot;&gt;bushwald&lt;\/a&gt;\n\t\t&lt;br \/&gt;\n\t\tAIM: &lt;a class=&quot;url&quot; href=&quot;aim:goim?screenname=bushwald&quot;&gt;bushwald&lt;\/a&gt;\n\t\t&lt;br\/&gt;\n\t\t&lt;!-- didn&apos;t bother putting these in microformat --&gt;\n\t\tGTalk: bushwald@gmail.com&lt;br \/&gt;\n\t\tMSN: msn@coteindustries.com&lt;br \/&gt;\n\t\tSkype: &lt;a class=&quot;url&quot; href=&quot;callto:\/\/bushwald&quot;&gt;bushwald&lt;\/a&gt;\n\t\t&lt;br\/&gt;\n\t\t&lt;span class=&quot;tel&quot;&gt;\n\t\t\t&lt;span class=&quot;type&quot;&gt;Work&lt;\/span&gt;:\n\t\t\t&lt;span class=&quot;value&quot;&gt;+1-512-206-2927&lt;\/span&gt;\n\t\t&lt;\/span&gt;\n\t\t&lt;br \/&gt;\n\t\t&lt;span class=&quot;tel&quot;&gt;\n\t\t\t&lt;span class=&quot;type&quot;&gt;Cell&lt;\/span&gt;:\n\t\t\t&lt;span class=&quot;value&quot;&gt;+1-512-663-7507&lt;\/span&gt;\n\t\t&lt;\/span&gt;\n\t\t&lt;br \/&gt;\n\t\tTime Zone: &lt;abbr class=&quot;tz&quot; title=&quot;-06:00&quot;&gt;CST&lt;\/abbr&gt;&lt;\/span&gt;\n\t&lt;\/div&gt;\n&lt;\/address&gt;\n<\/pre>\n<p>That may seem like a lot of code, but the difference between what I had before adding in an hCard and after is slim.<\/p>\n<p>The key point here is that the microformat of an hCard more layers <i>on top<\/i> of existing formats than rests on it&#8217;s own. A companion point is that the hCard microformat piggybacks on existing XHTML tags instead of making it&#8217;s own tags up.<\/p>\n<p>The long existent <code>address<\/code> tag is used for the entire hCard, and it spans more than one &#8220;block&#8221; of data. You don&#8217;t have to use <code>address<\/code>, of course, the important things are the <code>class<\/code> attributes and the relationships implicit in the XHTML nesting.<\/p>\n<h3>Convention and Hierarchy<\/h3>\n<p>So, what we have here is formatting by convention (to steal a page from Rails) and hierarchy.<\/p>\n<p>Format and convention are two words that don&#8217;t often go together, because convention implies messiness and parsing problems. But, convention, <a href=\"http:\/\/www.redmonk.com\/cote\/archives\/2006\/03\/invalid_success.html\">not validity<\/a>, is what makes, and made, the web successful.<\/p>\n<p>Hierarchy is a danger word for many coders as it&#8217;s a synonym for &#8220;bad performance&#8221; and &#8220;walking DOMs.&#8221; Both of those applied to the hilt until recently. But those problems have been steadily fixed in XML\/XHTML land with a better understanding of XSLT, CSS paths, and the fact walking a DOM in a dynamic languages (e.g., JavaScript) can be much easier than in most static (e.g., Java) languages.<\/p>\n<h2>Rendering<\/h2>\n<p>Here&#8217;s what the data looks like in <a href=\"http:\/\/www.metonymie.com\/hCard_extract\/app.html\">a third-party tool<\/a>:<\/p>\n<p>\n<a href=\"http:\/\/www.flickr.com\/photos\/cote\/118973547\/\" title=\"Photo Sharing\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/static.flickr.com\/55\/118973547_49a78ae52f.jpg\" width=\"500\" height=\"224\" alt=\"My hCard in Use\" \/><\/a>\n<\/p>\n<p>Not too hot because of two things: I have a funny character in my name (&eacute;) that no one nor no thing ever gets right. <a href=\"http:\/\/www.dehora.net\">Bill<\/a> probably has the same problem. Also, it seems to have conflated together two of my URLs. I&#8217;m not sure if that&#8217;s because I typed in something wrong, or a bug in the tester.<\/p>\n<h2>Why This Matters: Less Code &amp; Config<\/h2>\n<p>Typical snafu&#8217;s aside, what&#8217;s amazing about this example is that with just 10-20 minutes of reading and typing, a static web page was used to provide structured data to a 3rd party tool. The time it took doesn&#8217;t matter so much, what does matter is that one view can be used by two different consumers. The URL <a href=\"http:\/\/www.peopleoverprocess.com\">PeopleOverProcess.com<\/a> can be used by:<\/p>\n<ol>\n<li>People who want to read the webpage.<\/li>\n<li>Software that wants to get my contact info.<\/li>\n<\/ol>\n<p>Normally, you would need two different URLs\/files for that: one for each consumer. That is, microformats make screen-scrapping really easy. No more need to use regexes and script-hacks.<\/p>\n<p>This simplistic example doesn&#8217;t mean much. But let&#8217;s expand it to something with even more data: free\/busy calendars.<\/p>\n<p>A constant problem for us at RedMonk is scheduling meetings. We each have different OS&#8217;s, but more importantly, 99% of our scheduling is with people outside of our organization. so you can imagine that the Exchange\/Outlook approach doesn&#8217;t work too well.<\/p>\n<p>Now, you can imagine that we could put a calendar on a web page that showed when we were free and busy: it might even say what we were doing at the time, contain links to relevant things (like follow-up blog posts)&#8230;you know, the Web 2.0 calendaring wet dream ;&gt; <a href=\"http:\/\/www.upcoming.org\">Upcoming<\/a>, <a href=\"http:\/\/www.eventful.com\">eventful<\/a>, and others are good initial cuts at a UI for a calendar (the next steps are integrating with more applications and services, like Exchange and iCal, or <a href=\"http:\/\/www.dodgeball.com\">dodgeball<\/a>.).<\/p>\n<p>What gets tricky is if some application &#8212; say Outlook &#8212; wants to use that calendar web page to help someone schedule time with RedMonk. Good luck with that. At best you&#8217;d have to screen-scrape and someone hook up with Outlook.<\/p>\n<p>Now, if that calendar web page was microformated &#8212; with <a href=\"http:\/\/microformats.org\/wiki\/hcalendar\">hCalendar<\/a>? &#8212; things would go much better for the program involved: parsing the well-formed XHTML of a microformat is do-able in a short amount of time (read: &#8220;cheap&#8221;).<\/p>\n<p>You might be thinking, &#8220;but you could just have the programatic view of the calendar at another URL.&#8221; And, sure, you could, but why have more code?<\/p>\n<p>Which highlights a key benefit of microformats in web pages is that you don&#8217;t need a protocol of discovery for the programatic content. For example, if I give you the URL http:\/\/www.peopleoverprocess.com, I might have to markup in that page that my programatic calander view is at http:\/\/www.peopleoverprocess.com\/cal.xml. (Indeed, this is what&#8217;s done for RSS feeds with a <code>link<\/code> tag in the page&#8217;s <code>head<\/code>.) That&#8217;s where the whole &#8220;one view instead of two&#8221; idea comes in again. Once you&#8217;ve got the URL, you&#8217;ve &#8220;discovered&#8221; everything there is to know.<\/p>\n<h2>Using It<\/h2>\n<p>There are always going to be times when another view is better. On the other hand, when it comes to many types of data &#8212; contact, calendars, social net relationships, and other declarative statements in both consumer and enterprise software &#8212; coding a support another view for programatic access may be just time prohibitive enough to prevent you from providing programatic access. In those times, microformats are a good option. Meta-data is exciting stuff, and microformats are light-weight enough to actually be a viable approach to meta-data&#8230;as opposed to say, RDF, at least by programmer-lore.<\/p>\n<p>The over-all simplicity of microformats makes them a good base-line for providing data access as well. Instead of starting out with a new view from the get go, It might be a good idea to start by using a microformat, and only expand out to a brand new view if needed.<\/p>\n<p><b>Disclaimer:<\/b> Microsoft is a client.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Since I&#8217;ve been talking a big KISS-game recently, I thought I&#8217;d get my hands dirty with a couple microformats. Today I went for hCard, which is a XHTML version of vCard, which itself is just a way to markup your contact info. There are marking up your links and cites to other people. But, for [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-67","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/redmonk.com\/cote\/wp-json\/wp\/v2\/posts\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/redmonk.com\/cote\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/redmonk.com\/cote\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/redmonk.com\/cote\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/redmonk.com\/cote\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":0,"href":"https:\/\/redmonk.com\/cote\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"wp:attachment":[{"href":"https:\/\/redmonk.com\/cote\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redmonk.com\/cote\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redmonk.com\/cote\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}