找回密码
 欢迎注册
搜索
热搜: 活动 交友 discuz
查看: 2125|回复: 1

zt: Atom

[复制链接]
发表于 2007-10-5 09:09:59 | 显示全部楼层 |阅读模式
Atom 是一种基于XML的文档格式以及基于HTTP的协议,它被站点和客户工具等用来聚合网络内容,包括网志和新闻标题等。它借鉴了各种版本RSS的使用经验。一些批评者说它只不过是另一个内容聚合领域的捣蛋鬼。

Atom被许多的聚合工具广泛使用在发布和使用上。值得一提的是, Blogger和Gmail这两个由Google提供的服务正在使用Atom。

Atom已是IETF的“建议标准”,相关的资料可在RFC 4287找到。

作为RSS的替代品,Atom计划制作了一个建基于HTTP的协定Atom Publishing Protocol(APP)以取代现有的发布方式(如Blogger API和LiveJournal XML-RPC Client/Server Protocol)。Atom曾命名为“Echo”。 最新的Atom资料格式和协定可以在工作小组的主页取得。


Atom相对RSS 2.0的优势
当初发展Atom的动机在于广泛应用RSS 2.0时所遇到的问题。为了降低开发支持Web聚合应用的难度,下面列出Atom 1.0所克服的RSS 2.0几个主要问题(源自 [1]):

RSS 2.0 可能包含文本或经过编码的HTML内容,同时却没有提供明确的区分办法;相比之下,Atom 则提供了明确的标签(也就是typed)。
RSS 2.0 的 description 标签可以包含全文或摘要(尽管该标签的英文含义为描述或摘要)。Atom 则分别提供了 summary 和 content标签,用以区分摘要和内容,同时 Atom 允许在summary中添加非文本内容。
RSS 2.0 存在多种非标准形式的应用,而 Atom 具有统一的标准,这便于内容的聚合和发现。
Atom 有符合XML标准的命名空间,RSS 2.0 却没有。
Atom 通过XML内置的xml:base标签来指示相对地址(URI),RSS 2.0 则无相应的机制区分相对地址和绝对地址。
Atom 通过XML内置的xml:lang,而 RSS 采用自己的language标签。
Atom 强制为每个条目设定唯一的ID,这将便于内容的跟踪和更新。
Atom 1.0 允许条目单独成为文档,RSS 2. 0则只支持完整的种子文档,这可能产生不必要的复杂性和带宽消耗。
Atom 按照RFC 3339标准(ISO 8601标准的一个子集)表示时间 ,而RSS 2.0中没有指定统一的时间格式。
Atom 1.0 具有在 IANA 注册了的 MIME 类型,而 RSS 2.0 所使用的 application/rss+xml 并未注册。
Atom 1.0 标准包括一个 XML schema,RSS 2.0 却没有。
Atom 是IETF组织标准化程序下的一个开放的发展中标准,RSS 2.0 则不属于任何标准化组织,而且它不是开放版权的。
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <feed xmlns="http://www.w3.org/2005/Atom">
  3.   <title type="text">dive into mark</title>
  4.   <subtitle type="html">
  5.     A &lt;em&gt;lot&lt;/em&gt; of effort
  6.     went into making this effortless
  7.   </subtitle>
  8.   <updated>2005-04-02T12:29:29Z</updated>
  9.   <id>tag:example.org,2003:3</id>
  10.   <link rel="alternate" type="text/html"
  11.    hreflang="en" href="http://example.org/"/>
  12.   <copyright>Copyright (c) 2003, Mark Pilgrim</copyright>
  13.   <generator uri="http://www.example.com/" version="1.0">
  14.     Example Toolkit
  15.   </generator>
  16.   <entry>
  17.     <title>Atom draft-07 snapshot</title>
  18.     <link rel="alternate" type="text/html"
  19.      href="http://example.org/2005/04/02/atom"/>
  20.     <link rel="enclosure" type="audio/mpeg" length="1337"
  21.      href="http://example.org/audio/ph34r_my_podcast.mp3"/>
  22.     <id>tag:example.org,2003:3.2397</id>
  23.     <updated>2005-04-02T12:29:29Z</updated>
  24.     <published>2003-12-13T08:29:29-04:00</published>
  25.     <author>
  26.       <name>Mark Pilgrim</name>
  27.       <uri>http://example.org/</uri>
  28.       <email>f8dy@example.com</email>
  29.     </author>
  30.     <contributor>
  31.       <name>Sam Ruby</name>
  32.       <uri>http://intertwingly.net/blog/</uri>
  33.     </contributor>
  34.     <contributor>
  35.       <name>Joe Gregorio</name>
  36.       <uri>http://bitworking.org/</uri>
  37.     </contributor>
  38.     <content type="xhtml" xml:lang="en"
  39.      xml:base="http://diveintomark.org/">
  40.       <div xmlns="http://www.w3.org/1999/xhtml">
  41.         <p><i>[Update: The Atom draft-07 snapshot is out.]</i></p>
  42.       </div>
  43.     </content>
  44.   </entry>
  45. </feed>
复制代码
 楼主| 发表于 2007-10-5 09:20:14 | 显示全部楼层
rss2.0
  1. <?xml version="1.0"?>
  2. <rss version="2.0">
  3.   <channel>
  4.     <title>Liftoff News</title>
  5.     <link>http://liftoff.msfc.nasa.gov/</link>
  6.     <description>Liftoff to Space Exploration.</description>
  7.     <language>en-us</language>
  8.     <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
  9.     <lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
  10.     <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  11.     <generator>Weblog Editor 2.0</generator>
  12.     <managingEditor>editor@example.com</managingEditor>
  13.     <webMaster>webmaster@example.com</webMaster>

  14.     <item>
  15.       <title>Star City</title>
  16.       <link>http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp</link>
  17.       <description>How do Americans get ready to work with Russians aboard the
  18.         International Space Station? They take a crash course in culture, language
  19.         and protocol at Russia's Star City.</description>
  20.       <pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate>
  21.       <guid>http://liftoff.msfc.nasa.gov/2003/06/03.html#item573</guid>
  22.     </item>

  23.     <item>
  24.       <title>Space Exploration</title>
  25.       <link>http://liftoff.msfc.nasa.gov/</link>
  26.       <description>Sky watchers in Europe, Asia, and parts of Alaska and Canada
  27.         will experience a partial eclipse of the Sun on Saturday, May 31st.</description>
  28.       <pubDate>Fri, 30 May 2003 11:06:42 GMT</pubDate>
  29.       <guid>http://liftoff.msfc.nasa.gov/2003/05/30.html#item572</guid>
  30.     </item>

  31.     <item>
  32.       <title>The Engine That Does More</title>
  33.       <link>http://liftoff.msfc.nasa.gov/news/2003/news-VASIMR.asp</link>
  34.       <description>Before man travels to Mars, NASA hopes to design new engines
  35.         that will let us fly through the Solar System more quickly.  The proposed
  36.         VASIMR engine would do that.</description>
  37.       <pubDate>Tue, 27 May 2003 08:37:32 GMT</pubDate>
  38.       <guid>http://liftoff.msfc.nasa.gov/2003/05/27.html#item571</guid>
  39.     </item>

  40.     <item>
  41.       <title>Astronauts' Dirty Laundry</title>
  42.       <link>http://liftoff.msfc.nasa.gov/news/2003/news-laundry.asp</link>
  43.       <description>Compared to earlier spacecraft, the International Space
  44.         Station has many luxuries, but laundry facilities are not one of them.
  45.         Instead, astronauts have other options.</description>
  46.       <pubDate>Tue, 20 May 2003 08:56:02 GMT</pubDate>
  47.       <guid>http://liftoff.msfc.nasa.gov/2003/05/20.html#item570</guid>
  48.     </item>
  49.   </channel>
  50. </rss>
复制代码
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

快速回复 返回顶部 返回列表