11.1 Namespaces and Modules with RSS 2.0
RSS 2.0
introduces namespaced modules to the simple strand of RSS. The
specification document states:
A RSS feed may contain elements not described on this page, only if
those elements are defined in a namespace. The elements defined in
this document are not themselves members of a namespace, so that RSS
2.0 can remain compatible with previous versions in the following
sense � a version 0.91 or 0.92 file is also a valid 2.0 file.
If the elements of RSS 2.0 were in a namespace, this constraint would
break, a version 0.9x file would not be a valid 2.0 file.
Other than not defining a namespace for the core elements of RSS 2.0,
the modules work in the same way as the modules for RSS 1.0: declare
the module's namespace in the root element (which in
the case of RSS 2.0 is, of course, rss) and then
use the module elements as directed by their specification. Parsers
that do not recognize the namespace just ignore the new elements.
11.1.1 Differences from RSS 1.0
Whether or not RSS 1.0 modules can be reused within RSS 2.0 is
currently a matter of debate. To do so requires the feed author to
declare two additional namespaces within the root element: the
namespace of the module and the namespace of RDF. Some people find
this additional complexity distasteful, and others find the rejection
of the additionally powerful metadata a great shame. Still others,
however, are using modules that declare the
rdf:resource attribute without flinching.
While this argument rages (I advise you to check out the relevant
email lists for the latest blows and parries), we can always bear in
mind the simple way to convert between the default module styles,
which we will consider now.
RSS 1.0 modules, you will remember, declare everything in terms of
RDF resources. This is done with the rdf:resource
attribute. For example, a fictional element
pet:image, used to denote an image of the feed
author's pet, would be written:
<pet:image rdf:resource="URI_OF_IMAGE"/>
whereas in RSS 2.0, the default lack of RDF means you must just
declare the URI of the image as a literal string:
<pet:image>URI_OF_IMAGE</pet:image>
But the differences go deeper than this, as we will now see as we
design a new module: mod_Book.
|