RSS開發(fā)規(guī)范(英文|中文)
F E E D Validator
RSS 2.0 specification
Jump to navigationFrom: http://feedvalidator.org/docs/rss2.html?
Contents
- What is RSS?
- Sample files
- About this document
- Required channel elements
- Optional channel elements
- Elements of <item>
- Comments
- Extending RSS
- Roadmap
- Copyright and disclaimer
What is RSS?
RSS is a Web content syndication format.Its name is an acronym for Really Simple Syndication.
RSS is dialect of XML. All RSS files must conform to the XML 1.0 specification, as published on the World Wide Web Consortium (W3C) website.
At the top level, a RSS document is a <rss> element, with a mandatory attribute called version, that specifies the version of RSS that the document conforms to. If it conforms to this specification, the version attribute must be 2.0.
Subordinate to the <rss> element is a single <channel> element, which contains information about the channel (metadata) and its contents.
Sample files
Here are sample files for: RSS 0.91, 0.92 and 2.0.Note that the sample files may point to documents and services that no longer exist. The 0.91 sample was created when the 0.91 docs were written. Maintaining a trail of samples seems like a good idea.
About this document
This document represents the status of RSS as of the Fall of 2002, version 2.0.1.It incorporates all changes and additions, starting with the basic spec for RSS 0.91 (June 2000) and includes new features introduced in RSS 0.92 (December 2000) and RSS 0.94 (August 2002).
Change notes are here.
First we document the required and optional sub-elements of <channel>; and then document the sub-elements of <item>. The final sections answer frequently asked questions, and provide a roadmap for future evolution, and guidelines for extending RSS.
Required channel elements
Here's a list of the required channel elements, each with a brief description, an example, and where available, a pointer to a more complete description.Element | Description | Example |
---|---|---|
title | The name of the channel. It's how people refer to your service. If you have an HTML website that contains the same information as your RSS file, the title of your channel should be the same as the title of your website. | GoUpstate.com News Headlines |
link | The URL to the HTML website corresponding to the channel. | http://www.goupstate.com/ |
description | Phrase or sentence describing the channel. | The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site. |
Optional channel elements
Here's a list of optional channel elements.Element | Description | Example |
---|---|---|
language | The language the channel is written in. This allows aggregators to group all Italian language sites, for example, on a single page. A list of allowable values for this element, as provided by Netscape, is here. You may also use values defined by the W3C. | en-us |
copyright | Copyright notice for content in the channel. | Copyright 2002, Spartanburg Herald-Journal |
managingEditor | Email address for person responsible for editorial content. | geo@herald.com (George Matesky) |
webMaster | Email address for person responsible for technical issues relating to channel. | betty@herald.com (Betty Guernsey) |
pubDate | The publication date for the content in the channel. For example, the New York Times publishes on a daily basis, the publication date flips once every 24 hours. That's when the pubDate of the channel changes. All date-times in RSS conform to the Date and Time Specification of RFC 822, with the exception that the year may be expressed with two characters or four characters (four preferred). | Sat, 07 Sep 2002 0:00:01 GMT |
lastBuildDate | The last time the content of the channel changed. | Sat, 07 Sep 2002 9:42:31 GMT |
category | Specify one or more categories that the channel belongs to. Follows the same rules as the <item>-level category element. More info. | <category>Newspapers</category> |
generator | A string indicating the program used to generate the channel. | MightyInHouse Content System v2.3 |
docs | A URL that points to the documentation for the format used in the RSS file. It's probably a pointer to this page. It's for people who might stumble across an RSS file on a Web server 25 years from now and wonder what it is. | http://backend.userland.com/rss |
cloud | Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds. More info here. | <cloud domain="rpc.sys.com" port="80" path="/RPC2" registerProcedure="pingMe" protocol="soap"/> |
ttl | ttl stands for time to live. It's a number of minutes that indicates how long a channel can be cached before refreshing from the source. More info here. | <ttl>60</ttl> |
image | Specifies a GIF, JPEG or PNG image that can be displayed with the channel. More info here. | |
textInput | Specifies a text input box that can be displayed with the channel. More info here. | |
skipHours | A hint for aggregators telling them which hours they can skip. More info here. | |
skipDays | A hint for aggregators telling them which days they can skip. More info here. |
<image> sub-element of <channel>
<image> is an optional sub-element of <channel>, which contains three required and three optional sub-elements.<url> is the URL of a GIF, JPEG or PNG image that represents the channel.
<title> describes the image, it's used in the ALT attribute of the HTML <img> tag when the channel is rendered in HTML.
<link> is the URL of the site, when the channel is rendered, the image is a link to the site. (Note, in practice the image <title> and <link> should have the same value as the channel's <title> and <link>.
Optional elements include <width> and <height>, numbers, indicating the width and height of the image in pixels. <description> contains text that is included in the TITLE attribute of the link formed around the image in the HTML rendering.
Maximum value for width is 144, default value is 88.
Maximum value for height is 400, default value is 31.
<cloud> sub-element of <channel>
<cloud> is an optional sub-element of <channel>.It specifies a web service that supports the rssCloud interface which can be implemented in HTTP-POST, XML-RPC or SOAP 1.1.
Its purpose is to allow processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.
<cloud domain="radio.xmlstoragesystem.com" port="80" path="/RPC2" registerProcedure="xmlStorageSystem.rssPleaseNotify" protocol="xml-rpc" />
In this example, to request notification on the channel it appears in, you would send an XML-RPC message to radio.xmlstoragesystem.com on port 80, with a path of /RPC2. The procedure to call is xmlStorageSystem.rssPleaseNotify.
A full explanation of this element and the rssCloud interface is here.
<ttl> sub-element of <channel>
<ttl> is an optional sub-element of <channel>.ttl stands for time to live. It's a number of minutes that indicates how long a channel can be cached before refreshing from the source. This makes it possible for RSS sources to be managed by a file-sharing network such as Gnutella.
Example: <ttl>60</ttl>
<textInput> sub-element of <channel>
A channel may optionally contain a <textInput> sub-element, which contains four required sub-elements.<title> -- The label of the Submit button in the text input area.
<description> -- Explains the text input area.
<name> -- The name of the text object in the text input area.
<link> -- The URL of the CGI script that processes text input requests.
The purpose of the <textInput> element is something of a mystery. You can use it to specify a search engine box. Or to allow a reader to provide feedback. Most aggregators ignore it.
Elements of <item>
A channel may contain any number of <item>s. An item may represent a "story" -- much like a story in a newspaper or magazine; if so its description is a synopsis of the story, and the link points to the full story. An item may also be complete in itself, if so, the description contains the text (entity-encoded HTML is allowed), and the link and title may be omitted. All elements of an item are optional, however at least one of title or description must be present.Element | Description | Example |
---|---|---|
title | The title of the item. | Venice Film Festival Tries to Quit Sinking |
link | The URL of the item. | http://www.nytimes.com/2002/09/07/movies/07FEST.html |
description | The item synopsis. | Some of the most heated chatter at the Venice Film Festival this week was about the way that the arrival of the stars at the Palazzo del Cinema was being staged. |
author | Email address of the author of the item. More. | oprah@oxygen.net |
category | Includes the item in one or more categories. More. | Simpsons Characters |
comments | URL of a page for comments relating to the item. More. | http://www.myblog.org/cgi-local/mt/mt-comments.cgi?entry_id=290 |
enclosure | Describes a media object that is attached to the item. More. | <enclosure url="http://live.curry.com/mp3/celebritySCms.mp3" length="1069871" type="audio/mpeg"/> |
guid | A string that uniquely identifies the item. More. | <guid isPermaLink="true">http://inessential.com/2002/09/01.php#a2</guid> |
pubDate | Indicates when the item was published. More. | Sun, 19 May 2002 15:21:36 GMT |
source | The RSS channel that the item came from. More. | <source url="http://www.quotationspage.com/data/qotd.rss">Quotes of the Day</source> |
<source> sub-element of <item>
<source> is an optional sub-element of <item>.Its value is the name of the RSS channel that the item came from, derived from its <title>. It has one required attribute, url, which links to the XMLization of the source.
<source url="http://static.userland.com/tomalak/links2.xml">Tomalak's Realm</source>
The purpose of this element is to propogate credit for links, to publicize the sources of news items. It's used in the post command in the Radio UserLand aggregator. It should be generated automatically when forwarding an item from an aggregator to a weblog authoring tool.
<enclosure> sub-element of <item>
<enclosure> is an optional sub-element of <item>.It has three required attributes. url says where the enclosure is located, length says how big it is in bytes, and type says what its type is, a standard MIME type.
The url must be an http url.
<enclosure url="http://www.scripting.com/mp3s/weatherReportSuite.mp3" length="12216320" type="audio/mpeg" />
A use-case narrative for this element is here
<category> sub-element of <item>
<category> is an optional sub-element of <item>.It has one optional attribute, domain, a string that identifies a categorization taxonomy.
The value of the element is a forward-slash-separated string that identifies a hierarchic location in the indicated taxonomy. Processors may establish conventions for the interpretation of categories. Two examples are provided below:
<category>Grateful Dead</category>
<category domain="http://www.fool.com/cusips">MSFT</category>
You may include as many category elements as you need to, for different domains, and to have an item cross-referenced in different parts of the same domain.
<pubDate> sub-element of <item>
<pubDate> is an optional sub-element of <item>.Its value is a date, indicating when the item was published. If it's a date in the future, aggregators may choose to not display the item until that date.
<pubDate>Sun, 19 May 2002 15:21:36 GMT</pubDate>
<guid> sub-element of <item>
<guid> is an optional sub-element of <item>.guid stands for globally unique identifier. It's a string that uniquely identifies the item. When present, an aggregator may choose to use this string to determine if an item is new.
<guid>http://some.server.com/weblogItem3207</guid>
There are no rules for the syntax of a guid. Aggregators must view them as a string. It's up to the source of the feed to establish the uniqueness of the string.
If the guid element has an attribute named "isPermaLink" with a value of true, the reader may assume that it is a permalink to the item, that is, a url that can be opened in a Web browser, that points to the full item described by the <item> element. An example:
<guid isPermaLink="true">http://inessential.com/2002/09/01.php#a2</guid>
isPermaLink is optional, its default value is true. If its value is false, the guid may not be assumed to be a url, or a url to anything in particular.
<comments> sub-element of <item>
<comments> is an optional sub-element of <item>.If present, it is the url of the comments page for the item.
<comments>http://rateyourmusic.com/yaccs/commentsn/blogId=705245&itemId=271</comments>
<author> sub-element of <item>
<author> is an optional sub-element of <item>.It's the email address of the author of the item. For newspapers and magazines syndicating via RSS, the author is the person who wrote the article that the <item> describes. For collaborative weblogs, the author of the item might be different from the managing editor or webmaster. For a weblog authored by a single individual it would make sense to omit the <author> element.
<author>lawyer@boyer.net (Lawyer Boyer)</author>
Comments
RSS places restrictions on the first non-whitespace characters of the data in <link> and <url> elements. The data in these elements must begin with an IANA-registered URI scheme, such as http://, https://, news://, mailto: and ftp://. Prior to RSS 2.0, the specification only allowed http:// and ftp://, however, in practice other URI schemes were in use by content developers and supported by aggregators. Aggregators may have limits on the URI schemes they support. Content developers should not assume that all aggregators support all schemes.In RSS 0.91, various elements are restricted to 500 or 100 characters. There can be no more than 15 <items> in a 0.91 <channel>. There are no string-length or XML-level limits in RSS 0.92 and greater. Processors may impose their own limits, and generators may have preferences that say no more than a certain number of <item>s can appear in a channel, or that strings are limited in length.
In RSS 2.0, a provision is made for linking a channel to its identifier in a cataloging system, using the channel-level category feature, described above. For example, to link a channel to its Syndic8 identifier, include a category element as a sub-element of <channel>, with domain "Syndic8", and value the identifier for your channel in the Syndic8 database. The appropriate category element for Scripting News would be <category domain="Syndic8">1765</category>.
A frequently asked question about <guid>s is how do they compare to <link>s. Aren't they the same thing? Yes, in some content systems, and no in others. In some systems, <link> is a permalink to a weblog item. However, in other systems, each <item> is a synopsis of a longer article, <link> points to the article, and <guid> is the permalink to the weblog entry. In all cases, it's recommended that you provide the guid, and if possible make it a permalink. This enables aggregators to not repeat items, even if there have been editing changes.
If you have questions about the RSS 2.0 format, please post them on the RSS2-Support mail list, hosted by Sjoerd Visscher. This is not a debating list, but serves as a support resource for users, authors and developers who are creating and using content in RSS 2.0 format.
Extending RSS
RSS originated in 1999, and has strived to be a simple, easy to understand format, with relatively modest goals. After it became a popular format, developers wanted to extend it using modules defined in namespaces, as specified by the W3C.RSS 2.0 adds that capability, following a simple rule. A RSS feed may contain elements not described on this page, only if those elements are defined in a namespace.
The elements defined in this document are not themselves members of a namespace, so that RSS 2.0 can remain compatible with previous versions in the following sense -- a version 0.91 or 0.92 file is also a valid 2.0 file. If the elements of RSS 2.0 were in a namespace, this constraint would break, a version 0.9x file would not be a valid 2.0 file.
Here's an example of a file that makes use of elements in namespaces, authored by Mark Pilgrim.
Roadmap
RSS is by no means a perfect format, but it is very popular and widely supported. Having a settled spec is something RSS has needed for a long time. The purpose of this work is to help it become a unchanging thing, to foster growth in the market that is developing around it, and to clear the path for innovation in new syndication formats. Therefore, the RSS spec is, for all practical purposes, frozen at version 2.0.1. We anticipate possible 2.0.2 or 2.0.3 versions, etc. only for the purpose of clarifying the specification, not for adding new features to the format. Subsequent work should happen in modules, using namespaces, and in completely new syndication formats, with new names.Copyright and disclaimer
? Copyright 1997-2002 UserLand Software. All Rights Reserved.This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and these paragraphs are included on all such copies and derivative works.
This document may not be modified in any way, such as by removing the copyright notice or references to UserLand or other organizations. Further, while these copyright restrictions apply to the written RSS specification, no claim of ownership is made by UserLand to the format it describes. Any party may, for commercial or non-commercial purposes, implement this format without royalty or license fee to UserLand. The limited permissions granted herein are perpetual and will not be revoked by UserLand or its successors or assigns.
This document and the information contained herein is provided on an "AS IS" basis and USERLAND DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.


RSS 2.0 標準
來源:http://www.cpcwedu.com/Document/WEBOfficial/095447158.htm
RSS 是一種站點內容聚合的格式。
它的名字是Really Simple Syndication 的的簡寫。
RSS是XML的一種。所有的RSS文檔都遵循 XML 1.0規(guī)范, 該規(guī)范發(fā)布在W3C網(wǎng)站上。
這里是RSS版本歷史的一個概要。
在一個RSS文檔中,最外層是一個<rss>元素,這個元素必須規(guī)定version屬性,該屬性明確了本文檔遵從何種RSS版本規(guī)范。如果一個RSS文檔以這個規(guī)范來表示,那么它的version屬性就必須是2.0。
<rss>元素只有一個子元素<channel>,包含了關于這個頻道(元數(shù)據(jù))和它的內容的一些信息。
樣本文件
這里有一些RSS樣本文件: RSS 0.91, 0.92 和 2.0。
注意這些樣本文件所指向的鏈接地址和服務器可能已經(jīng)不再存在。在撰寫0.91文檔的時候,這個0.91的樣本文件就已經(jīng)創(chuàng)建了。維護一個樣本文件的歷史也許是一個不錯的主意。
關于本文檔
本文檔完成于2002年秋天,版本為 2.0.1。
它包含從 RSS 0.91 規(guī)范(2000年)開始的所有的修改和添加,以及包含在RSS 0.92 (2000年12月)和RSS 0.94(2002年8月)中的新的特性。
詳細的文檔歷史紀錄請參閱這里。
本文檔中首先介紹必須的和可選的頻道元素;接著介紹了<item>的子元素。最后回答了一些經(jīng)常碰到的問題,并提供了未來的發(fā)展路線和RSS擴展的指導方針。
必需的頻道元素
下面是一個必須包含的頻道(channel)元素的列表,每一個都有一個簡單的描述、一個例子、應該出現(xiàn)的位置和更詳細描述的鏈接地址。
01.● title?
名稱:title
描述:頻道的名稱。它表明別人如何訪問你的服務。如果你有一個與你的RSS文件內容一致的HTML網(wǎng)站,你的title元素值應該與你的網(wǎng)站的標題相同。
例子:GoUpstate.com 的新聞大字標題。
02.● link?
名稱:link
描述:對應頻道的網(wǎng)站的URL鏈接地址。
例子:http://www.goupstate.com/ 。
03.● description?
名稱:description
描述:關于頻道的描述。
例子:The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site。
可選的頻道元素
下面是一個可選的頻道(channel)元素的列表。
01.● language
名稱:language
描述:頻道使用的語言。比如,在一個網(wǎng)站上,允許聚合所有的意大利語站點到相應的分組。對于這個元素,可使用的值,參閱 Netscape提供的清單?;蛘呖梢詤㈤哤3C定義的 清單。
例子:en-us。
02.● copyright
名稱:copyright
描述:頻道內容的版權聲明。
例子:Copyright 2002, Spartanburg Herald-Journal
03.● managingEditor
名稱:managingEditor
描述:頻道內容責任編輯的電子郵件地址。
例子:geo@herald.com (George Matesky)
04.● webMaster
名稱:webMaster
描述:頻道技術支持人員的電子郵件地址。
例子:betty@herald.com (Betty Guernsey)
05.● pubDate
名稱:pubDate
描述:頻道內容發(fā)布的日期。所有的日期和時間都必須遵循 RFC 822規(guī)范, 但年份可以用2個或4個字母表示(首選4個字母)。
例子:Sat, 07 Sep 2002 00:00:01 GMT
06.● lastBuildDate
名稱:lastBuildDate
描述:頻道內容的最后修改時間。
例子:Sat, 07 Sep 2002 09:42:31 GMT
07.● category
名稱:category
描述:指定頻道所屬的一個或多個分類。遵循與item級category元素相同的規(guī)則。詳見這里。
例子:<category>Newspapers</category>
08.● generator
名稱:generator
描述:表明生成頻道的程序名稱的字符串。
例子:MightyInHouse Content System v2.3
09.● docs
名稱:docs
描述:指向該RSS文件所用格式說明文檔的URL鏈接地址。
例子:http://blogs.law.harvard.edu/tech/rss。
10.● cloud
名稱:cloud
描述:允許通過注冊一個cloud來處理獲得頻道的更新通知,并為rss種子實現(xiàn)一個輕量級的發(fā)布訂閱協(xié)議,詳見這里。
例子:<cloud domain="rpc.sys.com" port="80" path="/RPC2" registerProcedure="pingMe" protocol="soap"/>
11.● ttl
名稱:ttl
描述:ttl是Time to live的縮寫,表示生存時間。它表示頻道從源更新之前可以緩存的時間。詳見 這里。
例子:<ttl>60</ttl>。
12.● image
名稱:image
描述:指定一個可以在頻道中顯示的GIF、JPEG或者 PNG 圖像。詳見這里。
例子:。
13.● rating
名稱:rating
描述:頻道的 PICS?內容分級信息。
例子: 。
14.● textInput
名稱:textInput
描述:指定一個可以在頻道中顯示的文本輸入框。詳見這里。
例子:。
15.● skipHours
名稱:skipHours
描述:提示聚合器,可以跳過那些小時的時間段。詳見這里。
例子:。
16.● skipDays
名稱:skipDays
描述:提示聚合器,可以跳過那些天的時間段。詳見這里。
例子:。
<channel>的子元素<image>?
<image> 是 <channel>的一個可選子元素, 它本身包含了三個必須的和三個可選的子元素。
<url>是一個GIF、JPEG或PNG圖像文件的URL鏈接地址,該圖像代表整個頻道。
<title>用于描述上面的圖像,當頻道在HTML中顯示時,用于HTML語言中的<img>的alt屬性。
<link>是要連接的站點的url,當顯示頻道時,圖像的連接指向該站點。(在實際中,<title>和<link>應該與頻道的<title>和<link>有相同的值)。
可選的元素包括<width>和<height>,它們是數(shù)字類型,指定圖像的寬度和高度,單位為像素。
<description>就是link的TITLE屬性中文本,它將在調用網(wǎng)頁時顯示出來。
圖像寬度的最大值為144,默認值為88 。
圖像高度的最大值為400,默認值為31 。
<channel>的子元素<cloud>
<cloud> 是 <channel>的一個可選子元素。
它指定一個可以支持rssCloud接口的web服務,rssCloud接口可以在HTTP-POST、XML-RPC或SOAP1.1中實現(xiàn)。
它的目的是允許通過注冊一個cloud來處理獲得頻道的更新通知,從而為RSS feeds實現(xiàn)一個輕量級的發(fā)布訂閱協(xié)議.
<cloud domain="rpc.sys.com" port="80" path="/RPC2" registerProcedure="myCloud.rssPleaseNotify" protocol="xml-rpc" />
在這個例子中,為了請求頻道通知,你需要發(fā)送一個XML-RPC消息到rpc.sys.com的80端口,路徑為/RPC2。調用的程序為為myCloud.rssPleaseNotify。
這個元素的詳細說明和 rssCloud 接口說明請參閱 這里。
<channel>子元素<ttl>
<ttl><channel>的一個可選子元素。
ttl是Time to live的縮寫,表示生存時間。它表示頻道從源重新更新之前可以緩存的時間。這使得rss源可以被一個支持文件共享的網(wǎng)絡所管理,例如Gnutella。
例子: <ttl>60</ttl>
<channel>的子元素<textInput>
頻道可以選擇包含一個<textInput>子元素,它本身包含了四個必須的子元素。
<title>--文本輸入?yún)^(qū)域提交按鈕的標簽。
<description>--文本輸入?yún)^(qū)域的描述。
<name>--文本輸入?yún)^(qū)域中文本對象的名稱。
<link>--處理文本輸入請求的CGI腳本的URL鏈接地址。
使用<textInput>元素的目的看起來有些神秘。你可以用它提供一個搜索引擎輸入框,或讓讀者提供反饋信息。許多聚合器忽略該元素。
<item>的元素
一個頻道可以包含許多<item>元素。一個項目可以代表一個"故事" ——比如說一份報紙或雜志上的故事;如果是這樣的話,那么項目的描述則是故事的摘要,項目的鏈接則指向整個故事的鏈接位置。一個項目也可以本身是完整的,如果是這樣的話,項目的描述就包含了文本(整體以HTML格式編碼是可以的;參見 例子),而鏈接和標題可以省略。項目的所有元素都是可選的,但是至少要包含一個標題(title)或描述(description)。
01.● title
名稱:title
描述:item的標題。
例子:Venice Film Festival Tries to Quit Sinking
02.● link
名稱:link
描述:item的URL鏈接地址。
例子:http://nytimes.com/2004/12/07FEST.html
03.● description?????
名稱:description?????
描述:item的摘要。
例子:Some of the most heated chatter at the Venice Film Festival this week was about the way that the arrival of the stars at the Palazzo del Cinema was being staged.
04.● author
名稱:author
描述:item作者的電子郵件地址。詳見這里。
例子:。
05.● category
名稱:category
描述:包含item在一個或多個分類中。詳見這里。
例子:。
06.● comments
名稱:comments
描述:與item相關的評論的URL鏈接地址。詳見 這里。
例子:。
07.● enclosure
名稱:enclosure
描述:item附加的媒體對象。詳見這里。
例子:。
08.● guid
名稱:guid
描述:可以唯一確定item身份的字符串。詳見 這里。
例子:。
09.● pubDate
名稱:pubDate
描述:item發(fā)布的時間。詳見 這里。
例子:。
10.● source
名稱:source
描述:rss頻道來源。詳見 這里。
例子:。
<item>的子元素<source>
<source>是<item>的一個可選子元素。
它的值是item所屬rss頻道的名稱,從title衍生而來。它有一個必須包含的屬性url, 該屬性鏈接到XML序列化源。
<source url="http://www.tomalak.org/links2.xml">Tomalak's Realm</source>
該元素的作用是提高鏈接的聲望,從而進一步推廣新聞項目的源頭。它可以用在聚合器的Post命令中。當從聚合器中通過一個webblog編輯工具提交一個item時,<source>應該能夠被自動生成。
<item>的子元素<enclosure>
<enclosure>是<item>的一個可選子元素。
它有三個必須的屬性。url屬性表明enclosure的位置,length屬性表明它的字節(jié)大小,而type屬性則指出它的標準MIME類型。
這里的url必須為一個http url。
<enclosure url="http://www.scripting.com/mp3s/weatherReportSuite.mp3" length="12216320" type="audio/mpeg" />
它的 use-case 說明請參見這里。
<item>的子元素<category>
<category>是<item>的一個可選子元素。
它有一個可選屬性domain,該屬性是一個用來定義分類法的字符串。
該節(jié)點的值是一個斜杠分割的字符串,它用來表明在指定的分類法中的層次位置。處理器可以為分類的識別建立協(xié)定。以下是兩個例子:
<category>Grateful Dead</category>
<category domain="http://www.fool.com/cusips">MSFT</category>
你可以根據(jù)需要為不同的域包含很多<category>元素,并且可以在相同域的不同部分擁有一個交叉引用的item。
<item>的子元素<pubDate>
<pubDate> 是<item>的一個可選子元素。
它的值是一個 日期, 表明項目發(fā)布的時間。如果它是一個將來的日期,則聚合器在日期到達之前可以選擇不顯示該項目。?
<pubDate>Sun, 19 May 2002 15:21:36 GMT</pubDate>
<item>的子元素<guid>?
<guid>是<item>的一個可選子元素。
guid 是 globally unique identifier的縮寫。它是一個可以唯一識別這個<item>的字符串。在發(fā)布之后,聚合器可以選擇使用該字符串判斷這個<item>是否是新的。?
<guid>http://some.server.com/weblogItem3207</guid>
guid沒有特定的語法規(guī)則。聚合器必須將它們當作一個字符串來處理。生成具有唯一性的字符串guid取決于種子的源頭。
如果guid元素有isPermaLink屬性,并且值為真,解釋器就會認為它是item的permalink。permalink是一個可在web瀏覽器中打開的url鏈接,它指向<item>節(jié)點所描述的完整item。 例如:
<guid isPermaLink="true">http://inessential.com/2002/09/01.php#a2</guid>
isPermaLink是可選屬性,默認值為真。如果值為假,guid將不會被認為是一個url或指向任何對象的url。
<item>的子元素<comments>
<comments>是<item>的一個可選子元素。
如果出現(xiàn),它指向與item相關的評論的url。
<comments>http://ekzemplo.com/entry/4403/comments</comments>
更多信息,請參閱?這里。
<item>的子元素<author>?
<author>是<item>的一個可選子元素。
它是item作者的電子郵件地址l。對于通過rss傳播的報紙和雜志,作者可能是寫該item所描述的文章的人。對于聚集型webblogs,作者可能不是責任編輯或站長。對于個人維護的webblog,忽略<author>節(jié)點是有意義的。
<author>lawyer@boyer.net (Lawyer Boyer)</author>
注釋
RSS限制<link> 和 <url>元素的數(shù)據(jù)首字母為非空格字符。這些元素的數(shù)據(jù)必須以IANA-registered?URI方案規(guī)定的格式開始,如http://, https://, news://, mailto:和 ftp://等。在RSS2.0規(guī)范之前,RSS規(guī)范只允許http:// 和 ftp://,然而在實踐中,其他的URI方案被內容開發(fā)者廣泛使用,并被聚合器所支持。聚合器也許對它們支持的URI方案有一些限制,而內容開發(fā)者不應該假定所有的聚合器都支持所有的URI方案。
在 RSS 0.91規(guī)范中,各種元素都被限制為500或100個字符。在一個符合0.91規(guī)范的頻道中,不能超過15個 <item> 元素。在RSS 0.92和以后的規(guī)范中,不再有這些字符長度或者XML級別的限制。處理器也許強加一些它們自己的限制,產(chǎn)生者也許有自己的一些參數(shù)選擇,它們可以規(guī)定在一個頻道中,不超過一定數(shù)目的<item>元素,或者字符串都限制在一定的長度。?
如上所述,在?RSS 2.0規(guī)范中,對于一個目錄系統(tǒng),當鏈接一個頻道到它的標識中時,使用基于頻道級別的分類特征。 例如,如果鏈接一個頻道到它的Syndic8 標識,則將包括一個分類元素作為頻道的子元素,它有域“Syndic8”屬性,同時在Syndic8 數(shù)據(jù)庫中為你的頻道確定這個標識。正確的分類元素腳本應該是 <category domain="Syndic8">1765</category>。
一個經(jīng)常被問到的問題是關于<guid> 如何和 <link>進行區(qū)別。它們指的是相同的事情嗎?在一些內容系統(tǒng)中是,但在別的內容系統(tǒng)中可能不是。在一些系統(tǒng)中,<link>是一個網(wǎng)絡日志項的永久鏈接。然后在別的系統(tǒng)中,每一個<item>都是一個較長文章的摘要,<link>指向這篇文章,而<guid>則是這個網(wǎng)絡日志入口的永久鏈接。在所有的情況下,建議提供<guid>,如果可能的話,并使它成為一個永久鏈接。這使聚合著在內容發(fā)生變化時,也不會出現(xiàn)重復項目成為可能。
如果你對RSS 2.0規(guī)范的格式有任何問題,請向由Sjoerd Visscher維護的電子郵件列表RSS2-Support發(fā)送郵件。這個郵件列表不是一個技術辯論的列表,而是一個針對作者和開發(fā)人員在創(chuàng)建和使用RSS 2.0格式的內容時提供技術支持的列表。
RSS的擴展
RSS起源于1999年,目標是成為一個簡單、易于理解的數(shù)據(jù)格式。在它逐漸成為一種流行格式之后,開發(fā)者想在一個名字空間中使用模塊對它進行擴展,正像W3C定義的那樣。
RSS遵循簡單的規(guī)則,增加了它的能力。一個RSS feed 可以包含不是在本頁中描述的內容,而只是在一個名字空間中定義的那些元素。
本文檔中定義的元素不是一個名字空間本省的元素,因此, RSS2.0從某種意義上來講,和原來的版本是兼容的,即一個 0.91?或者 0.92 版本的文件也是一個有效的 2.0 版本文件。如果RSS2.0的元素是在一個名字空間中,那么這種約束將被打破,即 一個0.9x 版本的文件不可能是一個有效的2.0 版本的文件。
發(fā)展方向?
RSS決不是一個完美的格式,但是它現(xiàn)在已經(jīng)非常流行,并得到廣泛的支持。要成為一個固定的規(guī)范,RSS需要很長的一段時間。這項工作的目的是幫助RSS成為一個固定的事情,同時促進和培育圍繞它進行的開發(fā)的市場的增長,并為新的聚合格式鋪平道路。因此,為了實用的目的,RSS規(guī)范將被凍結在2.0.2版本。我們可以預期的可能的2.0.2 或者 2.0.3等版本,都只是出于澄清規(guī)范的目的,而不是在格式上增加新的特征。后續(xù)的工作應該集中在模塊化、名字空間的使用和在完全新的聚合格式中用新的名字等方面。
許可協(xié)議和作者
RSS 2.0 是在遵循i the Attribution/Share Alike Creative Commons 許可協(xié)議?的基礎上由 the Berkman Center for Internet & Society at Harvard Law School 提供。本文檔的作者是 Dave Winer,UserLand software的創(chuàng)始人,也是 Berkman Center 的員工。