发新话题
打印

zt: Atom

zt: Atom

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 则不属于任何标准化组织,而且它不是开放版权的。
复制内容到剪贴板
代码:
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="text">dive into mark</title>
  <subtitle type="html">
    A &lt;em&gt;lot&lt;/em&gt; of effort
    went into making this effortless
  </subtitle>
  <updated>2005-04-02T12:29:29Z</updated>
  <id>tag:example.org,2003:3</id>
  <link rel="alternate" type="text/html"
   hreflang="en" href="http://example.org/"/>
  <copyright>Copyright (c) 2003, Mark Pilgrim</copyright>
  <generator uri="http://www.example.com/" version="1.0">
    Example Toolkit
  </generator>
  <entry>
    <title>Atom draft-07 snapshot</title>
    <link rel="alternate" type="text/html"
     href="http://example.org/2005/04/02/atom"/>
    <link rel="enclosure" type="audio/mpeg" length="1337"
     href="http://example.org/audio/ph34r_my_podcast.mp3"/>
    <id>tag:example.org,2003:3.2397</id>
    <updated>2005-04-02T12:29:29Z</updated>
    <published>2003-12-13T08:29:29-04:00</published>
    <author>
      <name>Mark Pilgrim</name>
      <uri>http://example.org/</uri>
      <email>f8dy@example.com</email>
    </author>
    <contributor>
      <name>Sam Ruby</name>
      <uri>http://intertwingly.net/blog/</uri>
    </contributor>
    <contributor>
      <name>Joe Gregorio</name>
      <uri>http://bitworking.org/</uri>
    </contributor>
    <content type="xhtml" xml:lang="en"
     xml:base="http://diveintomark.org/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p><i>[Update: The Atom draft-07 snapshot is out.]</i></p>
      </div>
    </content>
  </entry>
</feed>
选咖啡,选拿铁.少喝咖啡,多办事

TOP

rss2.0
复制内容到剪贴板
代码:
<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>Liftoff News</title>
    <link>http://liftoff.msfc.nasa.gov/</link>
    <description>Liftoff to Space Exploration.</description>
    <language>en-us</language>
    <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
    <lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>Weblog Editor 2.0</generator>
    <managingEditor>editor@example.com</managingEditor>
    <webMaster>webmaster@example.com</webMaster>

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

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

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

    <item>
      <title>Astronauts' Dirty Laundry</title>
      <link>http://liftoff.msfc.nasa.gov/news/2003/news-laundry.asp</link>
      <description>Compared to earlier spacecraft, the International Space
        Station has many luxuries, but laundry facilities are not one of them.
        Instead, astronauts have other options.</description>
      <pubDate>Tue, 20 May 2003 08:56:02 GMT</pubDate>
      <guid>http://liftoff.msfc.nasa.gov/2003/05/20.html#item570</guid>
    </item>
  </channel>
</rss>
选咖啡,选拿铁.少喝咖啡,多办事

TOP

发新话题