Exercises for Lecture 1

Consider a collection of recipes stored in raw text files such as this example. We design an XML version of a recipe collection:

This example (formatted XML file) contains five recipes. Abbreviated version:

<?xml version="1.0" encoding="UTF-8"?>
<collection>
  <description>
     Some recipes used for the XML tutorial.
  </description>
  <recipe>
    <title>Beef Parmesan with Garlic Angel Hair Pasta</title>
    <ingredient name="beef cube steak" amount="1.5" unit="pound"/>
    ...
    <preparation>
      <step>
        Preheat oven to 350 degrees F (175 degrees C).
      </step>
      ...
    </preparation>
    <comment>
      Make the meat ahead of time, and refrigerate over night, the acid in the
      tomato sauce will tenderize the meat even more. If you do this, save the
      mozzarella till the last minute.
    </comment>
    <nutrition calories="1167" fat="23" carbohydrates="45" protein="32"/>
  </recipe>
  ...
</collection>

Note that XML documents (usually) begin with an XML declaration (<?xml ...?>)

  1. Add this ravioli recipe to the recipe collection XML file. Make sure the result is wellformed XML.

  2. Design an XML language to represent weblogs, that is, diaries aimed for publication on the web. There are countless different solutions, try to keep it simple.

  3. Use the W3C validator to check whether www.jp.dk and www.microsoft.com (or some other Web pages) are valid HTML. If not, see what kinds of errors there are.

  4. This HTML page heavily uses physical markup (ex. <i>, <tt>, <font>, color="blue", ...).

  5. Study the list of selected online XML resources from the slides and the collection of XML applications.

Tips

To check that an XML document file.xml is wellformed XML, you can either

To run the W3C validator on a page without a DOCTYPE and encoding, try using "HTML 4.01 Transitional" and "iso-8859-1".