Dave Johnson on open web technologies, social software and software development
« Hey, I wrote that | Main | Sealing deals faster... »
I spent some time exploring the new Rome feed parser for Java and trying to understand how it works. Along the way, I put together the following class diagram and notes on the parsing process. I provide some pointers into the Rome 0.3 Javadocs, but, because this summary is based on the latest Rome codebase from CVS you will notice that some class and interface names have changed.
You don't need to know this stuff to use Rome, but it you are interested in internals you might find it interesting.
Notes on the Rome parsing processRome is based around an idealized and abstract model of a Newsfeed or "Syndication Feed." Rome can parse any format of Newsfeed, including RSS variants and Atom, into this model. Rome can convert from model representation to any of the same Newfeed output formats.
Internally, Rome defines intermediate object models for specific Newsfeed formats, or "Wire Feed" formats, including both Atom and all RSS variants. For each format, there is a separate JDOM based parser class that parses XML into an intermediate model. Rome provides "converters" to convert between the intermediate Wire Feed models and the idealized Syndication Feed model.
Rome makes no attempt at Pilgrim-style liberal XML parsing. If a Newsfeed is not valid XML, then Rome will fail. Perhaps, as Kevin Burton suggests, parsing errors in Newsfeeds can and should be corrected. Kevin suggests that, when the parse fails, you can correct the problem and parse again. (BTW, I have some sample code that shows how to do this, but it only works with Xerces - Crimsom's SAXParserException does not have reliable error line and column numbers.)
Here is what happens during Rome Newsfeed parsing:
<img src="http://rollerweblogger.org/resources/roller/HowRomeWorks.png" alt="diagram of Rome classes and the parsing process." style="align:center" />URL feedUrl = new URL("file:blogging-roller.rss"); SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new InputStreamReader(feedUrl.openStream()));
Rome supports Newsfeed extension modules for all formats that also support modules: RSS 1.0, RSS 2.0, and Atom. Standard modules such as Dublic Core and Syndication are supported and you can define your own custom modules too.
Rome also supports Newsfeed output and for each Newsfeed format provides a "generator" class that can take a Syndication Feed model and produce from it Newsfeed XML.
Learning moreI've linked to a number of the Rome 0.3 Tutorials, here is the full list from the Rome Wiki:
Overall, Rome looks really good. It is obvious that a lot of thought has gone into design and a lot of work has been done on implementation (and docs). Rome is well on the way to "ending syndication feed confusion by supporting all of 'em" for us Java heads.
Please leave a comment if I have gotten something wrong.
Dave Johnson in Blogging
03:16PM Aug 08, 2004
Comments [6]
Tags:
Blogging
This is just one entry in the weblog Blogging Roller. You may want to visit the main page of the weblog
Below are the most recent entries in the category Blogging, some may be related to this entry.
Posted by Charles Miller on August 09, 2004 at 10:10 AM EDT #
Posted by Lance Lavandowska on August 09, 2004 at 12:33 PM EDT #
Posted by Nick Lothian on August 09, 2004 at 01:56 PM EDT #
Posted by Paul Kilroy on August 09, 2004 at 05:02 PM EDT #
Posted by 216.54.164.11 on August 10, 2004 at 04:47 PM EDT #
Posted by Dave Johnson on August 10, 2004 at 05:24 PM EDT #