Atom Entry - Sweet to its Core

An Atom Entry Element is at the center of both Atom Syndication and the Atom Publishing Protocol. A single Atom Entry has the flexability to carry with it both descriptive metadata and a payload in a simple XML package. Here is a simple spec for what the <entry> tag can have:

  1. An <id> tag - a unique identifier like a URL

  2. An <updated> tag - a recently updated timestamp

  3. A <title> tag - a human readable title

  4. 0 or more <author> tags - to indicate the entry's authors

  5. 0 or more <contributor> tags - similiar to authors

  6. 0 or more <category> tags - to convey more information like tags

  7. 0 or more <link> tags - for other resources/URLs

  8. An optional <content> tag - the real data

  9. And optional <published>, <rights>, <source>, and <summary> tags for extra information and details about the entry.

The power is in the <content> tag. This tag has a type attribute which can be text, html, xhtml, or any valid MIME media type such as "image/jpeg" for jpeg images, "video/quicktime" for mov movies etc. Here is a list of valid MIME types. Without further ado, here are your example Atom entries:

<entry>
  <title>Robots Run Amok</title>
  <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
  <updated>2003-12-13T18:30:02Z</updated>
  <link rel="self" title="Blog Post"
        href="http://example.org/2008/03/15/atom03" />
  <summary>Some Robots are Crazy.</summary>
</entry>
Example 1 - Basic

Nothing is really exciting about this Atom Entry. You get a feel for what it is but you don't know the main content of the blog article that this entry is seemingly referring to. An Atom Entry this vague would be likely to show up in a very basic Atom Feed. Since a Feed contains a collection of entries it may benefit the syndicator to only give some information about each entry and allow the user to request more by following the <link rel="self" href="..."> link for the full content. Lets do just that!

<entry>
  <title>Robots Run Amok</title>
  <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
  <updated>2003-12-13T18:30:02Z</updated>

  <link rel="self" title="Blog Post"
        href="http://example.org/2008/03/15/atom03"/>
  <link rel="edit"
        href="http://example.org/e/2008/03/15/atom03/"/>
  <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"/>

  <author>
    <name>Joseph Pecoraro</name>
    <uri>http://bogojoker.com/</uri>
    <email>j0e@example.com</email>
  </author>
  <contributor>
    <name>Sam Ruby</name>
  </contributor>
  <contributor>
    <name>Joe Gregorio</name>
  </contributor>

  <summary>Some Robots are Crazy.</summary>
  <content type="xhtml" xml:lang="en"
   xml:base="http://diveintomark.org/">
    <div xmlns="http://www.w3.org/1999/xhtml">
      <p>
        I have not been in contact with too many robots.  I am
        not <em>robo-phobic</em>, I just don't see them all that
        often.  That may have been the source of today's problem!
      </p>
      <blockquote cite="Joseph Pecoraro">
        I think a Robot robbed me today.  It was crazy.
      </blockquote>
      <p>
        So what can I do?  Who do I turn to?  Help me.
      </p>
    </div>
  </content>

</entry>
Example 2 - More Advanced

Now we really get a better idea of what this entry represents! We not only see the content but more metadata and even some links. Lets break it down:

  1. The 3 required tags are at the top and serve their purpose

  2. There are 4 links. Each with a descriptive rel attribute and an href attribute with a URL. These links are fundamental to Atom. In the case above they are descriptive enough that the unnecessary title attribute was dropped. One at a time:

    • rel="self" is a link to the current entry, quite useful in practice

    • rel="edit" is the URL used to edit this entry via the Atom Publishing Protocol

    • rel="alternate" is a link to more external content

    • rel="enclosure" is a link to some extra "attached" content

  3. There is 1 Author, Joseph Pecoraro, with his full contact information. There are also 2 contributors

  4. The entry provides a summary of the content

  5. The content itself is type="xhtml". Therefore all of the data between the opening and closing <content> tags is xhtml. Sure enough the <div> links to the xhtml namespace! Joseph Pecoraro sure can write a great article!

For more information go on to read the RESTful page describing how the Atom Publshing Protocol combines Atom Entries and the HTTP Protocol to complete its goal of both simple syndication and flexible publication.