Lab Sheet 2: XML from Scratch and DTDs

It's time to get our hands a bit dirty and work directly with the code, creating our very own xml vocabulary. Some of the work in this lab is tedious but will enable us to understand some of the characteristics of xml that make it an attractive technology.

There are links to online resources supporting this lab in the xml section of the clog.

  1. Creating an XML document that conforms to a DTD:

    Create two distinctly different documents that conform to assignment.dtd. Use the XML Validator at Brown University to validate your documents against the dtd. (For simplicity you can make the dtd internal to the XML document and use the validators paste option.)
  2. User-Defined XML Dialects:

    Create an XML document to represent your CD collection. To make things interesting in subsequent sections of the lab you should make sure to include
    1. a cd element
    2. a year element for each cd element that stores the year the cd was produced;
    3. a cd_graphic atttribute for each cd element whose value is the uri of an image file.
  3. Creating a DTD

    Create an in-document DTD that defines the syntax of your CD collection XML dialect that constrains the kinds of documents that conform to the dtd to only include those that have at least one cd element; each cd element should have exactly one year element and may or may not have a cd_graphic attribute. Validate the document.
  4. Creating an XML Schema

    Creating a Schema (.xsd file) that defines the syntax of your schedule XML dialect in such a way that constrains the kinds of documents that conform to the schema to only include those that satisfy the following:
    1. have at least one cd element;
    2. each cd element has exactly one year element whose value lies between 1982 and 2012;
    3. each cd element has a cd_graphic attribute of the form *.gif or *.jpg
    Validate the document. Use an XML Schema Validator to validate your documents against an xml schema. (remark: courses.xsd is an xml schema document for courses.xml. This can serve as a model as you work through your cd document.
  5. Uploading Work to Personal Web Page:

    Upload your work in this lab to your personal page.