Chapter 4. Intermediate Usage

This chapter covers topics that you will probably find very helpful, though they are not essential.

4.1. Join Mode: Putting multiple feeds together

Let's say you want to keep track of more than one feed at once. You could do a number of calls to paperboy and view them all separately, or you could use paperboy's join mode (-j). If you use the join mode, you will be able to aggregate multiple feeds into one page. To make join mode possible, multiple files and URLs are passed to paperboy, then the root element of each file is placed under a new root (<root>). So, if you had a couple of files that looked like this:


<rss>
	<channel>
		<title>My Feed</title>
		etc...
	</channel>
</rss>
			

Then the aggregated feed (passed to the XSLT processor) would look like this:


<root>
	<rss>
		<channel>
			<title>My Feed</title>
			etc...
		</channel>
	</rss>
	<rss>
		<channel>
			<title>My Feed</title>
			etc...
		</channel>
	</rss>
</root>
			

As you might guess, you need a template which is designed to understand this new layout. Thankfully that's a very easy thing to do; For information on how to write XSLT stylesheets that work with join mode, see the tutorial*.xsl series or the XSLT chapter. In an nutshell, you will go to the root element, and then apply templates for each <rss> element. For join mode to do anything meaningful, multiple -u/-f pairs should be passed to paperboy. (It will work just fine on one feed, but why would you bother?) As described before, these flag pairs are associated in a first-in/first-out manner, so the first URL would go with the first file, the second URL would go with the second file, etc... regardless of any intervening flags. So finally, here is an example of how paperboy would be called with join mode enabled:


kryptech@debian:~/xml$ paperboy -f blogentries.xml -f wrenupdates.xml -u
http://collab.freegeek.org/~wren/rss/blog.rss -u http://collab.freegeek.org/~wren/rss/updates.rss
-t tutorial1.xsl -o feeds.html -j