Back to Home

Back Home

Elements of a Feed are the Feed itself and Entries

* Entry ID Title Date Author(s) Category Summary Content == RSS Limitations == * Spec is loose * What fields can be escaped HTML? * How many enclosures are allowed per item? * Content model is weak * No support for summary and content * Content-type and escaping not specified * Specification is final and cannot be clarified == Atom == Atom Publishing Format An XML feed format; feed contains entries Entries are: * Time-stamped, uniquely ID’ed chunks of data * With meta-data: title, dates, categories * Entry content can be: * TEXT, HTML, XHTML or any content-type * In-line or out-of-line specified by URI * Entry Binary data w/Base64 encoding Feed * Id Title Title It’s generic, not just for blog == Dublin Core == Dublin core specified 15 attributes common to RDF documents including * title, creator, subject, description, publisher, contributor .. == Implemenations == * Rome - dom based implementaiton * Apache Abdera - stax based Atom implementation == Rome Implementation == Rome's unified implementation can generate Atom or RSS  Feed Model Fetching a Feed With ROME Fetcher, Note: ROME’s Fetcher provides a caching feed-store <code java> FeedFetcherCache cache = new DiskFeedInfoCache(quot;/var/rome-fetcher/cachequot;); FeedFetcher fetcher = new HttpURLFeedFetcher(cache); SyndFeed feed = fetcher.retrieveFeed( new URL(quot;http://bugtracker/feeds/bugreportquot;)); Iterator entries = feed.getEntries().iterator(); while (entries.hasNext()) { SyndEntry entry = (SyndEntry); … omitted: print out entry … } </code> == Rome Generating Atom == <code java> public String process(@Payload String payload) { try { String feedType = “atom_1.0”; SyndFeed syndFeed = new SyndFeedImpl(); syndFeed.setTitle(“Latest bugs”); syndFeed.setAuthor(“BugTrack-9000-XL”); syndFeed.setPublishedDate(new Date()); syndFeed.setLink(“http://localhost/bugtracker”); syndFeed.setUri(syndFeed.getLink()); syndFeed.setFeedType(feedType); mandatory SyndLink selfLink = new SyndLinkImpl(); selfLink.setRel(“self”); selfLink.setHref(“http://localhost/bugtracker/latest.atom”); syndFeed.setLinks(Collections.singletonList(selfLink)); List entries = new ArrayList(); syndFeed.setEntries(entries); create 20 fake entries for (int i = 0; i < 20; i++) { SyndEntry entry = new SyndEntryImpl(); entry.setTitle(“Title ” + i); entry.setUpdatedDate(new Date()); entry.setLink(“” + i); entry.setUri(entry.getLink()); SyndContent content = new SyndContentImpl(); content.setValue(“contet ” + i); content.setType(“html”); entry.setContents(Collections.singletonList(content)); entries.add(entry); } Writer writer = new StringWriter(); SyndFeedOutput output = new SyndFeedOutput(); output.output(syndFeed, writer); return writer.toString(); } catch (Exception e) { e.printStackTrace(); return “”; } } </code> Advanced (Todo) try and use an OutputStream .. to stream results? Where mule supports streaming to File, FTP, HTTP (and HTTPS), Jetty and Jetty SSL == Wirefeed Output == Using Rome one can convert from the format-independent SyndFeed interface to a specific wirefeed “type” These type strings are supported by default in ROME: * rss_0.9, rss_0.91N, rss_0.91U, rss_0.92, rss_0.93, rss_0.94, rss_1.0, rss_2.0, atom_0.3, atom_1.0 === Note: Set Content Type === Set the generated content type * application/rss+xml * application/atom+xml == Feed Auto Discovery == Use html tags to indicate that the page/site has an associated rss feed: <code html> <html> <head> <meta http-equiv=“Content-Type” content=“text/html” /> <link rel=“alternate” type=“application/atom+xml” title=“Latest bugs (Atom)” href=“http://bugtracker/feeds/bugreport” /> <link rel=“alternate” type=“application/rss+xml” title=“Latest bugs (RSS)” href=“http://bugtracker/feeds/bugreport?format=rss” /> </code> == Extensions == * Google Data using Atom Publishing Protocol * Lucene—WS using Atom Publishing Protocol == Links and References == * - validates feeds * Another good description

rome.txt · Last modified: 2013/09/01 11:18 by root