微格式Microformats

微格式 (有时缩写为μF)是HTML标记某些实体的小模式,这些实体包括人、组织、事件、地点、博客、产品、评论、简历、食谱等。它们是在HTML中嵌套语义的简单协议,且能迅速地提供一套可被搜索引擎,聚合器等其他工具使用的API。

除了hCard和hCalendar,有好几个库特别开发了微格式。

主要的搜索引擎都支持微格式。

Microformats, microdata and RDFa

Microdata属于WHATWG(网页超文本应用技术工作小组:Web Hypertext Application Technology Working ) HTML 规范,这也用于将元数据嵌套在现有的网页内容中。
RDFa是W3C标准,用于将RDF应用于网页。

虽然hCard和hCalendar惯例被广泛使用,但是微格式并不是标准。

RDFa的本质就是提供一些属性,载有后设资料的这些属性可以被用在XML文件上(也就是RDFa的a的来源 - Attributes)。

Some microformats examples

Adr microformat

adr微格式表示地址,物理位置或邮寄地址。

Properties

属性的值除了特别声明外,一般为string or undefined

Property Description
type

The type of address. The value is either undefined or a non-empty array where each element is one of the following strings.

work
A work address.
home
A home address.
pref
A preferred address; use this to indicate that a specific address is the preferred address for the person or company it's associated with.
postal
A mailing address.
dom
A domestic address.
intl
An international address.
parcel
An address for shipping packages and parcels.
post-office-box The post office box number, if there is one.
street-address The street address or addresses. The value is either undefined or a non-empty array where each element is a string.
extended-address The extended address.
locality The locality for the address.
region The region for the address.
postal-code The postal or ZIP code for the address.
country-name The name of the country in which the address is located.

Methods

toString()

返回地址字符串

Geo microformat

地理微格式表示地球上使用纬度和经度坐标的物理位置。

Properties

如果一个属性没有被标记为必须,则其值可以为undefined

Property Description
latitude The latitude of the geographic location, represented as a floating-point number. Required.
longitude The longitude of the geographic location, represented as a floating-point number. Required.

Methods

toString()

返回位置字符串

geoString = geo.toString();

hCalendar microformat

hCalendar microformat表示日历上的事件

类名为vevent. 有2个必须的属性: summary 和dtstart.

Properties

属性的值除了特别声明外,一般为string,如果一个属性没有被标记为必须,则其值可以为undefined

Tip: The function Microformats.dateFromISO8601 takes a normalized ISO 8601 date as its first parameter and returns the corresponding date.
Property Description
category Zero or more categories with which the event is associated. If a category is also a tag microformat, its "tag" property is used. The value is either undefined or a non-empty array where each element is a string.
class The classification of the event. This is one of public, private, or confidential.
description An description of the event, using HTML. The value is some kind of object.
dtstart The date and time at which the event begins, normalized to an ISO8601 date. Required.
dtend The date and time at which the event ends, normalized to an ISO8601 date.
dtstamp The date and time at which the calendar entry was created, normalized to an ISO8601 date.
duration The length of the event. This can be things such as "1w" for one week, or "1h" for one hour. See the description in RFC 2445 for details.
geo A physical location associated with the event. The value is a geo microformat where none of the properties are required.
location A location at which the event is to take place. The value is either a string or an hCard microformat where none of the properties are required.
status The status of the event. This can be one of tentative, confirmed, cancelled.
summary A brief description of the event. Required.
transp Specifies whether or not the event should be ignored when searching for openings in the user's calendar. If this value is transparent, the time occupied by this event is considered to be free when looking for openings in the calendar. If the value is opaque, the time occupied is considered unavailable for assignment.
uid A unique ID for the event.
url A URL associated with the event.
last-modified The date and time at which the event was last modified, normalized to an ISO8601 date.
rrule Specifies recurrence rules for the event. See RFC 2445 for details. I am not sure what the type of the value is. Reading may throw an exception.

hCard microformat

hCard微格式将联系人在数据库中的条目描述为虚拟名片。

Properties

T属性的值除了特别声明外,一般为string,如果一个属性没有被标记为必须,则其值可以为undefined。如果属性标记为复数,则该值为 undefined或非空数组。 数组中的每个元素都是一个字符串,除非有特别指定。 email,n,org和tel属性的值未完全记录。

Property Description
adr The contact's address. Plural. Each element is an adr microformat where none of the properties are required.
agent People who act as agents on behalf of the contact. Plural. Each element is either a string or an hCard microformat where none of the properties are required.
bday The contact's birthdate.
class A class for the contact.
category Category with which the contact is associated. If a category is also a tag microformat, its "tag" property is used. Plural.
email Zero or more email addresses for the contact. Each email address entry includes two subproperties, both of which are plural:
type
This can be one or more of internet, x400, or pref. The pref type indicates the preferred email address.
value
One or more email addresses associated with the specified type.
fn The contact's full name. Required.
geo The contact's physical location. The value is a geo microformat where none of the properties are required.
key The contact's public key, for exchanging encrypted data with the contact. Plural.
label Formatted text providing an address label for the contact. Plural.
logo Optional URI to a graphic image of a logo for the contact; this can be used for a company logo, for example. Plural.
mailer The type of email software used by the contact. Plural.
n The contact's name. This has the following subproperties:
honorific-prefix
Zero or more honorifics to prepend to the name. For example, ["Mr."], or ["Honorable", "Governor"].
given-name
The contact's given name.
additional-name
An additional name, such as the middle name.
family-name
The contact's family name.
honorific-suffix
Zero or more honorifics to append to the name.

The n property is normally required, but since Mozilla's implementation offers an implied n optimization, it is optional, and will be parsed from the fn property if not specifically provided.

nickname Nickname for the contact. Plural.
note HTML note with additional information about the contact. Plural. Each element is some kind of object.
org The organization with which the contact is associated. This includes the following subproperties:
organization-name
The name of the organization with which the contact is associated.
organization-unit
The name of the division or department within the organization with which the contact is associated.
photo URI providing a photograph of the contact. Plural.
rev The date and time at which the contact was last revised.
role Role which the contact fills within his or her organization. Plural.
sequence A revision number for the contact. Each time the contact is revised, this number should be incremented, if this property is used at all. (The value is a string)
sort-string If provided, this string is used instead of the fn or n property to determine the sort order for the card. This can be useful in cases where the locale of the contact's name has different sorting rules than other names in the user's contact database.
sound URI specifying a sound file associated with the contact. Plural.
title Job title for the contact. Plural.
tel The contact's telephone number. Plural. Each element has the following subproperties:
type
The type of phone number. Can be one or more of the following: msg, home, work, pref, voice, fax, cell, video, pager, bbs, car, isdn, pcs.
tel
The telephone number, specified using the tel datatype.
tz The contact's time zone.
uid A unique UID for this contact.
url URL associated with the contact. Plural.

Tag microformat

tag微格式用于向其他微格式添加标签。

Properties

The value of each property is a string.

Property Description
tag The name of the tag. This is the text after the last forward slash in the link. Required.
link A URL associated with the tag. Required.
text The text associated with the tag. Required.

Methods

toString()

返回tag字符串

See also

文档标签和贡献者

 此页面的贡献者: zodiac-xl
 最后编辑者: zodiac-xl,