Today I was working on completing the support for Atom 1.0 in the next version of RSS Bandit and decided to make the changes for parsing out enclosure/podcast elements while I was in that part of the code. RSS 2.0 is pretty straightforward, there is an <enclosure> element that is a child of the <item> element.
On the other hand, the Atom 1.0 specification has two completely different mechanisms for creating podcasts. Both mechanisms are described in the article by James Snell entitled An overview of the Atom 1.0 Syndication Format. From the article
Support for enclosures Listing 4. Atom 1.0 podcasting example <feed xmlns="http://www.w3.org/2005/Atom"> <id>http://www.example.org/myfeed</id> <title>My Podcast Feed</title> <updated>2005-07-15T12:00:00Z</updated> <author> <name>James M Snell</name> </author> <link href="http://example.org" /> <link rel="self" href="http://example.org/myfeed" /> <entry> <id>http://www.example.org/entries/1</id> <title>Atom 1.0</title> <updated>2005-07-15T12:00:00Z</updated> <link href="http://www.example.org/entries/1" /> <summary>An overview of Atom 1.0</summary> <link rel="enclosure" type="audio/mpeg" title="MP3" href="http://www.example.org/myaudiofile.mp3" length="1234" /> <link rel="enclosure" type="application/x-bittorrent" title="BitTorrent" href="http://www.example.org/myaudiofile.torrent" length="1234" /> <content type="xhtml"> <div xmlns="http://www.w3.org/1999/xhtml"> <h1>Show Notes</h1> <ul> <li>00:01:00 -- Introduction</li> <li>00:15:00 -- Talking about Atom 1.0</li> <li>00:30:00 -- Wrapping up</li> </ul> </div> </content> </entry> </feed> Atom enclosures allow you to do more than just distribute audio content. Enclosure links can reference any type of resource. Listing 5, for instance, uses multiple enclosures within a single entry to reference translated versions of a single PDF document that's accessible through FTP. The hreflang attribute identifies the language that each PDF document has been translated into. Content-by-reference In addition to support for links and enclosures, Atom introduces the ability to reference entry content by URI. Listing 6, for instance, illustrates how an Atom feed for a photo weblog might appear. The content element references each individual photograph in the blog. The summary element provides a caption for the image. Listing 6. A simple list of images using Atom 1.0 <feed xmlns="http://www.w3.org/2005/Atom" xml:base="http://www.example.org/"> <id>http://www.example.org/pictures</id> <title>My Picture Gallery</title> <updated>2005-07-15T12:00:00Z</updated> <author> <name>James M Snell</name> </author> <entry> <id>http://www.example.org/entries/1</id> <title>Trip to San Francisco</title> <link href="/entries/1" /> <updated>2005-07-15T12:00:00Z</updated> <summary>A picture of my hotel room in San Francisco</summary> <content type="image/png" src="/mypng1.png" /> </entry> <entry> <id>http://www.example.org/entries/2</id> <title>My new car</title> <link href="/entries/2" /> <updated>2005-07-15T12:00:00Z</updated> <summary>A picture of my new car</summary> <content type="image/png" src="/mypng2.png" /> </entry> </feed> This content-by-reference mechanism provides a very flexible means of expanding the types of content that one can syndicate through Atom.
Support for enclosures
Listing 4. Atom 1.0 podcasting example
<feed xmlns="http://www.w3.org/2005/Atom"> <id>http://www.example.org/myfeed</id> <title>My Podcast Feed</title> <updated>2005-07-15T12:00:00Z</updated> <author> <name>James M Snell</name> </author> <link href="http://example.org" /> <link rel="self" href="http://example.org/myfeed" /> <entry> <id>http://www.example.org/entries/1</id> <title>Atom 1.0</title> <updated>2005-07-15T12:00:00Z</updated> <link href="http://www.example.org/entries/1" /> <summary>An overview of Atom 1.0</summary> <link rel="enclosure" type="audio/mpeg" title="MP3" href="http://www.example.org/myaudiofile.mp3" length="1234" /> <link rel="enclosure" type="application/x-bittorrent" title="BitTorrent" href="http://www.example.org/myaudiofile.torrent" length="1234" /> <content type="xhtml"> <div xmlns="http://www.w3.org/1999/xhtml"> <h1>Show Notes</h1> <ul> <li>00:01:00 -- Introduction</li> <li>00:15:00 -- Talking about Atom 1.0</li> <li>00:30:00 -- Wrapping up</li> </ul> </div> </content> </entry> </feed>
hreflang
Content-by-reference
In addition to support for links and enclosures, Atom introduces the ability to reference entry content by URI. Listing 6, for instance, illustrates how an Atom feed for a photo weblog might appear. The content element references each individual photograph in the blog. The summary element provides a caption for the image.
content
summary
Listing 6. A simple list of images using Atom 1.0
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="http://www.example.org/"> <id>http://www.example.org/pictures</id> <title>My Picture Gallery</title> <updated>2005-07-15T12:00:00Z</updated> <author> <name>James M Snell</name> </author> <entry> <id>http://www.example.org/entries/1</id> <title>Trip to San Francisco</title> <link href="/entries/1" /> <updated>2005-07-15T12:00:00Z</updated> <summary>A picture of my hotel room in San Francisco</summary> <content type="image/png" src="/mypng1.png" /> </entry> <entry> <id>http://www.example.org/entries/2</id> <title>My new car</title> <link href="/entries/2" /> <updated>2005-07-15T12:00:00Z</updated> <summary>A picture of my new car</summary> <content type="image/png" src="/mypng2.png" /> </entry> </feed>
This content-by-reference mechanism provides a very flexible means of expanding the types of content that one can syndicate through Atom.
After looking at this from all angles for about 30 minutes the only conclusion I can come to is that Atom provided two completely different mechanisms of achieving the same goal. This is likely a potential gotcha for aggregator authors who might end up supporting one or the other of the mechanisms instead of both.
After this, I still have to add some code to also support Yahoo! Media RSS and then track down some feeds that actually use all the various enclosure techniques so I can test my code with actual real world scenarios. I'd appreciate any pointers to test feeds especially for the Yahoo! Media extensions to RSS [which I'm considering not supporting if there aren't that many feeds that use it].
No rest for the wicked. ;)