Question: *SimpleReader/Writer are part of OSU CSE Components RSSReader.java: import components.simplereader.SimpleReader; import components.simplereader.SimpleReader1L; import components.simplewriter.SimpleWriter; import components.simplewriter.SimpleWriter1L; import components.xmltree.XMLTree; import components.xmltree.XMLTree1; /** * Program to convert
*SimpleReader/Writer are part of OSU CSE Components
RSSReader.java:
import components.simplereader.SimpleReader; import components.simplereader.SimpleReader1L; import components.simplewriter.SimpleWriter; import components.simplewriter.SimpleWriter1L; import components.xmltree.XMLTree; import components.xmltree.XMLTree1; /** * Program to convert an XML RSS (version 2.0) feed from a given URL into the * corresponding HTML output file. * * @author Put your name here * */ public final class RSSReader { /** * Private constructor so this utility class cannot be instantiated. */ private RSSReader() { } /** * Outputs the "opening" tags in the generated HTML file. These are the * expected elements generated by this method: * * * * the channel tag title as the page title * * *
the page title inside a link to the link
*
the channel description
*
*
*
Date
*
Source
*
News
*
* * @param channel * the channel element XMLTree * @param out * the output stream * @updates out.content * @requires [the root of channel is a tag] and out.is_open * @ensures out.content = #out.content * [the HTML "opening" tags] */ private static void outputHeader(XMLTree channel, SimpleWriter out) { assert channel != null : "Violation of: channel is not null"; assert out != null : "Violation of: out is not null"; assert channel.isTag() && channel.label().equals("channel") : "" + "Violation of: the label root of channel is a tag"; assert out.isOpen() : "Violation of: out.is_open"; /* * TODO: fill in body */ } /** * Outputs the "closing" tags in the generated HTML file. These are the * expected elements generated by this method: * *
* * * * @param out * the output stream * @updates out.contents * @requires out.is_open * @ensures out.content = #out.content * [the HTML "closing" tags] */ private static void outputFooter(SimpleWriter out) { assert out != null : "Violation of: out is not null"; assert out.isOpen() : "Violation of: out.is_open"; /* * TODO: fill in body */ } /** * Finds the first occurrence of the given tag among the children of the * given {@code XMLTree} and return its index; returns -1 if not found. * * @param xml * the {@code XMLTree} to search * @param tag * the tag to look for * @return the index of the first child of type tag of the {@code XMLTree} * or -1 if not found * @requires [the label of the root of xml is a tag] * @ensures
* getChildElement = * [the index of the first child of type tag of the {@code XMLTree} or * -1 if not found] *
*/ private static int getChildElement(XMLTree xml, String tag) { assert xml != null : "Violation of: xml is not null"; assert tag != null : "Violation of: tag is not null"; assert xml.isTag() : "Violation of: the label root of xml is a tag"; /* * TODO: fill in body */ } /** * Processes one news item and outputs one table row. The row contains three * elements: the publication date, the source, and the title (or * description) of the item. * * @param item * the news item * @param out * the output stream * @updates out.content * @requires * [the label of the root of item is an tag] and out.is_open * @ensures
* out.content = #out.content * * [an HTML table row with publication date, source, and title of news item] *
*/ private static void processItem(XMLTree item, SimpleWriter out) { assert item != null : "Violation of: item is not null"; assert out != null : "Violation of: out is not null"; assert item.isTag() && item.label().equals("item") : "" + "Violation of: the label root of item is an tag"; assert out.isOpen() : "Violation of: out.is_open"; /* * TODO: fill in body */ } /** * Main method. * * @param args * the command line arguments; unused here */ public static void main(String[] args) { SimpleReader in = new SimpleReader1L(); SimpleWriter out = new SimpleWriter1L(); /* * TODO: fill in body */ in.close(); out.close(); } } RSS (Really Simple Syndication) is an XML application for distributing web content that changes frequently. Many news- related sites, weblogs and other online publishers syndicate their content as an RSS Feed to whoever wants it. For this project your task is to write a program that asks the user for the URL of an RSS 2.0 feed and for the name of an output file including the .html extension, reads the RSS feed into an XML Tree object and then uses the information in the XML Tree object to generate in the output file a nicely formatted HTML page with table of links to all the news items in the original feed. Input: RSS 2.0 XML Document Here is a simplified description of the structure of an RSS 2.0 XML document. RSS 2.0 documents can contain a few other tags and features, but these are the ones you will need for the project. Title goes here Link goes here Description goes hereOptional title goes hereOptional description goes here Optional link goes here Optional publication date goes hereOptional source goes here Note the following properties of RSS 2.0 XML documents: The children of the channel> tag and of the tag can occur in any order; do not assume they will appear in the order above. Furthermore there can be other children of other types not listed above. , , and are required children of the tag, i.e., you should assume they are present. However, and may be blank, i.e., they may not have any text child. All the children of tag are optional, i.e., do not assume they are present; but, either or must be present. However, the and/or tags, even if present, may be blank, i.e., they may not have any text child. Ifa tag appears as a child of an tag, it must have a url attribute. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Note that when your program creates an XML Tree object from a given RSS 2.0 feed, if it is successful, all you know is that the input is a valid XML document. It is up to your program to check that the label of the root of the XML Tree is an tag and that it has a version attribute with value "2.0". After that, your program can assume that the input is indeed a valid RSS 2.0 feed and the XML Tree has the structure described above; in other words, you do not need to check for the existence of the channel> tag, or the , , and tags inside that. Make sure you do not make any assumptions that are not specified in the structure described above and, in particular, make sure to check that the channel's and tags and each item's and tags have a child before trying to access it. However, the and , if present, are required to have a child with the needed information. (See slide #9 in RSS for a diagram capturing these requirements.) Output: HTML Web Page These are the minimum requirements for the generated web page. If you think you can produce better output or include more information, you should consult your instructor to make sure that any changes you want to implement are acceptable. This is what your output should include: the channel> title as the page title (or "Empty Title" if the tag has no children) a header with the page title inside a link to the link . a paragraph with the channel> description (or "No description" if the description> tag has no children) a table with appropriate headers, each row should correspond to one news item with the following columns: the publication date, if present, or "No date available" o the source, if present, which should be linked to the source url, or "No source available" o the title, if present and not empty, or the description, if not empty, or "No title available", which should be linked if a link for the news item is available You can see an example of the output here (note that the links may be outdated and no longer available). Method 1. Create a new Eclipse project by copying Project Template and name the new project RssReader. 2. Open the src folder of this project and then open (default package). As a starting point you can use any of the Java files. Rename it RSS Reader and delete the other files from the project. Open the RSS Reader.java file in the editor. 3. Follow the link to RSS Reader.java, select all the code on that page, copy it to the clipboard, and paste it into Eclipse's editor window to replace the skeleton code. 4. Edit RSSReader.java to satisfy the problem requirements stated above by completing the methods provided. 5. Select your Eclipse project RSS Reader (not just some of the files, but the whole project), create a zip archive of it, and submit the zip archive to the Carmen dropbox for this project, as described in Submitting a Project. Referenced Slide Example XMLTree Created rss version 2.0 No order guaranteed among children No order guaranteed among children citem> Yahoo! News http:/ews.yahoo.com The latest news and headlines from Yahoo! News. clinto url http://www.reuters.com Apple seeks to stop... http:// news.yahoo.com/.. Apple Inc will seek a... Mon, 27 Aug 2012 14:40:49 Reuters REQUIRED AT LEAST ONE REQUIRED REQUIRED, IF PARENT PRESENT NOT REQUIRED Example Output Example Output Yahoo! News - Latest News & Headlines The latest news and headlines from Yahoo! News. Get breaking news stories and in-depth coverage with videos and photos. Date Source News Mon, 27 Aug 2012 17:13:44 -0400 No source available Obama promises to help Gulf Coast governors with TS Isaac Mon, 27 Aug 2012 15:13:46-0400 No source available Romney vows free-market defense as GOP opens convention Mon, 27 Aug 2012 12:02:51 -0400 ABC News Student critically wounded on first day of school: teacher subdues gumman Mon, 27 Aug 2012 17:14:09 -0400 No source available Mike Huckabee to Ron Paul supporters: You lost, move on Mon, 27 Aug 2012 10:03:33 -0400 No source available Romney admits Democratic attacks are huting him with voters Mon, 27 Aug 2012 14:42:25 -0400 Associated Press Soldiers. Marines punished for misconduct in Afghanistan Mon, 27 Aug 2012 14:40:49 -0400 Reuters Apple seeks to stop U.S. sales of eight Samsung.products Fri, 24 Aug 2012 12:00:37 -0400 No source available Photos: See issues voters want addressed at the RNC Mon, 27 Aug 2012 14:35:21-0400 Associated Press Commissioner defends police force in NYC gun fight Mon, 27 Aug 2012 13:14:46 -0400 No source available The speech that Nixon never gave: In event of moon disaster Mon, 27 Aug 2012 15:04:26 -0400 No source available World may be forced to go vegetarian by 2050. scientists say Mon, 27 Aug 2012 14:04:51 -0400 No source available Meet the worlds dumbest dumbphone Mon, 27 Aug 2012 16:13:17-0400 Good Moming America World's oldest person. Besse Cooper, tums 116 Mon, 27 Aug 2012 10:01:37 -0400 Good Moming America Bill Nye 'The Science Guy' hits evolution deniers Mon, 27 Aug 2012 07:32:32 -0400 SPACE.com Blue moon' to light up night sky this week Mon, 27 Aug 2012 14:34:38 -0400 Good Moming America Do our genes determine how we vote in elections? Mon, 27 Aug 2012 16:02:17-0400 AFP UN chief leads world outcry over Syria 'massacre' Mon, 27 Aug 2012 02:07:10 -0400 Associated Press Series of earthquakes rattle Southem Califomia Mon, 27 Aug 2012 11:57:05 -0400 LiveScience.com One small step for (a) man': Was Neil Armstrong misquoted? Mon, 27 Aug 2012 06:55:55 -0400 Associated Press Killed for dancing: 17 Afghans beheaded in attack on party Sun, 26 Aug 2012 17:21:13 -0400 Reuters Ex-South Carolina governor to many former mistress RSS (Really Simple Syndication) is an XML application for distributing web content that changes frequently. Many news- related sites, weblogs and other online publishers syndicate their content as an RSS Feed to whoever wants it. For this project your task is to write a program that asks the user for the URL of an RSS 2.0 feed and for the name of an output file including the .html extension, reads the RSS feed into an XML Tree object and then uses the information in the XML Tree object to generate in the output file a nicely formatted HTML page with table of links to all the news items in the original feed. Input: RSS 2.0 XML Document Here is a simplified description of the structure of an RSS 2.0 XML document. RSS 2.0 documents can contain a few other tags and features, but these are the ones you will need for the project. Title goes here Link goes here Description goes hereOptional title goes hereOptional description goes here Optional link goes here Optional publication date goes hereOptional source goes here Note the following properties of RSS 2.0 XML documents: The children of the channel> tag and of the tag can occur in any order; do not assume they will appear in the order above. Furthermore there can be other children of other types not listed above. , , and are required children of the tag, i.e., you should assume they are present. However, and may be blank, i.e., they may not have any text child. All the children of tag are optional, i.e., do not assume they are present; but, either or must be present. However, the and/or tags, even if present, may be blank, i.e., they may not have any text child. Ifa tag appears as a child of an tag, it must have a url attribute. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Note that when your program creates an XML Tree object from a given RSS 2.0 feed, if it is successful, all you know is that the input is a valid XML document. It is up to your program to check that the label of the root of the XML Tree is an tag and that it has a version attribute with value "2.0". After that, your program can assume that the input is indeed a valid RSS 2.0 feed and the XML Tree has the structure described above; in other words, you do not need to check for the existence of the channel> tag, or the , , and tags inside that. Make sure you do not make any assumptions that are not specified in the structure described above and, in particular, make sure to check that the channel's and tags and each item's and tags have a child before trying to access it. However, the and , if present, are required to have a child with the needed information. (See slide #9 in RSS for a diagram capturing these requirements.) Output: HTML Web Page These are the minimum requirements for the generated web page. If you think you can produce better output or include more information, you should consult your instructor to make sure that any changes you want to implement are acceptable. This is what your output should include: the channel> title as the page title (or "Empty Title" if the tag has no children) a header with the page title inside a link to the link . a paragraph with the channel> description (or "No description" if the description> tag has no children) a table with appropriate headers, each row should correspond to one news item with the following columns: the publication date, if present, or "No date available" o the source, if present, which should be linked to the source url, or "No source available" o the title, if present and not empty, or the description, if not empty, or "No title available", which should be linked if a link for the news item is available You can see an example of the output here (note that the links may be outdated and no longer available). Method 1. Create a new Eclipse project by copying Project Template and name the new project RssReader. 2. Open the src folder of this project and then open (default package). As a starting point you can use any of the Java files. Rename it RSS Reader and delete the other files from the project. Open the RSS Reader.java file in the editor. 3. Follow the link to RSS Reader.java, select all the code on that page, copy it to the clipboard, and paste it into Eclipse's editor window to replace the skeleton code. 4. Edit RSSReader.java to satisfy the problem requirements stated above by completing the methods provided. 5. Select your Eclipse project RSS Reader (not just some of the files, but the whole project), create a zip archive of it, and submit the zip archive to the Carmen dropbox for this project, as described in Submitting a Project. Referenced Slide Example XMLTree Created rss version 2.0 No order guaranteed among children No order guaranteed among children citem> Yahoo! News http:/ews.yahoo.com The latest news and headlines from Yahoo! News. clinto url http://www.reuters.com Apple seeks to stop... http:// news.yahoo.com/.. Apple Inc will seek a... Mon, 27 Aug 2012 14:40:49 Reuters REQUIRED AT LEAST ONE REQUIRED REQUIRED, IF PARENT PRESENT NOT REQUIRED Example Output Example Output Yahoo! News - Latest News & Headlines The latest news and headlines from Yahoo! News. Get breaking news stories and in-depth coverage with videos and photos. Date Source News Mon, 27 Aug 2012 17:13:44 -0400 No source available Obama promises to help Gulf Coast governors with TS Isaac Mon, 27 Aug 2012 15:13:46-0400 No source available Romney vows free-market defense as GOP opens convention Mon, 27 Aug 2012 12:02:51 -0400 ABC News Student critically wounded on first day of school: teacher subdues gumman Mon, 27 Aug 2012 17:14:09 -0400 No source available Mike Huckabee to Ron Paul supporters: You lost, move on Mon, 27 Aug 2012 10:03:33 -0400 No source available Romney admits Democratic attacks are huting him with voters Mon, 27 Aug 2012 14:42:25 -0400 Associated Press Soldiers. Marines punished for misconduct in Afghanistan Mon, 27 Aug 2012 14:40:49 -0400 Reuters Apple seeks to stop U.S. sales of eight Samsung.products Fri, 24 Aug 2012 12:00:37 -0400 No source available Photos: See issues voters want addressed at the RNC Mon, 27 Aug 2012 14:35:21-0400 Associated Press Commissioner defends police force in NYC gun fight Mon, 27 Aug 2012 13:14:46 -0400 No source available The speech that Nixon never gave: In event of moon disaster Mon, 27 Aug 2012 15:04:26 -0400 No source available World may be forced to go vegetarian by 2050. scientists say Mon, 27 Aug 2012 14:04:51 -0400 No source available Meet the worlds dumbest dumbphone Mon, 27 Aug 2012 16:13:17-0400 Good Moming America World's oldest person. Besse Cooper, tums 116 Mon, 27 Aug 2012 10:01:37 -0400 Good Moming America Bill Nye 'The Science Guy' hits evolution deniers Mon, 27 Aug 2012 07:32:32 -0400 SPACE.com Blue moon' to light up night sky this week Mon, 27 Aug 2012 14:34:38 -0400 Good Moming America Do our genes determine how we vote in elections? Mon, 27 Aug 2012 16:02:17-0400 AFP UN chief leads world outcry over Syria 'massacre' Mon, 27 Aug 2012 02:07:10 -0400 Associated Press Series of earthquakes rattle Southem Califomia Mon, 27 Aug 2012 11:57:05 -0400 LiveScience.com One small step for (a) man': Was Neil Armstrong misquoted? Mon, 27 Aug 2012 06:55:55 -0400 Associated Press Killed for dancing: 17 Afghans beheaded in attack on party Sun, 26 Aug 2012 17:21:13 -0400 Reuters Ex-South Carolina governor to many former mistress
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
Students Have Also Explored These Related Databases Questions!