hcard-zh: Difference between revisions

From Microformats Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 137: Line 137:
vCard有幾個特性不是沒有意義的,就是已經隱含在網頁中的上下文,這一節會說明如何(不)處理他們。
vCard有幾個特性不是沒有意義的,就是已經隱含在網頁中的上下文,這一節會說明如何(不)處理他們。


# vCard的'''NAME'''、'''PROFILE'''、'''SOURCE'''、'''PRODID'''、'''VERSION'''特性定義在[[rfc-2426|RFC2426]]的2.1.2、2.1.3、2.1.4、3.6.3、3.6.9等小節,內容發佈者''不得''使用這些特性在他們的hCard裡,因此,hCard用戶/剖析器{{必須}} 忽略這些特性假如在hCard中有發現這些特性的話,相反地,hCard到vCard的轉換器{{應該}}使用hCard被找到的頁面title(例如,HTML文件中的<code><title></code>元素)來建構NAME特性,''可能''由[[rfc-2426|RFC2426]]輸出一個"<code>VCARD</code>"的PROFILE值,{{應該}}使用hCard被找到的頁面URL來建構SOURCE特性(例如可能是一個參數轉換hCard到VCard的URL/服務),對一個輸出的vCard串流來說(例如一個.vcf檔),只有輸出真正的cVard的服務/應用程式應該寫PRODID特性,就上述的服務/應用程式的產品識別器來說,同樣地,只有這樣的服務/應用程式應該寫VERSION特性,由[[rfc-2426|RFC2426]]的3.6.9節的"3.0"值 (沒有引號)。
# vCard的'''NAME'''、'''PROFILE'''、'''SOURCE'''、'''PRODID'''、'''VERSION'''特性定義在[[rfc-2426|RFC2426]]的2.1.2、2.1.3、2.1.4、3.6.3、3.6.9等小節,內容發佈者''不得''使用這些特性在他們的hCard裡,因此,hCard用戶/剖析器{{必須}} 忽略這些特性假如在hCard中有發現這些特性的話,相反地,hCard到vCard的轉換器''應該''使用hCard被找到的頁面title(例如,HTML文件中的<code><title></code>元素)來建構NAME特性,''可能''由[[rfc-2426|RFC2426]]輸出一個"<code>VCARD</code>"的PROFILE值,''應該''使用hCard被找到的頁面URL來建構SOURCE特性(例如可能是一個參數轉換hCard到VCard的URL/服務),對一個輸出的vCard串流來說(例如一個.vcf檔),只有輸出真正的cVard的服務/應用程式應該寫PRODID特性,就上述的服務/應用程式的產品識別器來說,同樣地,只有這樣的服務/應用程式應該寫VERSION特性,由[[rfc-2426|RFC2426]]的3.6.9節的"3.0"值 (沒有引號)。


=== 組織機構的聯繫方式 ===
=== 組織機構的聯繫方式 ===
假如"FN"及"ORG" (organization)特性有完全相同的值(通常是因為他們設為想同的元素,如class="fn org"),那麼hCard表示公司、組織霍地方的資訊{{應該}}這樣來處理,在這個例子中作者也{{不得}}設定"N"特性,或明確地設成(以及任何的子特性)空字串"",因此剖析器{{應該}}處理這個錯誤的"N"特性,在這個例子中可以藉由隱藏所有"N"的子特性的空值來完成。
假如"FN"及"ORG" (organization)特性有完全相同的值(通常是因為他們設為想同的元素,如class="fn org"),那麼hCard表示公司、組織霍地方的資訊''應該''這樣來處理,在這個例子中作者也{{不得}}設定"N"特性,或明確地設成(以及任何的子特性)空字串"",因此剖析器''應該''處理這個錯誤的"N"特性,在這個例子中可以藉由隱藏所有"N"的子特性的空值來完成。


=== 隱藏的"n"最佳化 ===
=== 隱藏的"n"最佳化 ===
雖然vCard需要"N"特性存在,在vCard規格([[rfc-2426|RFC2426]])靠近尾端(p.38)那邊他們自己的authors卻不包含"N"特性在他們的vCard裡,這種明顯的矛盾可以在規格提供的一般案例裡只要允許"FN"特性暗指"N"特性值就可解決,我們可以明確地在hCard裡這樣做。
雖然vCard需要"N"特性存在,在vCard規格([[rfc-2426|RFC2426]])靠近尾端(p.38)那邊他們自己的authors卻不包含"N"特性在他們的vCard裡,這種明顯的矛盾可以在規格提供的一般案例裡只要允許"FN"特性暗指"N"特性值就可解決,我們可以明確地在hCard裡這樣做。


假如"FN"跟"ORG"不相同(見前一節),而且"FN"特性的值剛好是兩個字(空白字元分隔),沒有明顯的"N"特性,那麼"N"特性可以由"FN"特性來推測,對於任意字的"FN"見下面,三個或以上的,author {{必須}}明確標記"N",除了組織機構的聯繫方式例子,[http://microformats.org/wiki/hcard-zh#Organization_Contact_Info 詳見前述]。
假如"FN"跟"ORG"不相同(見前一節),而且"FN"特性的值剛好是兩個字(空白字元分隔),沒有明顯的"N"特性,那麼"N"特性可以由"FN"特性來推測,對於任意字的"FN"見下面,三個或以上的,author {{必須}}明確標記"N",除了組織機構的聯繫方式例子,[http://microformats.org/wiki/hcard-zh#組織機構的聯繫方式 詳見前述]。


# The content of "FN" is broken into two "words" separated by whitespace.
# The content of "FN" is broken into two "words" separated by whitespace.

Revision as of 07:13, 18 May 2010

<entry-title>hCard 1.0</entry-title> hCard是一種用來表現人、公司、組織及地點的簡單、開放、分佈式的格式,它在語義的HTML或XHTML使用vCard (RFC2426)以1:1實現,hCard是幾個適合嵌入HTML、XHTML、Atom、RSS跟任意的XML文件的開放標準之一。

想要開始寫一個hCard嗎? 使用hCard產生器來寫一些聯絡資料然後發佈,或是照著hCard創作技巧來新增hCard標記到你目前的聯絡頁面。

編輯
Tantek Çelik (http://tantek.com/,之前在Technorati, Inc.服務,現在於Microsoft Corporation服務)
作者:Tantek Çelik (背景同上)
Brian Suda (http://suda.co.uk/)
致謝: 見 致謝

版權專利聲明的申請。

狀態

hCard 1.0是一個microformats.org的規格,hCard公開討論在hcard-feedback、irc.freenode.net上的#microformats irc頻道跟microformats-discuss郵件列表

可用語言

這個規格的英文版本是唯一正式的版本,文件的翻譯見翻譯這節。

錯誤及更新

這個規格已知的錯誤及問題在解決結案這裡被修正,在報告問題前請先檢查那裡。

hCard 1.0.1更新正在開發並且已知的錯誤也會結合進來修正,還有值類模式

前言

vCard標準(RFC2426),和hCard的互相操作性已廣泛地實作(例如Apple的"Address Book"應用程式已內建於MacOSX)。

此外,很多部落客會用名字來識別自己並且跟他們的朋友及家人討論,只需一點點的結構,部落客可以用這樣一種方式在他們的部落格內跟人討論,這種方式網路蜘蛛跟其他的聚合器可以取得這個資訊,並且自動地將它們轉換到vCards,然後在任何vCard的應用程式或服務使用他們。

這個規格介紹了hCard格式,hCard在語義的HTML裡使用了前面提到的vCard標準的屬性和值來1:1的實現,部落客也可以直接用內嵌的hCards在他們的網頁裡,並且用CSS來設計樣式來使他們可以如預期顯示,此外,hCard允許應用程式直接從網頁來取得訊息而不需參考一個單獨的檔案來做。

使用hCard產生器並且複製它產生的HTML原始碼到你的部落格或網站來公佈你的聯絡資訊。

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

格式

一般來說

vCard標準(RFC2426)構成了hCard基礎。

hCard的基本格式的類別名稱以小寫的vCaard物件/屬性名稱來使用,並且直接對應巢狀的vCard物件到巢狀的HTML元素裡。

根類別名稱

一個hCard的根類別名稱是"vcard",一個"vcard"類別名稱的元素就是它自己稱作hCard

屬性跟子屬性

一個hCard的屬性是由hCard內的元素來表現,有下列屬性的類別名稱的元素表現那些屬性的值,某些屬性有子屬性,並且對該屬性來說是由元素內的元素來表現。

屬性列表

hCard屬性(子屬性會像這樣括號起來)

需求:

  • fn
  • n1 (family-name, given-name, additional-name, honorific-prefix, honorific-suffix)

可選擇的:

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

屬性備註

1. ^:假如任意的隱藏的'n'最佳化規則是有效的話,'n'屬性是可選擇的
2. ^: tel - 作者可能會遵循E.123標準來書寫電話號碼的值,字母值(例 +1-555-格式) 必須轉換為數字,使用abbr來顯示字母並同時提供一個數值的值,例<abbr title="+15553676287">+1-555-格式</abbr>

單一屬性 vs 多重屬性

單一屬性:'fn', 'n', 'bday', 'tz', 'geo', 'sort-string', 'uid', 'class', 'rev',對單一屬性來說,有類別的第一代元素應該開始作用,而其他的會被忽略。

所有其他的屬性可能是多重的,像這樣屬性的每個類別實體會產生那個屬性的一個新實體。

人們可讀的 vs 機器可讀的

一個屬性元素的人類可見的文字內容表現該屬性的值,只有一些例外:

假如<abbr>元素被用作一個特性,那麼<abbr>元素的'title'屬性(如果存在的話) 就是這個特性的值,而不是元素的內容,取代的是一個更像樣的版本值。

假如一個<a>元素用於一個或多個特性,Template:必須按照下列處理:

  1. 對於把URL作為它的值的'photo'特性跟任何其它特性,href="..."屬性提供了特性值。
  2. 對其它的特性來說,元素的內容就是特性值。

假如一個<img>元素用於一個或多個特性,必須按照下列處理:

  1. 對於把URL作為它的值的'photo'特性及任何其它的特性來說,src="..."屬性提供了特性值。
  2. 對其它特性來說,<img>元素的'alt'屬性就是特性值。

假如一個<object>元素用於一個或多個特性,Template:必須按照下列處理:

  1. 對於把URL作為它的值的'photo'特性及任何其它的特性來說,data="..."屬性提供了特性值。
  2. 對其它的特性來說,元素的內容就是特性值。

值的篩選

有時候只有部份的元素有等同的特性用於特性值,這通常發生在特性有子型別,像'tel',為此,這特別的類別名稱"value"用來篩選元素子行別的特性值,例如,這裡有一個hCard片段用來標記一個家用電話號碼:

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>

hCard片段可以顯示成:

home: +1.415.555.1212


特性的例外

vCard有幾個特性不是沒有意義的,就是已經隱含在網頁中的上下文,這一節會說明如何(不)處理他們。

  1. vCard的NAMEPROFILESOURCEPRODIDVERSION特性定義在RFC2426的2.1.2、2.1.3、2.1.4、3.6.3、3.6.9等小節,內容發佈者不得使用這些特性在他們的hCard裡,因此,hCard用戶/剖析器Template:必須 忽略這些特性假如在hCard中有發現這些特性的話,相反地,hCard到vCard的轉換器應該使用hCard被找到的頁面title(例如,HTML文件中的<title>元素)來建構NAME特性,可能RFC2426輸出一個"VCARD"的PROFILE值,應該使用hCard被找到的頁面URL來建構SOURCE特性(例如可能是一個參數轉換hCard到VCard的URL/服務),對一個輸出的vCard串流來說(例如一個.vcf檔),只有輸出真正的cVard的服務/應用程式應該寫PRODID特性,就上述的服務/應用程式的產品識別器來說,同樣地,只有這樣的服務/應用程式應該寫VERSION特性,由RFC2426的3.6.9節的"3.0"值 (沒有引號)。

組織機構的聯繫方式

假如"FN"及"ORG" (organization)特性有完全相同的值(通常是因為他們設為想同的元素,如class="fn org"),那麼hCard表示公司、組織霍地方的資訊應該這樣來處理,在這個例子中作者也Template:不得設定"N"特性,或明確地設成(以及任何的子特性)空字串"",因此剖析器應該處理這個錯誤的"N"特性,在這個例子中可以藉由隱藏所有"N"的子特性的空值來完成。

隱藏的"n"最佳化

雖然vCard需要"N"特性存在,在vCard規格(RFC2426)靠近尾端(p.38)那邊他們自己的authors卻不包含"N"特性在他們的vCard裡,這種明顯的矛盾可以在規格提供的一般案例裡只要允許"FN"特性暗指"N"特性值就可解決,我們可以明確地在hCard裡這樣做。

假如"FN"跟"ORG"不相同(見前一節),而且"FN"特性的值剛好是兩個字(空白字元分隔),沒有明顯的"N"特性,那麼"N"特性可以由"FN"特性來推測,對於任意字的"FN"見下面,三個或以上的,author Template:必須明確標記"N",除了組織機構的聯繫方式例子,詳見前述

  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, then the first word (minus the comma at the end) 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

Implied "nickname" Optimization

Due to the prevalence of the use of nicknames/handles/usernames 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" MUST be treated as a "nickname" property value.
  2. Parsers SHOULD handle the missing "N" property by implying empty values for all the "N" sub-properties.

Though parsers MUST follow the implied nickname optimization, publishers SHOULD explicitly indicate the "nickname" even in this case, e.g.:

<span class="vcard">
 <span class="fn nickname">daveman692</span>
</span>

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 MAY 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.

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

type with unspecified value

When the type of a property is specified, and there is no explicit value specified, then everything in the property except for the type is considered the value of the property. E.g.

<span class="tel"><span class="type">Home</span> +1.415.555.1212</span>

is equivalent to:

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

And thus the type is "home" and the value is "+1.415.555.1212".

adr tel email types

The following lists are informative. See RFC2426 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

Profile

The hCard XMDP profile is at http://microformats.org/profile/hcard

Content that uses hCard SHOULD reference this profile, e.g.

<head profile="http://microformats.org/profile/hcard">

or

<link rel="profile" href="http://microformats.org/profile/hcard">

or

This content uses <a rel="profile" href="http://microformats.org/profile/hcard">hCard</a>.

Content may combine the above methods as well.

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/
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>

This hCard might be displayed as:

Tantek Çelik

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.

Live example

Here is Commercenet's contact details, as a live hCard which will be detected, on this page, by microformat parsing tools:

CommerceNet
http://www.commerce.net/
Work:
169 University Avenue

Palo Alto, CA  94301

USA
Work +1-650-289-4040
Fax +1-650-289-4041
Email

The mark-up, emboldening omitted for clarity, with the following semantic improvements:

  • abbr to expand abbreviations
  • hyperlinking the org name with the url
<div class="vcard">
  <a class="fn org url" href="http://www.commerce.net/">CommerceNet</a>
  <div class="adr">
    <span class="type">Work</span>:
    <div class="street-address">169 University Avenue</div>
    <span class="locality">Palo Alto</span>,  
    <abbr class="region" title="California">CA</abbr>&nbsp;&nbsp;
    <span class="postal-code">94301</span>
    <div class="country-name">USA</div>
  </div>
  <div class="tel">
   <span class="type">Work</span> +1-650-289-4040
  </div>
  <div class="tel">
    <span class="type">Fax</span> +1-650-289-4041
  </div>
  <div>Email: 
   <span class="email">info@commerce.net</span>
  </div>
</div>

More Examples

See hCard examples for more examples, including all examples from vCard RFC2426 converted into hCard.

Examples in the wild

This section is informative. The number of hCard examples in the wild has expanded far beyond the capacity of being kept inline in this specification. They have been moved to a separate page.

See hCard Examples in the wild.

Implementations

This section is informative. The number of hCard implementations has also expanded beyond the capacity of keeping them inline. They have been moved to a separate page.

See hCard Implementations.

Articles

This section is informative. For further reading on hCard see hcard-articles.

Buttons

You can use these buttons on pages with hCards. See buttons#hCard for any recent additions.

Copyright

Per the public domain release on the authors' user pages (Tantek Çelik, Brian Suda) this specification is released into the public domain.

Public Domain Contribution Requirement. Since the author(s) released this work into the public domain, in order to maintain this work's public domain status, all contributors to this page agree to release their contributions to this page to the public domain as well. Contributors may indicate their agreement by adding the public domain release template to their user page per the Voluntary Public Domain Declarations instructions. Unreleased contributions may be reverted/removed.

Patents

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

References

Normative References

Informative References

This section is informative.

Specifications That Use hCard

Similar Work

This section is informative.

Inspiration and Acknowledgments

This section is informative. 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.

Notes on derivation from vCard

This section is informative.

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 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 and Plural derivations

The lists of singular and plural properties have 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.

Related Pages

The hCard 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.

Translations

Read the hCard specification in additional languages: