hcard: Difference between revisions

From Microformats Wiki
Jump to navigation Jump to search
(moving implementations to own page)
Line 1: Line 1:
<h1>hCard</h1>
<h1>hCard</h1>


hCard is a simple, open, distributed format for representing people, companies, organizations, and places, using a 1:1 representation of the properties and values of the vCard standard ([http://www.ietf.org/rfc/rfc2426.txt RFC2426]) in [[semantic-xhtml|semantic XHTML]]. hCard is one of several open [[microformats|microformat]] standards suitable for embedding in (X)HTML, Atom, RSS, and arbitrary XML.
hCard is a simple, open, distributed format for representing people, companies, organizations, and places, using a 1:1 representation of the properties and values of the vCard standard ([http://www.ietf.org/rfc/rfc2426.txt RFC2426]) in [[semantic-xhtml|semantic XHTML]]. hCard is one of several open [[microformats|microformat]] standards suitable for embedding in (X)HTML, Atom, RSS, and arbitrary XML.


Want to get started with writing an [[hcard|hCard]]?  Use the [http://microformats.org/code/hcard/creator hCard creator] to write up some contact information and publish it, or follow the [[hcard-authoring|hCard authoring tips]] to add hCard markup to your current contact page.
Want to get started with writing an [[hcard|hCard]]?  Use the [http://microformats.org/code/hcard/creator hCard creator] to write up some contact information and publish it, or follow the [[hcard-authoring|hCard authoring tips]] to add hCard markup to your current contact page.
Line 170: Line 170:
* category, note
* category, note
* class, key, mailer, uid, rev
* class, key, mailer, uid, rev
==== type subproperty values ====
==== type subproperty values ====


Line 245: Line 246:
=== More Examples ===
=== More Examples ===


See [[hcard-examples]] for more examples, including all examples from vCard RFC 2426 converted into hCard.
*[[hcard-examples]] - more examples, including all examples from vCard RFC 2426 converted into hCard.
 
*[[hcard-examples-in-wild]]
== Examples in the wild ==
*See [[hcard-examples-in-wild]]
 
== Implementations ==
This section is '''informative'''.
 
The following implementations have been developed which either generate or parse hCards. If you have an hCard implementation, feel free to add it to the top of this list. Once the list grows too big, we'll make a separate wiki page.
*[http://www.alexa.com/site/devcorner/hcard Alexa hcard search]
*[http://leftlogic.com/info/articles/microformats_bookmarklet Microformats Bookmarklet] is a bookmarklet designed for Safari (works in Firefox and Camino) that overlays on the current page to allow users to import individual hCards or hCalendars.  Written by Remy Sharp.
*[http://elbewerk.com/2006/09/vcardexplorer-02.shtml vCardExplorer 0.2] is a Mac OS X Application, that displays VCF-Files and extracts hCards from Websites written by Daniel Kagemann.
* [http://placenamehere.com/mf/nnwextract/ Extract Microformats] is a script for NetNewsWire that supports extracting hCard and hCalendar data in blog posts (via technorati service). Written by [[User:ChrisCasciano|Chris Casciano]]
* [http://allinthehead.com/hkit/ hKit] is an open source PHP 5 parsing library with support for hCard.
* [http://kitchen.technorati.com/search Technorati Microformats Search] indexes [[hcard|hCard]], [[hcalendar|hCalendar]], and [[hreview|hReview]] as [http://tantek.com/log/2006/05.html#d31t1802 announced by Tantek].
** list of pages with indexing Issues so they can be looked into as to why data is not being extracted
** suda.co.uk/contact
** multipack.co.uk
 
* [http://www.webstandards.org/action/dwtf/microformats/ Dreamweaver Extension suite] from the [http://webstandards.org/ Web Standards Project] enables the authoring of hCards from within Dreamweaver 8.
* [http://scooch.gr0w.com/ Scooch] is a slide show and presentation creator that generates a [[hCard]] for individual slide show authors and comment authors with a CSS button to parse and download via [http://suda.co.uk/projects/X2V/ X2V]. Also uses [[hReview]] for slide ratings and [[rel-tag]] for categories.
* [http://blog.codeeg.com/2006/03/20/flock-tails-flocktails/ Flocktails] - port of Tails extension for Flock 0.5.12 that looks for hCards, hCalendar, xFolk and hReview and tosses them into a handy topbar
*[http://opensource.reevoo.com/2006/03/08/release-uformats-12/ uformats] is a ruby library that can parse [[hCalendar]], [[hCard]], [[hReview]] and [[rel-tag]]
* [http://blog.codeeg.com/tails-firefox-extension-03/ Tails] is a Firefox Extension that will display the presence and details of microformats ([[hcard|hCard]], [[hcalendar|hCalendar]], [[hreview|hReview]], [[xfolk|xFolk]]) on a webpage. [https://addons.mozilla.org/firefox/2240/ Tails Export] is an extended version.
* [http://www.stripytshirt.co.uk/features/firefox/smartzilla Smartzilla is a Firefox Extension] that finds hCards on web pages and lets you add them to your addressbook.
* [http://placenamehere.com/TXP/pnh_mf/ pnh_mf] is a plugin for [http://textpattern.com/ Textpattern] that supports embedding hCard and other microformats in templates and blog posts. Written by [http://placenamehere.com/ Chris Casciano].
* There is [http://flickr.com/photos/factoryjoe/68755089/ evidence of built-in hCard support in the Konqueror browser].  Specifically, Konqueror 3.5, in KDE 3.5 (kubuntu Breezy w/ update).
* There is [http://tagcamp.org/index.cgi?ContactList evidence of a kwiki plugin for hCards].  Update: the [http://svn.kwiki.org/cwest/Kwiki-hCard/ hCard kwiki plugin svn repository].  See the [http://microwiki.caseywest.com/index.cgi?hCard documentation of the hCard kwiki plugin].
* [http://suda.co.uk/projects/X2V/ X2V] is a bookmarklet that parses hCard and produces a .vcf (vCard) stream.  Note: needs to be updated as the spec is refined
* [http://www.stripytshirt.co.uk Duncan Walker] has built [http://www.stripytshirt.co.uk/features/firefox/smartzilla a Firefox extension] that gets hCard data from a webpage, uses Brian Suda's XSL (locally) to transform it to vcard format and opens the resulting .vcf file.
* [http://george.hotelling.net/90percent/ George] has written a [http://george.hotelling.net/90percent/geekery/greasemonkey_and_microformats.php Greasemonkey user script] that detects hCards and allows users to easily add them to their address book application.  Relies on the X2V web service to do the conversion.
* [http://inside.glnetworks.de/ Martin Rehfeld] has updated the work of [http://blogmatrix.blogmatrix.com/ David Janes] and produced a [[Greasemonkey]] [http://inside.glnetworks.de/2006/06/05/microformats-have-arrived-in-firefox-15-greasemonkey-06/ script] that finds many microformat elements, including hCards, and [http://blog.davidjanes.com/mtarchives/2005_08.html#003379 provides a popup menu of actions]. The hCard to vCard conversion is done internally within the script. ''This will work with FireFox 1.5+/GreaseMonkey 0.6.4+ now.''
* [http://diveintomark.org/ Mark Pilgrim] has also written an [http://diveintomark.org/projects/greasemonkey/hcard/ hCard parser Greasemonkey user script].  It is self-contained and does not rely on the X2V web service.
* [http://www.oliverbrown.me.uk/2005/09/03/a-working-microformats-extension-to-simplexml/ Oliver Brown] has written an "extension" to [http://www.php.net/simplexml SimpleXML] that gives simple access to hCard information in PHP 5.
* [http://thedredge.org/ Andrew D. Hume] has built a system (Wordpress plugin?) for [http://thedredge.org/2005/06/using-hcards-in-your-blog/ using hcards in your blog] to represent people leaving comments on blog posts.
* The [http://tantek.com/microformats/hcard-creator.html hCard creator] is a very simple, yet illustrative, open source user interface / form / script which creates an hCard in real-time as you type in a set of contact information.
* [http://greenbytes.de/tech/webdav/rfc2629.xslt rfc2629.xslt] now attempts to generate hCard information ([http://ietf.org/rfc/rfc2629 RFC2629] is an XML format for authoring RFCs and Internet Drafts, see [http://greenbytes.de/tech/webdav/rfc2629xslt/rfc2629xslt.html example document])
* [http://tantek.com/microformats/buddylist2hcards.html iChat buddy list to hCards] - Open source AppleScript to automatically convert one's buddy list in the MacOSX iChat AIM client into a valid XHTML 1.0 Strict list of hCards.
* [http://dev.w3.org/cvsweb/2001/palmagent/ palmagent] is a collection of palmpilot and sidekick tools. It includes X2V derivatives xhtml2hcard.xsl and toICal.xsl plus some [http://dev.w3.org/cvsweb/2001/palmagent/hcardTest.html hcardTest] materials
* [http://www.openpsa.org/ OpenPsa 2.x] CRM application uses hCard for all person listings. The widget is [http://www.midgard-project.org/midcom-permalink-922834501b71daad856f35ec593c7a6d reusable across Midgard CMS]
* [http://www.metonymie.com Emiliano Martínez Luque] has written an experimental [http://www.metonymie.com/hCard_extract/app.html hCard finder and structured search application] that finds hCards within a given set of URLs and returns the ones that match the specified search criteria.
* [http://randomchaos.com/microformats/base/ Microformat Base] is an open-source PHP microformat aggregation crawler, currently recognizing hreview, hcalendar, and hcard.
 
== Additional Applications ==
This section is '''informative'''.
 
There are numerous potential additional uses and applications for hCards on the Web.  The following are merely a few thoughts and possibilities that folks have come up with:
 
* As an open standard/format for [http://www.gravatar.com/ Gravatars].
* Marking up individual authors of blog posts on a group blog
* Marking up people's names and URLs in a blogroll
* Any reference to people in blog posts (e.g. when citing them, or referencing them, or describing them, by name).
* ...


== References ==
== References ==
Line 329: Line 279:
* [[hcard-examples-in-wild]] - an on-going list of pages which use hCards.
* [[hcard-examples-in-wild]] - an on-going list of pages which use hCards.
* [[hcard-faq|hCard FAQ]] - If you have any questions about hCard, check here, and if you don't find answers, add your questions!
* [[hcard-faq|hCard FAQ]] - If you have any questions about hCard, check here, and if you don't find answers, add your questions!
* [[hcard-implementations]] - websites or tools which either generate or parse hCards.
* [[hcard-parsing|hCard parsing]] - Normatively details of how to parse hCards.
* [[hcard-parsing|hCard parsing]] - Normatively details of how to parse hCards.
* [[hcard-issues|hCard issues]] - Please add any specific issues with the specification to the issues page.
* [[hcard-issues|hCard issues]] - Please add any specific issues with the specification to the issues page.

Revision as of 23:01, 23 November 2006

hCard

hCard is a simple, open, distributed format for representing people, companies, organizations, and places, using a 1:1 representation of the properties and values of the vCard standard (RFC2426) in semantic XHTML. hCard is one of several open microformat standards suitable for embedding in (X)HTML, Atom, RSS, and arbitrary XML.

Want to get started with writing an hCard? Use the hCard creator to write up some contact information and publish it, or follow the hCard authoring tips to add hCard markup to your current contact page.

Specification

Editor

Tantek Çelik, Technorati, Inc.

Authors

Copyright

This specification is (C) 2004-2024 by the authors. However, the authors intend to submit (or already have submitted, see details in the spec) this specification to a standards body with a liberal copyright/licensing policy such as the GMPG, IETF, and/or W3C. Anyone wishing to contribute should read their copyright principles, policies and licenses (e.g. the GMPG Principles) and agree to them, including licensing of all contributions under all required licenses (e.g. CC-by 1.0 and later), before contributing.

Patents

This specification is subject to a royalty free patent policy, e.g. per the W3C Patent Policy, and IETF RFC3667 & RFC3668.

Inspiration and Acknowledgments

Thanks to: my good friend Vadim who introduced me to vCard many years ago, and if I'd only paid more attention then, perhaps I could have helped a lot of people avoid wasting a lot of time reinventing various standards wheels.

Introduction

The vCard standard (RFC2426), has been broadly interoperably implemented (e.g. Apple's "Address Book" application built into MacOSX).

In addition, many bloggers identify themselves by name and discuss their friends and family. With just a tad bit of structure, bloggers can discuss people in their blog(s) in such a way that spiders and other aggregators can retrieve this information, automatically convert them to vCards, and use them in any vCard application or service.

This specification introduces the hCard format, which uses a 1:1 representation of the properties and values of the aforementioned vCard standard, in semantic XHTML. Bloggers can both embed hCards directly in their web pages, and style them with CSS to make them appear as desired. In addition, hCard enables applications to retrieve information directly from web pages without having to reference a separate file.

Use the hCard creator and copy the HTML code it generates to your blog or website to publish your contact info.

Semantic XHTML Design Principles

Note: the Semantic XHTML Design Principles were written primarily within the context of developing hCard and hCalendar, thus it may be easier to understand these principles in the context of the hCard design methodology (i.e. read that first). Tantek

XHTML is built on XML, and thus XHTML based formats can be used not only for convenient display presentation, but also for general purpose data exchange. In many ways, XHTML based formats exemplify the best of both HTML and XML worlds. However, when building XHTML based formats, it helps to have a guiding set of principles.

  1. Reuse the schema (names, objects, properties, values, types, hierarchies, constraints) as much as possible from pre-existing, established, well-supported standards by reference. Avoid restating constraints expressed in the source standard. Informative mentions are ok.
    1. For types with multiple components, use nested elements with class names equivalent to the names of the components.
    2. Plural components are made singular, and thus multiple nested elements are used to represent multiple text values that are comma-delimited.
  2. Use the most accurately precise semantic XHTML building block for each object etc.
  3. Otherwise use a generic structural element (e.g. <span> or <div>), or the appropriate contextual element (e.g. an <li> inside a <ul> or <ol>).
  4. Use class names based on names from the original schema, unless the semantic XHTML building block precisely represents that part of the original schema. If names in the source schema are case-insensitive, then use an all lowercase equivalent. Components names implicit in prose (rather than explicit in the defined schema) should also use lowercase equivalents for ease of use. Spaces in component names become dash '-' characters.
  5. Finally, if the format of the data according to the original schema is too long and/or not human-friendly, use <abbr> instead of a generic structural element, and place the literal data into the 'title' attribute (where abbr expansions go), and the more brief and human readable equivalent into the element itself. Further informative explanation of this use of <abbr>: Human vs. ISO8601 dates problem solved

Format

In General

The vCard standard (RFC2426) forms the basis of hCard.

The basic format of hCard is to use vCard object/property names in lower-case for class names, and to map the nesting of vCard objects directly into nested XHTML elements.

More Semantic Equivalents

For some properties there are HTML elements which better match and convey their semantics. The following properties SHOULD be encoded with the following (X)HTML:

  • URL in vCard becomes <a class="url" href="...">...</a> inside the element with class="vcard" in hCard.
  • Similarly, EMAIL in vCard becomes <a class="email" href="mailto:...">...</a>
  • PHOTO in vCard becomes <img class="photo" src="..." alt="Photo of ..." /> or <object class="photo" data="..." type="...">Photo of ...</object>
  • UID in vCard simply becomes another semantic applied to a specific URL (or EMAIL) for an hCard.

Singular vs. Plural Properties

For properties which are singular (e.g. "N" and "FN"), the first descendant element with that class should take effect, any others being ignored.

For properties which can be plural (e.g. "TEL"), each class instance should create a instance of that property.

Singular properties

Singular properties: "FN", "N", "BDAY", "TZ", "GEO", "SORT-STRING", "UID", "CLASS".

All other properties are plural. This list has been derived by analyzing the semantics of the individual properties in vCard RFC2426 and determining logically that they MUST be singular per their semantics. See hcard-singular-properties for explanations.

Plural Properties Singularized

Since plural property names become their singular equivalents, even if the original plural property permitted only a single value with multiple components, those multiple components are represented each with their own singularly named property and the the property is effectively multivalued and subject to the above treatment of multivalued properties.

Human vs. Machine readable

If an <abbr> element is used for a property, then the 'title' attribute of the <abbr> element is the value of the property, instead of the contents of the element, which instead provide a human presentable version of the value.

If an <a> element is used for one or more properties, it must be treated as follows:

  1. For the "PHOTO" property and any other property that takes a URL as its value, the href="..." attribute provides the property value.
  2. For other properties, the element's content is the value of the property.

If an <img> element is used for one or more properties, it must be treated as follows:

  1. For the "PHOTO" property and any other property that takes a URL as its value, the src="..." attribute provides the property value.
  2. For other properties, the <img> element's 'alt' attribute is the value of the property.

If an <object> element is used for one or more properties, it must be treated as follows:

  1. For the "PHOTO" property and any other property that takes a URL as its value, the data="..." attribute provides the property value.
  2. For other properties, the element's content is the value of the property.

Value excerpting

Sometimes only part of an element which is the equivalent for a property should be used for the value of the property. This typically occurs when a property has a subtype, like TEL. For this purpose, the special class name "value" is introduced to excerpt out the subset of the element that is the value of the property. E.g. here is an hCard fragment for marking up a home phone number:

vCard:

TEL;TYPE=HOME:+1.415.555.1212

hCard:

<span class="tel">
 <span class="type">home</span>:
 <span class="value">+1.415.555.1212</span>
</span>

This hCard fragment could be displayed as:

home: +1.415.555.1212

Property Exceptions

vCard has several properties which either do not make sense on, or are already implied within the context of a web page. This section explains what to (not) do with them.

  1. NAME, PROFILE, SOURCE, PRODID, VERSION properties as defined in Sections 2.1.2, 2.1.3, 2.1.4, 3.6.3, 3.6.9 of RFC 2426. Content publishers MUST NOT use these properties in their hCards, and as such, hCard consumers/parsers MUST IGNORE these properties if they are found within an hCard. Instead. hCard to vCard converters SHOULD use the title of the page where the hCard is found (e.g. the <title> element in (X)HTML documents) to construct the NAME property, MAY output a PROFILE value of "VCARD" per RFC 2426, SHOULD use the URL of the page where the hCard is found to construct the SOURCE property (e.g. perhaps as a parameter to a URL/service that converts hCards to vCards), for an output vCard stream (e.g. a .vcf file). Only services/applications that output actual vCards should write the PRODID property, with the product identifier for said service/application. Similarly only such services/applications should write the VERSION property, with the value "3.0" (without quotes) per RFC2426 Section 3.6.9.

Organization Contact Info

If the "FN" and "ORG" properties have the exact same value (typically because they are set on the same element, e.g. class="fn org"), then the hCard represents contact information for a company or organization and should be treated as such. In this case the author MUST also NOT set the "N" property, or set it (and any sub-properties) explicitly to the empty string "". Thus parsers should handle the missing "N" property in this case by implying empty values for all the "N" sub-properties.

Implied "n" Optimization

Although vCard requires that the "N" property be present, the authors of the vCard specification (RFC 2426) themselves do not include "N" properties in their vCards near the end of the spec (p.38). This apparent contradiction can be resolved by simply allowing the "FN" property to imply "N" property values in typical cases provided in the spec. We do so explicitly in hCard.

If "FN" and "ORG" are not the same (see previous section), and the value of the "FN" property is exactly two words (separated by whitespace), and there is no explicit "N" property, then the "N" property is inferred from the "FN" property. For "FN"s with either one word see below, and for three or more, the author MUST explicitly markup the "N", except for the organization contact info case, see above for that.

  1. The content of "FN" is broken into two "words" separated by whitespace.
  2. The first word of the "FN" is interpreted as the "given-name" for the "N" property.
  3. The second/last word of the "FN" is interpreted as the "family-name" for the "N" property.
  4. Exception: If the first word ends in a "," comma OR if the second word is a single character (optionally followed by a period "."), then the first word (minus the comma at the end if any) is interpreted as the "family-name" and the second word is interpreted as the "given-name".

This allows simplification in the typical case of people stating:

  • given-name (space) family-name
  • family-name (comma) given-name
  • family-name (comma) given-name-first-initial
  • family-name (space) given-name-first-initial (optional period)

Implied "nickname" Optimization

Due to the prevalence of the use of nicknames/handles/usernames on the Web in actual content published on the Web (e.g. authors of reviews), hCard also has an implied "nickname" optimization to handle this.

Similar to the implied "n" optimization, if "FN" and "ORG" are not the same, and the value of the "FN" property is exactly one word, and there is no explicit "N" property, then:

  1. The content of the "FN" is treated as a "nickname" property value.
  2. Parsers should handle the missing "N" property by implying empty values for all the "N" sub-properties.

Note: the hCard may have additional explicit "nickname" property values in addition to the implied nickname.

Implied "organization-name" Optimization

The "ORG" property has two subproperties, organization-name and organization-unit. Very often authors only publish the organization-name. Thus if an "ORG" property has no "organization-name" inside it, then its entire contents MUST be treated as the "organization-name".

Tags as Categories

Categories in hCard can optionally be represented by tags with rel-tag. When a category property is a rel-tag, the tag (as defined by rel-tag) is used for that category.

Root Class Name

The root class name for an hCard is "vcard".

Property List

This is the list of properties (and subproperties, in parentheses, like this) in hCard, taken from vCard:

  • fn, n (family-name, given-name, additional-name, honorific-prefix, honorific-suffix), nickname, sort-string
  • url, email (type, value), tel (type, value)
  • adr (post-office-box, extended-address, street-address, locality, region, postal-code, country-name, type, value), label
  • geo (latitude, longitude), tz
  • photo, logo, sound, bday
  • title, role, org (organization-name, organization-unit)
  • category, note
  • class, key, mailer, uid, rev

type subproperty values

The 'type' subproperty in particular takes different values depending on which property it is a subproperty of. These 'type' subproperty values are case-INSENSITIVE, meaning "Home" is the same as "home", as well as multivalued, e.g. a tel can be home and preferred:

vCard:

TEL;TYPE=HOME,PREF:+1.415.555.1212

hCard:

<span class="tel"><span class="type">Home</span> (<span class="type">pref</span>erred):
 <span class="value">+1.415.555.1212</span>
</span>

This could be displayed as:

Home (preferred): +1.415.555.1212

The following lists are informative. See RFC 2426 sections 3.2.1 ADR, 3.3.1 TEL, and 3.3.2 EMAIL respectively for normative type values. They are repeated here for convenience. Default type subproperty value(s) is(are) first in each list and indicated in ALL CAPS. types may be multivalued.

  • adr type: INTL, POSTAL, PARCEL, WORK, dom, home, pref
  • tel type: VOICE, home, msg, work, pref, fax, cell, video, pager, bbs, modem, car, isdn, pcs
  • email type: INTERNET, x400, pref, "other IANA registered address types"

XMDP Profile

See hcard-profile for the XMDP profile of hCard which contains the above complete list of properties, with references to their RFC 2426 definitions.

Parsing Details

See hCard parsing.

Examples

This section is informative.

Sample vCard

Here is a sample vCard:

BEGIN:VCARD
VERSION:3.0
N:Çelik;Tantek
FN:Tantek Çelik
URL:http://tantek.com/
ORG:Technorati
END:VCARD

and an equivalent in hCard with various elements optimized appropriately. See hCard Example 1 for the derivation.

<div class="vcard">
 <a class="url fn" href="http://tantek.com/">Tantek Çelik</a>
 <div class="org">Technorati</div>
</div>

This hCard might be displayed as:

Tantek Çelik
Technorati

Note: The version information is unnecessary in hCard markup directly since the version will be defined by the profile of hCard that is used/referred to in the 'profile' attribute of the <head> element.

More Examples

References

Normative References

Informative References

Specifications That Use hCard

Similar Work

Related Pages

This specification is a work in progress. As additional aspects are discussed, understood, and written, they will be added. These thoughts, issues, and questions are kept in separate pages.

  • hCard Brainstorming - where we are keeping our brainstorms and other explorations relating to hCard
  • hCard tests - a wiki page with actual embedded hCards to try parsing.

Further Reading