CS1102 Lab 1

General information

Derek, what are you expecting from me?
Why should I bother?
Apart from the sheer intellectual joy of it?

Well, because some of the work will count towards your overall mark for CS1102.

Which labs will count towards my overall mark?
This information will not be divulged until the end of the year. You are therefore advised to tackle all labs.
How many labs will count towards my overall mark?
Again, this is not divulged until the end of the year.
Will each lab count equally?
No - not necessarily. I typically combine your marks using a weighted average so that what I consider to be the more difficult pieces of work count for more.
Can I use my laptop/PC at home to do the work?
Yes, but...
What help will there be?
You can speak to me or my helpers in the labs. You can also speak to me after any lecture. Or you can email me or call into my office.
Can I get help from my friends?
To some extent, yes...

You may discuss your plans for tackling the work. You may discuss concepts that you are having trouble with. Your friends may have found a way of explaining something that works better for you than the ways we explain things.

But, do not cog.

Do not look at your friends' files; do not type their work into your files; do not ask them to send you their files; do not cut-and-paste solutions from the web; etc. etc.

In no way, shape or form should you submit work as if it were your own when some or all of it is not.

Be warned that I think that cogging is contemptible and I will apply the maximum penalties both to the person who submits the cogged work and to any person who helped them.

So now what?
Now start this week's work...

This week's work

(My thanks go to Dr. Kieran Herley for providing the materials for the first part of this week's work.)

During Induction Week you should have created a folder/directory called cs1102 (all lowercase). (If not, create it now. If it has the wrong name, e.g. uppercase, rename it now.) Within cs1102, create another folder (a subdirectory), called lab1 (all lowercase).

This lab involves creating (yet another) simple web page, using Strict XHTML 1.0. But the twist in the tail is to validate it (explained later).

The following content is provided:

Download these files and save them in your cs1102\lab1 folder.

In your lab1 folder, you must create a html file, uzbekistan.html (all lowercase), based on the content mentioned above. A CSS stylesheet is not required.

You must use a copy of template.html to start you off. It has some extra lines in it that you need later.

I reccommend that you do this in stages and check after each stage that the document appears as it should.

Now here's the real part of the exercise!

There is software that can check whether you have indeed created a well-formed and valid document. Your document is well-formed if you have followed the rules of XML, e.g. if elements are nested properly, if every element (apart from empty elements) has a start tag and a corresponding end tag, etc. Your document is valid if you have used only the tags and attributes that you are allowed to use (in this case, the tags and attributes of Strict XHTML 1.0).

Here's how to check:

  1. Visit the W3C's Markup Validation Service: http://validator.w3.org/
  2. Click on the tab labelled 'Validate by File Upload' and use the 'Browse' button to select your file uzbekistan.html.
  3. Click 'Check'. Your XHTML will be validated. Error messages or warnings may be displayed.
  4. Did you get errors and/or warnings? Make corrections until the validator gives you a 'Congratulations' message.
  5. (If your file did not contain any errors, why not plant some, just to see what happens? Then get rid of them again!)

Once you are satisfied with your web page and satisfied that it is well-formed and valid, you can use our software to hand it up (to submit it). On the CS1102 Labs page, click on the link that says 'Submit the work you have done for a lab', and follow the instructions. In particluar, don't be put off by the stuff about 'Certificates', just click on Accept. Choose Year 1, CS1102 and LAB1 when prompted.

Deadline: 5 pm, Monday 15th October.

(Since this is our first submission, don't get upset about any difficulties you experience when submitting the work. I will be very understanding, and we will sort out problems in the lab on the 16th.)

Challenge exercise

Challenge exercises are always optional. They will not form part of your year's work, they are generally not submitted, and they are not worth any marks. They are designed for those students who finish the main exercise quickly and easily, and wish to explore further. The instructions will be more terse.

This challenge let's you explore XML a little bit more. It's probably best to put this work somewhere separate, e.g. cs1102 > challenge1.

A theatre is advertising its upcoming productions. In November, Romeo and Juliet is playing. In December, it's panto time, when Cinderella comes to town.

  1. Design an XML markup language that you think could be used to markup text files such as these. Use play as your root element. Put the DTD for your markup language into a file called plays.dtd.
  2. Markup the two adverts from earlier and place them into two files, romeoandjuliet.xml and cinderella.xml. You will need to include the following as the first two lines of each file:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE play SYSTEM "plays.dtd">
  3. Display your two files in your browser. (Use Firefox in preference to Internet Explorer.) They will display as a tree-like structure.
  4. We can display them more attractively by writing a CSS stylesheet. Instead of rules such as
    h1 {background-color: red;}
    you can write rules such as
    play {background-color: red;}
    Hence, write an interesting CSS stylesheet and save it as playstyle.css.
  5. Include the following as the second line of romeoandjuliet.xml and of cinderella.xml:
    <?xml-stylesheet type="text/css" href="playstyle.css"?>
    Display your two files in your browser again. (If your stylesheet isn't 'interesting' enough, the two files will probably now look awful in your browser, in which case make your stylesheet more 'interesting'!)

Want to read more? For all but the simplest tasks, DTDs are being phased out in favour of "XML Schemas". Look these up on the web.

And CSS is not the preferred way of formatting XML. Look up "XSL" on the web.