Tải bản đầy đủ (.pdf) (16 trang)

RSS and Syndication

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (768.51 KB, 16 trang )

239
CHAPTER 9
RSS and Syndication
I
N THIS CHAPTER
, we describe how portlets can aggregate links to content on
external web sites using the group of standards known as RSS. We also discuss
how the content of your own portal could be syndicated for convenient inclusion
in external sites using the same mechanism.
Overview of RSS
RSS is not a single standard. It is several standards, some closely related, and
others more loosely so.
The versions of RSS that are most commonly used are 0.9 and 0.91, both of
which were released by Netscape to allow content from external web sites to be
aggregated into its My Netscape portal.
Since 0.91, two groups have produced new versions of RSS with varying degrees
of backward compatibility. The company UserLand Software carried out early
development of RSS for Netscape and has subsequently released versions 0.92,
0.93, 0.94, and 2.0. The RSS-DEV working group (an independent group of devel-
opers) released the 1.0 version of RSS stemming from the 0.91 version.
NOTE
Some but not all of these versions are based on the Resource Description
Framework (RDF) format. This rather more consistently managed standard
from the World Wide Web Consortium (W3C) standards body provided a stan-
dard for presenting metadata. A syndication feed is a set of metadata; it does
not (generally) provide the articles itself, but will provide their titles, some
associated links, and abstracts of the articles.
RDF in this respect is ideal—however, it is quite a complex standard; RSS prag-
matically provides a reasonable subset of this information oriented specifically
toward syndication at the cost of a somewhat fragmented standard.
Even the naming of the standard reflects the version confusion. Correctly or


otherwise, you may see any of these versions referred to as one of “Really Simple
Syndication,” “Rich Site Summary,” or “RDF Site Summary.” In practice, it is sim-
plest to refer to RSS by its acronym alone, and use a version number if you feel
the need to be specific.
2840ch09.qxd 7/13/04 12:44 PM Page 239
Download at Boykma.Com
Chapter 9
240
The good news is that amid this riot of colorful standards for RSS, the RSS
Portlet that we use to acquire and present syndicated content is quite agnostic.
You can import an RSS feed in formats 0.90 through to 2.0. The only thing that
you cannot import is invalid XML.
RSS is not the only game in town—there are various other standards for mak-
ing this type of meta-information available and for syndicating content. Although
we won’t be covering them any further, you should be familiar with RDF (which
we’ve already mentioned) and the up-and-coming “Atom” standard (in development
at
www.atomenabled.org
), which aims to be a more “standard” standard!
Walking Through an Example RSS File
Let’s now take a look at some concrete examples of RSS feeds in the most com-
monly encountered 0.9 and 0.91 formats. Both formats provide a number of
optional elements, but for the most part we will ignore these in favor of those
most commonly encountered “in the wild.”
Version 0.9
The following is a correct RSS 0.9 feed describing the authors’ web site, including
the compulsory elements and some of the optional ones:
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf=" />xmlns=" /><channel>

<title>PortalBook Technical Notes</title>
<link> /><description>
Discourse and exposition on Java and
developing Portlets
</description>
</channel>
<item>
<title>New version of Jetspeed released</title>
<link>
/></link>
</item>
2840ch09.qxd 7/13/04 12:44 PM Page 240
Download at Boykma.Com
RSS and Syndication
241
<item>
<title>Collections and iterations</title>
<link>
/></link>
</item>
<item>
<title>Deprecated techniques</title>
<link>
/></link>
</item>
</rdf:RDF>
The format is so simple it barely needs explanation, which is indubitably one
of the reasons for the enthusiastic early take-up.
The first version of RSS was a valid RDF document. As such it fell within the
RDF namespace defined by the W3C. The simple elements required by Netscape’s

format are specified in the default namespace:
<rdf:RDF
xmlns:rdf=" />xmlns=" />The
<channel>
element contains the metadata for the feed—its title, the site
from which it can be obtained, and a human-readable description of its content.
One of the deficiencies of the 0.9 format over later submissions is that it is restricted
to a single channel, so a web site proffering diverse subject matter must provide
multiple distinct feeds rather than a single RSS feed with multiple channels:
<channel>
<title>PortalBook Technical Notes</title>
<link> /><description>
Discourse and exposition on Java and
developing Portlets
</description>
</channel>
The
<item>
element repeats multiple times, once for each article or item of
interest that is being publicized in the feed. There is a hard limit of 15 items
permissible in the channel. The items includes a title describing the data to be
2840ch09.qxd 7/13/04 12:44 PM Page 241
Download at Boykma.Com
Chapter 9
242
propagated and a link to the data in question. This extremely sparse information
is all that is permitted:
<item>
<title>Deprecated techniques</title>
<link>

/></link>
</item>
Version 0.91
The following is a correct RSS 0.91 feed describing the authors’ web site, including
the compulsory elements and some of the optional ones.
<?xml version="1.0"?>
<rss version="0.91">
<channel>
<title>PortalBook Technical Notes</title>
<link> /><description>
Discourse and exposition on Java
and developing Portlets
</description>
<language>en-us</language>
<copyright>
Copyright: (C) 2003 Dave Minter
and Jeff Linwood
</copyright>
<item>
<title>New version of Jetspeed released</title>
<link> /><description>
We let you know the latest changes
and improvements to the Jetspeed
portlet server in the new version.
</description>
</item>
<item>
<title>Collections and iterations</title>
2840ch09.qxd 7/13/04 12:44 PM Page 242
Download at Boykma.Com

RSS and Syndication
243
<link> /><description>
Misuse of Collections can result in hidden
nested iterations that rapidly become a
serious performance drag. We discuss how
to avoid this and similar pitfalls.
</description>
</item>
<item>
<title>Deprecated techniques</title>
<link> /><description>
Bad habits die hard. We discuss some of the
techniques that were legitimate in older
versions of Jetspeed and the approaches that
should replace them.
</description>
</item>
</channel>
</rss>
This format is not quite as simple as that of version 0.9 but does contain some
compensatory features.
The version of RSS is specified in this version, making it a little easier to keep
track of what data is incoming:
<rss version="0.91">
Again only one channel is permitted by the standard. In this version, however,
the
<channel>
element encompasses all of the subsequent items along with the
channel’s metadata:

<channel>
Rather more information about the channel is available in a 0.91 feed. As well
as the title, link, and description, we are provided with an associated language and
copyright information:
<title>PortalBook Technical Notes</title>
<link> /><description>
Discourse and exposition on Java
and developing Portlets
</description>
2840ch09.qxd 7/13/04 12:44 PM Page 243
Download at Boykma.Com
Chapter 9
244
<language>en-us</language>
<copyright>
Copyright: (C) 2003 Dave Minter
and Jeff Linwood
</copyright>
The
<item>
elements are also rather better equipped. In addition to the
<title>
and
<link>
elements, we have a description. This is usually populated with an
abstract of the content that is to be covered in the associated link:
<item>
<title>New version of Jetspeed released</title>
<link> /><description>
We let you know the latest changes

and improvements to the Jetspeed
portlet server in the new version.
</description>
</item>
This version of the standard is not limited to 15 item elements, but enough
software exists that makes this assumption that we figure it is safer to so limit it.
Version 2.0
The following is a correct RSS 2.0 feed describing the authors’ web site, including
the compulsory elements and some of the optional ones:
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>PortalBook Technical Notes</title>
<link> /><description>
Discourse and exposition on Java and
developing Portlets
</description>
<language>en-us</language>
<copyright>
Copyright: (C) 2003 Dave Minter
and Jeff Linwood
</copyright>
2840ch09.qxd 7/13/04 12:44 PM Page 244
Download at Boykma.Com

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×