INFO I308 Lab 7: Restaurant XML

Version 2.1 (2013 Mar 28), specified title of Module 11.
Version 2.0 (2013 Mar 22), revised for Spring 2013.

Due dates: See Oncourse Modules and Assignments. Turn in through Oncourse Assignments.

Two parts:
Part One: 30 points (up to 35 with extra features)
Part Two: 30 points (up to 35 with extra features)

Learning Objectives

Students completing this assignment should be able to:

Overview

This lab has two parts. In Part One, you will create an XML document describing a restaurant, with particular attention to its menu or menus, and verify that the document is well-formed XML. In Part Two, you will develop a RELAX NG document schema for restaurant XML documents, and use it to validate the document created in Part One.


Part One

Prerequisite

Basic knowledge of XML, as covered in Module 10, “Introduction to XML” (in Oncourse; or Chapters 1, 2, and 3 of the textbook and the notes on XML Introduction and Comments, Characters, Entities, Notations.

Requirements

Create an XML document describing a restaurant and its menu(s). Verify that the document is well-formed.

Structural Requirements

These are the general requirements for any restaurant XML document. They pertain to document structure. These requirements are relevant to both Part One and Part Two of this assignment.

  1. A restaurant must have a name, address, and telephone number.

  2. It must have at least one menu, and each menu must have a title (for example, “Luncheon Menu,” or just “Menu” if there is only one).

  3. A menu must have one or more sections, with titles, such as Appetizers, Salads, Sandwiches, Seafood, Desserts, Wine List.

  4. Each section must have one or more items of food or drink that a customer can order.

  5. Each item must have a name and price and may have a description.

Content Requirements

These are the additional requirements for the particular restaurant XML document that you will turn in for Part One of this assignment. They pertain to the document’s content—not its structure, but how you fill that structure. They are irrelevant to Part Two.

  1. The restaurant must have at least three (3) sections.

  2. At least one menu title, section title, or item name must include a foreign (non-ASCII) character. (Let’s have some exotically named foods and drinks!) Be sure to declare a suitable encoding in your XML declaration.

  3. The restaurant must have at least ten (10) items of food and/or drink.

  4. Since the menu is going to make an impression on customers, it should be well written, with proper spelling, grammar, punctuation, etc.

Check that the document is well-formed XML, using xmlwf, xmllint, or equivalent tools. If your restaurant document is not well-formed, fix it.

Options

You may include extra features such as notes at the beginning or end of sections, or other features that you see or would like to see in restaurant menus.

Hints

  1. You can use gucharmap to pick Unicode characters, or if you find the name of a foreign dish on the web, just copy and paste it into your XML document.

    $ gucharmap &
  2. How to run xmlwf and xmllint and interpret their output (or the absence of any output) is covered in Lecture 18, in Module 10, “Introduction to XML,” in Oncourse.

What to Turn in for Part One

  1. Turn in the restaurant XML document, with the file extension “.xml”, as an attachment in Oncourse Assignments.
  2. If there are extra features, describe them in the “submitted text.”

Grading Criteria for Part One

BASE TOTAL: 30 points

Extra features, if described in “submitted text,” may earn up to 5 extra points, for a total of 35.


Part Two

Prerequisite

Requirements

Define a RELAX NG schema for restaurant XML documents and validate the document (the one you created in Part One) according to the schema. The schema must codify the Structural Requirements given in Part One; it should not codify the Content Requirements.

Use the file extension “.rnc” for RELAX NG compact syntax (preferred), or “.rng” for RELAX NG XML syntax.

Use Jing (recommended), xmllint, or equivalent tools for validation.

If your restaurant document is not valid, you must fix it!

Options

If you provided extra features in Part One, or you would like to do so now, make sure they are also specified in the RELAX NG schema (either as required or optional document structure).

Hints

  1. It will be easier—for you and for me—to do this using the compact syntax for RELAX NG. If you use the compact syntax, validate with Jing; xmllint will work only with the XML syntax.

  2. On merlin, there are two scripts, jing and jinc, in the /home/info/bin directory to make it easy for you to use Jing.

    1. Using the compact syntax:

      $ /home/info/bin/jing -c RNCFile XMLFile

      or

      $ /home/info/bin/jinc RNCFile XMLFile

      where RNCFile is the RELAX NG schema file with compact syntax, with the file extension “.rnc”, and XMLFile is the document you want to validate.

    2. Using the XML syntax:

      $ /home/info/bin/jing RNGFile XMLFile

      where RNGFile is the RELAX NG schema file with XML syntax, with the file extension “.rng”, and XMLFile is the document you want to validate.

  3. If you are going to use Jing, but not merlin, then you may need to read the Jing documentation.

What to Turn in for Part Two

  1. Turn in the following as attachments in Oncourse Assignments:
    1. The restaurant XML document, with file extension “.xml”. You must attach this, even if you made no revisions from the one you submitted for Part One.
    2. The schema file, with file extension “.rnc” (for compact syntax) or “.rng” (for XML syntax).
  2. If there are extra features, describe them in the “submitted text.”

Grading Criteria for Part Two

BASE TOTAL: 30 points

Extra features, if described in “submitted text” and present in both the schema and the document, may earn up to 5 extra points, for a total of 35.