{"id":901,"date":"2007-01-10T12:05:10","date_gmt":"2007-01-10T20:05:10","guid":{"rendered":"http:\/\/cephas.net\/blog\/2007\/01\/10\/rome-and-custom-generator-elements\/"},"modified":"2007-01-10T12:05:10","modified_gmt":"2007-01-10T20:05:10","slug":"rome-and-custom-generator-elements","status":"publish","type":"post","link":"https:\/\/cephas.net\/blog\/2007\/01\/10\/rome-and-custom-generator-elements\/","title":{"rendered":"ROME and custom Generator elements"},"content":{"rendered":"<p>The majority <a href=\"http:\/\/wiki.java.net\/bin\/view\/Javawsxml\/Rome05TutorialFeedWriter\">of<\/a> <a href=\"http:\/\/www.xml.com\/pub\/a\/2006\/02\/22\/rome-parse-publish-rss-atom-feeds-java.html\">the<\/a> <a href=\"http:\/\/today.java.net\/pub\/a\/today\/2006\/02\/02\/tour-of-rome.html\">articles<\/a> I&#8217;ve seen on using ROME to create Atom and RSS feeds don&#8217;t show you how to customize the optional &#8216;generator&#8217; element that both <a href=\"http:\/\/www.atomenabled.org\/developers\/syndication\/atom-format-spec.php#element.generator\">Atom<\/a> and <a href=\"http:\/\/blogs.law.harvard.edu\/tech\/rss#optionalChannelElements\">RSS<\/a> support. It&#8217;s really easy. I&#8217;m assuming that you&#8217;ve already created and populated a SyndFeed instance:<\/p>\n<pre>\r\nSyndFeed feed = ..\r\nWireFeedOutput feedOutput = new WireFeedOutput();\r\nWireFeed wireFeed = feed.createWireFeed();\r\nif (wireFeed.getFeedType().startsWith(\"atom\")) {\r\n  Feed atomFeed = (Feed)wireFeed;\r\n  Generator gen = new Generator();\r\n  gen.setUrl(\"http:\/\/yoursite.com\/\");\r\n  gen.setValue(\"Your Site\");\r\n  gen.setVersion(\"1.0\");\r\n  atomFeed.setGenerator(gen);\r\n  feedOutput.output(atomFeed, ...);\r\n} else {\r\n  Channel rssFeed = (Channel)wireFeed;\r\n  rssFeed.setGenerator(\"Your Site 1.0 (http:\/\/yoursite.com\/)\");\r\n  feedOutput.output(rssFeed, ...);\r\n}\r\n<\/pre>\n<p>Make a decision about which feed you&#8217;re going to produce, cast to the appropriate implementation of WireFeed (<a href=\"https:\/\/rome.dev.java.net\/apidocs\/0_9\/com\/sun\/syndication\/feed\/rss\/Channel.html\">Channel<\/a> for RSS and <a href=\"https:\/\/rome.dev.java.net\/apidocs\/0_9\/com\/sun\/syndication\/feed\/atom\/Feed.html\">Feed<\/a> for Atom), and then use the appropriate setters on each of those respective classes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The majority of the articles I&#8217;ve seen on using ROME to create Atom and RSS feeds don&#8217;t show you how to customize the optional &#8216;generator&#8217; element that both Atom and RSS support. It&#8217;s really easy. I&#8217;m assuming that you&#8217;ve already created and populated a SyndFeed instance: SyndFeed feed = .. WireFeedOutput feedOutput = new WireFeedOutput(); &hellip; <a href=\"https:\/\/cephas.net\/blog\/2007\/01\/10\/rome-and-custom-generator-elements\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">ROME and custom Generator elements<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,32,10],"tags":[],"_links":{"self":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/901"}],"collection":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/comments?post=901"}],"version-history":[{"count":0,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/901\/revisions"}],"wp:attachment":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/media?parent=901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/categories?post=901"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/tags?post=901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}