One of the things that has set of a furious round of politics on
list is the
<enclosure> element - does it allow multiple enclosures in
a single item or not? Here's the text from the spec:
<enclosure> is an optional sub-element of
It has three required attributes. url says where the enclosure
is located, length says how big it is in bytes, and type says what
its type is, a standard MIME type.
The url must be an http url. <enclosure
length="12216320" type="audio/mpeg" />
That doesn't say anything about it, which is why there's discussion. I thought it might be useful to have a look at actual practice - how many multiple enclosures do I see in the wild? Well, this is admittedly anecdotal - I'm looking through my own subscription list, and I'm not big into podcasts - so out of my 316 feeds, it's not a huge selection. Still, let's have a look. First, all the items that have at least one enclosure:
withEnclosures := OrderedCollection new.
RSSFeedManager default getAllMyFeeds do:
[:each | | with |
with := each allItems
select: [:eachItem | eachItem enclosure notNil
and: [eachItem enclosure size >= 1]].
with notEmpty ifTrue: [withEnclosures add: (each ->with)]].
withEnclosures inject: 0 into: [:subTotal :next | subTotal + next value size]
That code, when inspecting the results, gave me this:
Ok, so there are 18 feeds, out of 316 feeds total (with a total of 17,968 items) that have even one enclosure. In that group, there are 327 items with at least one enclosure. That's more than I thought, actually. How many of those 327 items have more than one?
- Feed: Lessig Blog
- I'll be virtual next Wednesday 3
- the badge campaigns continue 4
- Feed: Instapundit.com
- The Glenn and Helen Show: Austin Bay and Jim Dunnigan on Ports, the Philippines, Iran, and More 2
- Feed: Power Line
- Still More Cartoon Madness 2
That little snippet of HTML was produced by this code:
stream := WriteStream on: (String new: 100).
multiples := OrderedCollection new.
withEnclosures do: [:each |
| feed bigger |
feed := each key.
items := each value.
bigger := items select: [:eachItem | eachItem enclosure size > 1].
bigger notEmpty ifTrue: [multiples add: (feed -> bigger)]].
stream nextPutAll: '<ul>'; cr.
multiples do: [:each |
stream nextPutAll: '<li>Feed: ', each key title, '</li>'.
stream nextPutAll: '<ul>'; cr.
each value do: [:eachItem |
stream nextPutAll: '<li>'.
stream nextPutAll: eachItem title.
stream nextPutAll: eachItem enclosure size printString.
stream nextPutAll: '</li>'; cr.].
stream nextPutAll: '</ul>'; cr].
stream nextPutAll: '</ul>'.
The reason it looks like a lot of code is the production of the HTML mixed in there. All I'm really doing is looping over the data I produced in the last go-round, and getting numbers out of it. As it happens, there are 4 items in 3 feeds (out of 327 items in 18 feeds with enclosures) that have more than one enclosure - with a total of 11 enclosures across those 4 items.
So what does that show? Possibly that using multiple enclosures just isn't that common. On the other hand, the three feeds that did use them are quite popular.
So I almost forgot to mention the cool part. All that code was executed in a workspace in the runtime for BottomFeeder - not in the development environment. The tool is written in Smalltalk, and I can simply ask the domain objects questions at runtime. Pretty cool, IMHO.