HW 3 - XPath CSE 413 Homework

This homework is due online Friday, Nov 4, before 10PM.

  1. You will use Lantern for this exercise. Download a copy of the program.
  2. Download and store a local copy of the allelements.xml file.
  3. The following questions can all be answered using various XPath expressions. Using Lantern, figure out the correct XPath expression to find the answer to each of the following questions. The word "element" in these questions refers to an XML element node, not to a chemical element.
    1. How many nodes of any type are there in the file?
    2. How many ATOM elements are there?
    3. How many ATOM elements have a STATE attribute?
    4. What is the NAME of the ATOM element whose SYMBOL is "He"?
    5. What is the BOILING_POINT of the ATOM whose NAME is "Neon"?
    6. What is the node set containing all the child elements of the ATOM whose SYMBOL is "Es"?
    7. Of the child elements found with the previous expression, select only the ones that have at least one attribute of some type.
    8. What are the UNITS (ie, value of the UNITS attribute) of the HEAT_OF_FUSION of the ATOM whose ATOMIC_NUMBER is 54?
  4. Create a simple XML file of your own that could be used to describe your class schedule this quarter. Name the file class-schedule.xml. The actual structure of the XML hierarchy is up to you - there are many reasonable ways to structure this data. Among other things, think about what the root element might be. Should any of the requested information be stored as attributes, or should child elements be used everywhere? There is no single best answer, so just take a stab at it and see how it works out. At minimum, the file should record the following characteristics of your class schedule.
    1. Your name (given name and surname)
    2. Your UWNetID
    3. A list of your classes this quarter, at least two and no more than three. If you are only taking one class, make up another one. Information about each class should include the following: Department, Class number, Class name, Schedule line number, and URL for class web site.
  5. Given the structure of the file you created in the previous step, create XPath expressions to extract the following information from your file. (Verify that they work using Lantern.)
    1. What is your name?
    2. How many classes are you taking?
    3. What are the names of the classes you are taking?
    4. What are the upper division classes you are taking (class number >= 300)?
  6. Turn in two files online before Friday Nov 4 at 10PM.
    1. A file containing the list of XPath expressions for the allelements.xml file and the list of XPath expressions for your class schedule file.
    2. Your class schedule xml file.