XML
XML stands for Extensible Markup Language. It represents yet another effort by the W3C to divorce content from presentation. Whereas CSS allows us to take most formatting out of a document, but continues to require a restricted set of typesetting commands concerning the structure of the document, XML removes most of the restrictions on the structural commands. For example, HTML still contains the <hr> tag, which is not so structural, instead giving information about a graphical item. Likewise, the table command on which so many HTML documents rely has more to do with formatting than with structure. By contrast, XML allows an author to determine the structure of a document, create tags to describe that structure, and leave all the formatting for later.
XML has a stricter syntax than HTML, but really has very few rules. The only requirements for a well-formed XML file are as follows. We should properly use the word "element" instead of "tag" here, but we believe that tag is more evocative of the way we will implement XML, and will do for this course.
- Every opening XML tag must have a corresponding closing tag: for example <tag> must be followed by </tag>.
- Tags must be nested properly. The last tag to open must be the first to close.
- <tag/> is considered to be equivalent to <tag></tag>.
- There must be one tag, called the root tag, which does not appear in the content of any other tag.
What are the tags? That is up to us. We can define the tags, their relationship to each other, and the way in which their content will be formatted on a page. As you can see, this means that every XML document actually relies on at least two other files.
A Data Type Definition (DTD) file contains the rules regarding relationships among the tags we define. We do not really require a DTD, but it allows us to define default values, and enforces our syntax across many different XML documents.
In addition to a DTD, the presentation of our XML requires an associated style file to tell how it is to be formatted. The style file could be done in CSS - see this sample XML with CSS formatting. As you can see, the control over the appearance is limited. For that reason the X Stylesheet Language was invented - XSL. XSL is a much more versatile language for XML formatting, allowing us to include some typesetting commands in addition to formatting instructions. In short, XSL can handle all procedural matters, while XML is exclusively structural. You can view more examples of that same sample XML file here, here, and here.
The last test will take place at the final exam time on
Tuesday, 12 December, from 1:30-3:30. It will be written as a one-hour (not
50 minute) exam, but you may have the full two hours for it.
In other respects it will be very like the other tests, but
comprehensive - it will emphasize Python, but cover all the
topics we have seen.
There is a
Sample Exam, but be aware that things will have changed somewhat
with the advent of ChatGPT.
Assignment A
is posted.