1.簡介
Atom Syndication Format中文翻譯作Atom聯合格式,是一種基於XML用來對網站內容做格式化的規範,與RSS一樣可作為Feed讓閱讀器能更新資料等功能。
完整的規範可以在此網站查到 http://www.atomenabled.org/developers/syndication/atom-format-spec.php,本文以表格的方式整理說明。
Atom 1.0版命名空間為http://www.w3.org/2005/Atom,RFC 4287標準
MIME Type(Content Type或稱為Media Type)為application/atom+xml
2. 結構與定義
2.1 基本資料型態
2.1-1 atomTextConstruct
資料型態為atomTextConstruct的Element定義以下屬性
Attribute | 必要 | 說明 |
---|---|---|
type | X | 類型 |
Element內容依據type不同變化,規則如下:
- text: 純文字,不可有子節點
- html: HTML格式的純文字,不可有子節點
- xhtml: XHTML之節點內容,以<xhtml:div>起始
2.1-2 atomDateConstruct
[RFC3339]標準,也可以是符合[ISO.8601.1988]、[W3C.NOTE-datetime-19980827]或[W3C.REC-xmlschema-2-20041028]之日期格式,例如:
<updated>2003-12-13T18:30:02Z</updated> <updated>2003-12-13T18:30:02.25Z</updated> <updated>2003-12-13T18:30:02+01:00</updated> <updated>2003-12-13T18:30:02.25+01:00</updated>
2.1-3 atomPersonConstruct
資料型態為atomPersonConstruct的Element定義以下屬性
Element | 必要 | 多筆 | 說明 |
---|---|---|---|
name | O | X | 名稱 |
uri | X | X | IRI |
X | X | 電子郵件 |
2.2 文件
Atom的XML起始根節點可以是<feed>或<entry>兩種Element,一般而言,主要是從<feed>開始取得包含<entry>的各種資訊,但有時候<feed>中的<entry>只有摘要部分資訊,必須進一步連結至<entry>的完整資訊路徑,此時<entry>就會是根節點。
2.3 元素
2.3-1 <feed>
<feed>包含一些Metadata和一些資料的關連,<feed>之中定義了以下Element
Element | 必要 | 多筆 | 資料型態 | 說明 |
---|---|---|---|---|
<author> | Δ | O | atomPersonConstruct | 作者,<feed>必須要包含至少一個<author>,除非之下的所有<entry>都有包含<author> |
<category> | X | O | <category> | 分類 |
<contributor> | X | O | atomPersonConstruct | 貢獻者 |
<generator> | X | X | <generator> | 產生者 |
<icon> | X | X | 純文字 | 圖示,寬高比應該為1:1 |
<id> | O | X | 純文字 | 唯一識別ID |
<link> | X | O | <link> | 連結,<feed>應該包含一個連結指向自己(ref="self") |
<logo> | X | X | 純文字 | 圖示,寬高比應該為2:1 |
<rights> | X | X | atomTextConstruct | 版權資訊 |
<subtitle> | X | X | atomTextConstruct | 副標題 |
<title> | O | X | atomTextConstruct | 標題 |
<updated> | O | X | atomDateConstruct | 最後更新時間 |
<entry> | X | O | <entry> | 包含的項目 |
2.2-2 <entry>
<entry>描述主要的資料內容,<entry>之中定義了以下Element
Element | 必要 | 多筆 | 資料型態 | 說明 |
---|---|---|---|---|
<author> | Δ | O | atomPersonConstruct | 作者,<entry>必須要包含至少一個<author>,除非之下的<source>或者此<feed>有包含<author> |
<category> | X | O | <category> | 分類 |
<content> | X | X | <content> | 內容 |
<contributor> | X | O | atomPersonConstruct | 貢獻者 |
<id> | O | X | 純文字 | 唯一識別ID,可以有相同ID的<entry>,但更新時間必須不同,表示不同版本 |
<link> | X | O | <link> | 連結,如果沒有<content>就必須包含一個連結(ref="alternate"),且多個具有ref="alternate"的連結,type和hreflang的屬性不能都相同 |
<published> | X | X | atomDateConstruct | 發布時間 |
<rights> | X | X | atomTextConstruct | 版權資訊 |
<source> | X | X | <source> | 資料來源,當資料來源是從別的<feed>拷貝過來時,應用此Element提供原始<feed>資訊 |
<summary> | Δ | X | atomTextConstruct | 摘要,如果<content>是外部資源(具有src屬性)或內容是Base64編碼時,必須要有<summary> |
<title> | O | X | atomTextConstruct | 標題 |
<updated> | O | X | atomDateConstruct | 最後更新時間 |
2.2-3 <content>
<content>描述<entry>的內容,<content>之中定義了以下屬性
Attribute | 必要 | 說明 |
---|---|---|
type | X | 類型,無設定時,預設為text |
src | X | 外部連結 |
非外部連結時(無src屬性),Element內容依據不同type規則如下:
- text、html和xhtml時,如同atomTextConstruct用法
- text/開頭時,不能有子節點
- /xml或+xml結尾時,只能有一個子節點作為起始
- 其他類型時,必須用Base64編碼
外部連結時(有src屬性),應有type屬性,且Element內容應為空
2.2-4 <category>
<category>描述<entry>、<feed>或<source>的分類,<category>之中定義了以下屬性
Attribute | 必要 | 說明 |
---|---|---|
term | O | 識別ID |
scheme | X | IRI |
label | X | 讓人閱讀的顯示文字 |
Element內容為空
2.2-5 <generator>
<generator>描述<feed>或<source>的產生者,<generator>之中定義了以下屬性
Attribute | 必要 | 說明 |
---|---|---|
uri | X | IRI |
version | X | 版本 |
Element內容為產生者名稱之純文字
2.2-6 <link>
<link>描述<entry>、<feed>或<source>的連結,<link>之中定義了以下屬性
Attribute | 必要 | 說明 |
---|---|---|
href | O | IRI |
rel | X | 關聯類型,無設定時,預設為alternate。格式應符合isegment-nz-nc或IRI且不包含空白。另外,關聯定義可參考RFC 5988,在Atom中特別定義其中5個項目: alternate: 目前資源別種顯示方式(例如搭配hreflang為其他語言版本) related: 相關資源 self: 目前資源 enclosure: 相關資源,但資料內容較大 via: 資源由何處提供 |
type | X | 類型 |
hreflang | X | 語系 |
title | X | 標題 |
length | X | 連結內容的大小,當rel為enclosure時,應該要有此屬性 |
Element內容為空
2.2-7 <source>
<source>基本上和<feed>一模一樣,除了不包含<entry>,<source>之中定義了以下Element
Element | 必要 | 多筆 | 資料型態 | 說明 |
---|---|---|---|---|
<author> | X | O | <author> | 作者 |
<category> | X | O | <category> | 分類 |
<contributor> | X | O | <contributor> | 貢獻者 |
<generator> | X | X | <generator> | 產生者 |
<icon> | X | X | 純文字 | 圖示,寬高比應該為1:1 |
<id> | X | X | 純文字 | 唯一識別ID,應該要有 |
<link> | X | O | <link> | 連結 |
<logo> | X | X | 純文字 | 圖示,寬高比應該為2:1 |
<rights> | X | X | atomTextConstruct | 版權資訊 |
<subtitle> | X | X | atomTextConstruct | 副標題 |
<title> | X | X | atomTextConstruct | 標題,應該要有 |
<updated> | X | X | atomDateConstruct | 最後更新時間,應該要有 |