CS 371, Fall 2001
Lab 9, Part 1: XML and CSS

The goal of this lab is to create a small, well-formed XML document that uses a set of tags of your own design, and to write a CSS style sheet that will make it possible to display your document in Mozilla and other XML/CSS-capable Web browsers.

You should make printouts of your XML and CSS files, and you should add a link to the XML file to your main Web page. This is part one of a two-part lab on XML. The second part of the lab will take place on Friday, November 30. The combined lab report for the two parts of the lab will be due on Wednesday, December 5.

Writing XML

With XML, it is possible to design your own language. You can select a set of tags that best expresses the structure of the document or data that you want to represent. The first step in this lab is write an XML document based on a set of tags of your own design. Note that you are trying to do more that display some particular data. You are to design a tag language that could also be used for other data of the same type.

The XML document should be at least 25 lines long, and it should use at least six different tags. The document can be about one of the following topics, or you can choose your own topic:

We looked at an example of something like this in class. You can find a more fully worked-out example in the file schedule.xml. There is copy of this file in the directory /home/cs371. To view this example in formatted form in your xml-capable Web browser, click here. (This will work in Mozilla and will mostly work in Opera.)

When you have written your document, view it using the Mozilla Web browser. If your document is well-formed XML, you will see all the text from the document displayed as one large paragraph. If it is not well-formed, Mozilla will display an error message. (If by some chance you get things right the first time, you should introduce some error in the document just to see what Mozilla does with it.)

Using CSS with XML

The second step in this lab is to write a CSS style sheet that can be used with your XML document. The style sheet for my example can be found in the file schedule_style.css, which you will also find in the directory /home/cs371.

Don't forget that you will have to set the display style of some of your tags, since XML tags have no pre-set display style. Some of your tags can just use the default display style, inline. But if you want to avoid having all the text in one big paragraph, you will have to set the style for some tags. For the most part, you will want to use a display style of block or list-item, but I would be happy if you could get tables to work using the table display styles from page 201 of XML in a Nutshell.

David Eck, 16 November 2001