the iCite net > news / blog > a permalink

news and thoughts on and around the development of the iCite net
by Jay Fienberg

Example XQuery for RSS feeds mashup

posted: Jan 11, 2004 11:58:38 PM

As previously mentioned, I am having good luck working with XQuery. Today, I was experimenting with pulling multiple RSS feeds together into a single feed. Here is a sample XQuery and result:

the XQuery looks like (note: URLs shortened for appearance):

<rss version="0.92">
{
let $url := (
	"http://icite.net/blog/. . .,
	"http://jena.hpl.hp.com:3030/blojsom-devt/blog/. . .,
	"http://www.blojsom.com/blog/. . . 
	)
let $a := for $i in $url 
	let $b := doc($i)/rss/channel 
	return
	$b/title union $b/item

let $a := <t> {$a} </t>	
return 
	<channel>
	<title>blog mosh</title>
	<description>feeds from: {
		fn:string-join($a/title/text(), ", ")
		} moshed up via XQuery
	</description>
	<language>en</language>
	{ $a/item }
	</channel>
}
</rss>

(Unedited, source XQuery here.)

Basically, the XQuery says: 1) here are some URLs, 2) grab the title and item nodes within the /rss/channel nodes found at those URLs, 3) return stuff in a format that matches the RSS 0.92 format. (There is a little trick in there in that the new feed title lists the titles of each source feed.)

Because there are three source URLs, the result is a mashup RSS feed with three entries, one each from my blog, the HP Semantic Blogging Demonstrator, and David Czarnecki's blog respectively. Here is the full query result XML file.

You might notice that I chose three blogs that all run on blojsom. I did this because I know how each blojsom blog entry can be seen, by itself, as RSS. This example works with single posts in RSS only to keep the result brief—full feed mashups also work!

For my next experiment, I am thinking of creating an interactive XQuery form on this site (i.e., a web UI to the XQuery interface of Saxon). I also want to experiment more with combining X/HTML pages, but I think I need to add a Tidy process in the loop to get XML clean enough for Saxon / XQuery to process.

permalink | comments {0} · trackbacks {0}

also available as: rss · rss2 · rdf · atom

Comments and Tracbacks

Note: All comments and trackbacks are moderated. Spam is deleted. Other comments are approved as promptly as possible.

Note: Older posts no longer accept new comments or trackbacks.

« prev post
XQuery may be it

» next post
Interesting what others are saying about XQuery

blog newsfeeds

brief content:

 XML  ·  RSS  ·  RDF  ·  Atom 


full content:

 XML  ·  RSS  ·  RDF  ·  Atom 


blog archive

2006:
jan · feb · mar · apr
may · jun · jul · aug 
sep · oct · nov · dec
		
2005:
jan · feb · mar · apr
may · jun · jul · aug
sep · oct · nov · dec

2004:
jan · feb · mar · apr
may · jun · jul · aug
sep · oct · nov · dec

2003:
may · jun · jul · aug
sep · oct · nov · dec

first post: 
April 30, 2003

highlight views:
Spammers' Choice
		

Jay elsewhere online
Jay Fienberg - the official home page

Wrong Notes - the music blog of the Ear Reverends

Fine & Full, aka, a fine and full burger

Sociomobilepoetextologia (moblog, currently inactive due to lack of proper mobile)

to enjoy roll
sites I like to read when I start from here

· Anastasia Fuller
· Andy Baio
· Biz Stone
· Boris Mann
· Bre Pettis
· Chris Dent
· Danny Ayers
· Dare Obasanjo
· David Czarnecki
· David Weinberger
· Don Park
· Evan Williams
· Greg Narain
· Jason Kottke
· Jim Benson
· Lucas Gonze
· Marc Canter
· Matt May
· Matt Mullenweg
· Michal Migurski
· Nancy White
· Rebecca Blood
· Reg Cheramy
· Richard MacManus
· Sam Ruby
· Shelley Powers
· Tim Bray
· danah boyd


powered by blojsom


Entries by blojsim