[uf-discuss] hCard -> jCard implementation

Toby A Inkster mail at tobyinkster.co.uk
Thu Apr 3 03:06:22 PST 2008

Yes, already. This is based on the soon-to-be-released Cognition-0.1- 

Example input:

Example output:

Notable notes:
* Cognition doesn't just support hCard as input — it will pick up  
contact data from, say the W3C PIM vocabulary used with RDFa, or FOAF  
in eRDF, or chunks of RDF/XML in HTML comments. Basically, if you've  
got some metadata, it will be found. And if the metadata relates to a  
person, then it will be exported as jCard. The example input above  
does indeed include some RDFa goodness.
* geo (indeed multiple instances thereof) is supported as a  
descendent of adr.
* altitude, reference-frame and body are supported as sub-properties  
of geo, roughly as documented on the uf geo-extension-strawman and  
geo-extension-elevation wiki pages.
* Because different terms are used in hCard and vCard, categories are  
duplicated in the jCard output — there is a "category" array and a  
"categories" array containing identical information.
* When no "type" is given for "adr", "tel" or "email", default types  
are explicitly added to the output. List of default types are in  
hCard spec, section 3.15.2.
* There is a tiny buglet with nested vCards for agents — look  
carefully at the output and you'll see.

Yes, http://srv.buzzword.org.uk/jcard/ can be used to test your own  
hCards, but bear in mind that it is *very* slow. If anyone is willing  
to donate hosting to the Cognition project, I'd be eternally  
grateful. (Well, maybe not eternally, but certainly grateful for at  
least a month.)

Note that %2523 is a double-URL-encoded hash symbol. (Not sure why  
the double-encoding is necessary, but I haven't been able to get %23  
to work on its own.) That is, it's targeting a particular hCard on  
the page using the id attribute. If you leave the fragment identifier  
out, an array will be returned, containing jCard objects for each  
card found on the page — if there's only one hCard on the page, it  
will still be in an array.

e.g. if you want to test <http://www.example.com/foo/bar.html#mycard>  
then visit <http://srv.buzzword.org.uk/jcard/www.example.com/foo/ 

There are other services too: http://srv.buzzword.org.uk

Toby A Inkster
<mailto:mail at tobyinkster.co.uk>

More information about the microformats-discuss mailing list