Laboratory 11

Exercise 1

The executive of journal Hello World! want the journalists to submit their articles in XML format. An article contains:

  • the name of the journalist (may have more than one)
  • the title
  • the local (may have more than one)
  • the date
  • the sub-title (optional)
  • the resume (optional)
  • the body of the article

1. Define, informally, the XML document structure by an example.

2. Define its structure rigorously via a DTD.

3. Implement in Java a SAX parser for the XML document you defined, building a new object of type Article for each parsed article. Define the toString method in this new type Article in order to print to the terminal an article.

Exercise 2

The computer shop BigBytes wants to create a data base of its products in XML with the purpose of being used in its online shop. The shop sells computers, printers and monitors. The data base should have the following information about each product:

  • Computers:
    • unique identifier
    • brand
    • model
    • price
    • type (desktop or laptop)
    • processor
    • memory
    • hard disk capacity
    • other characteristics (optional) – description (optional)
  • Printers:
    • unique identifier
    • brand
    • model
    • price
    • type (laser or inkjet)
    • colours (true or false)
    • printed pages per minute
    • other characteristics (optional) – description (optional)
  • Monitors:
    • unique identifier
    • brand
    • model
    • price
    • type (CRT, LCD or Plasma)
    • supported resolution
    • other characteristics (optional) – description (opcional)

1. Define, informally, the XML document structure by an example.

2. Define its structure rigorously via a DTD.

Attachments