RSS and Atom in Action: Newsfeed Formats | Part 2/Page 3
RSS and Atom in Action: Newsfeed Formats
4.5.4 Atom identifiers
Unlike earlier formats, Atom format requires that you provide a unique and permanent identifier for each feed and each entry. Each
<entry> element must contain an
That last bullet about RFC 3987 sounds a little intimidating, but generating ids for your feeds and entries is really not that difficult. In fact, you can use URLs because every URL is a valid IRI. That's probably the easiest route. Use a feed's alternate link as the feed's id and use each entry's alternate link as its id. That's what we did in the Atom feed shown in listing 4.3.
4.5.5 The Atom content modelTo include content in an Atom entry, you use the
<content>element is similar to a text construct, but it's more complex because it is designed to support six types of content. These types of content can be included inline within the body of the entry or out-of-line at a web location specified by a URI. Here are the six types of content supported by Atom:
To specify the type of content in a
<content> element with
type="text" (no HTML is allowed in text content):
And here is one with
type="xhtml"; we've made the URL into a link:
Here's one with
type ="html" and the same link; note that all markup is escaped:
As you can see, Atom has a well though thought-out, flexible, and well-specified content model. Now let's discuss how Atom's
<link> element can be used to support podcasting.
4.5.6 Podcasting with Atom
Podcasting originated as a feature of RSS, but as the world moves to Atom as the new standard, the podcasters will tooÂand for good reason. Atom can support podcasting through the element. As is the case with RSS 2.0-based podcasts, you can have only one podcast per entry. But with Atom, you can have a different representation for each language and for each content-type. For example, if you want to make a podcast available in both English and German and in both MP3 and WMV formats, you can do it like this:
Perhaps the best way to summarize this chapter is with the newsfeed format family tree, shown in figure 4.7. You can clearly see the simple vs. RDF fork and Atom's clean break with the past.
Here are some of the key points we covered in this chapter:
This excerpt is taken from Chapter 4 of RSS and Atom in Action, written by Dave Johnson, and published by Manning Publications Co., Copyright © 2006 Manning Publications Co. All rights reserved.