Assignment Two: XML

out Monday 9/25, due Monday 10/9

It's important for us to understand and be able to work with XML for several reasons. First, XML was designed as an expressive language to store and exchange semi-structured data. As such, it is an alternative to RDF and other semantic web languages. Second, semantic web languages rely on many components of (or associated with) XML such as unicode, URIs, XML namespaces and XSD datatypes. Finally, the XML serialization for RDF was the first one developed and first serialization for RDF and continues to be widely used.

You are asked to develop an XML representation for the UMBC course offerings. Review a sample of computer science courses from the UMBC Fall 2017 schedule for the data that is associated with courses. Specifically

  • design an appropriate XML representation and express it using an XML Schema (not a DTD)
  • use your XML representation to encode the data for CMSC 304, 441 and 491 from the Fall 2017 schedule.
  • develop a simple XSLT transformation to render this as HTML
You will find the material in the appendix of the Semantic Web Primer helpful.

(1) Designing your representation

Your first job is to produce the XML Schema for your representation, giving it the name schedule.xsd

Even this simple problem can result in a complex representation. You don't need to do this. You can make the following simplifying assumptions:

  • Courses meet in the same room and at the same time on each day that it meets.
  • Courses have only one instructor

You can find the standard XML data types in the W3C's XML Schema Part 2: Datatypes document. Feel free to use the xs:string data type freely. Of course, if you want, you can use other data types (e.g., xs:gYear, xs:time, xs:nonNegativeInteger) but my advice is to keep it simple. be sure to add appropriate comments to help a person reading your schema understand it and how it is to be used.

Here's a sketch of the elements you might use. You can choose your own set of elements and your own names.

A schedule has
  a year (e.g., 2017) 
  a semester (e.g., Spring)
  one or more courses.

a course has 
 a program identifier (e.g., CMSC) 
 a number (e.g., 471)
 a classNumber (e.g., 1136)
 a title (e.g., Introduction to Artificial Intelligence)
 a credits (e.g., 3)
 zero or more prerequisite classes (e.g., CMSC341)
 a description (e.g., This course provides a broad...sections.)

A section has
 a section number (e.g., 01)
 an instructor (e.g., Maksym Morawski)
 a scheduleNumber (e.g., 1532)
 a room (e.g., Sherman Hall 013)
 a days (e.g., TuThr)
 a startTime (e.g., 10:00am)
 an endTime (e.g., 11:15am
 a status (e.g., Open or Closed)

(2) An example data file

The second step is to use your schema file to create an example XML data file for a part of the Fall 2017 Schedule. In particular, encode data for CMSC 471, 478 and 673 from the Fall 2017 course schedule (be sure to change the Term to Fall 2017 in the search form). Name this file fall2017.xml. Your XML file should reference the xsl transform and also the xml schema file. Referencing the schema file in your xml document requires adding two things to the root element:

  • A declaration of the XML Schema instance namespace, e.g., xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  • A link to your schema file using the XML Schema instance schemaLocation property, e.g., xsi:schemaLocation="http://umbc.edu/~finin/schedule.xsd"

See the expense report example and note how expenses.xml links to its xsd schema file and xsl transform file.

(3) An XSLT transformation file

The third step is to use XSLT to create a transform that will convert your xml file into a legal HTML file. The design of this is up to you, but use a good design that makes it clear and easy to understand and read. Name this file schedule.xsl.

(4) What to hand in

You should commit and push the following three files to your github HW2 repository

  • schedule.xsd - the schema file for a university schedule
  • fall2017.xml - your data for the courses 304, 441 and 491
  • schedule.xsl - the xsl transform file for a university schedule
  • notes.md - Some brief notes describing what you did including what software tools you used and anything you found interesting about the process
  • screenshot.jpg or screenshot.png - a screenshot showing the HTML version of your XML file rendred by the XSL transform

Tools you can use

You can develop your files using simple tools like emacs or eclipse. Both have packages to support XML: gnu emacs as nxml mode and Eclipse has several, (e.g. Rinzo). There are a number of good commercial XML editors and most have a way you can evaluate the product for long enough to do this assignment. For example, you might check out XMLSpy or oXygen. You might also look the Wikipedia page comparing XML editors.

There are online tools for validating an XML file, and XSD schema and also for vadidating that an XML file follows an XSD schema (e.g., here), and for validating sn XSL transform and applying it to an XML file (e.g., here).