Week 5

Chapter 1-3: http://books.xmlschemata.org/relaxng/page2.html






default namespace = ""

start = element {Pointmodel}

Pointmodel = Note* & ((lat & long) | Address)

(1) Model Interviews

An interview consists of a sequence of question-answer alternations. Our interviews are such that on each question multiple answers follow. In this exercise we create DTD's for different modellings of such interviews.

Your DTD consists of three elements I,Q,A. I is the root, and Q and A are XML elements to store questions and answers, respectively. Both Q and A have an attribute text, in which the text of the questions and asnwers is stored.

There are several ways to model such interviews. In each model, the tree of an interview looks different. You have to find at least five different modellings. For each of them, write the DTD, and make an example document. Parts of the DTD which are common to all models don't have to be repeated. DTD rules for elements can be given as follows: Element-name -> regular expression over element-names, like OL -> LI+. For convenience and inspiration, we have given the models we like to see suggestive names:

  • flat

    element flat{
    element interview{
    (element question{text},
    element answer{text})+

  • hierarchical

    element hierarchical{
    element interview{
    element question {
    element answer{text}

  • the stick

    grammar {
  start = TheStick
  TheStick = element interview { question}
  question = element question { text, answer* }
  answer = element answer { text, question* }

  • hierarchical-stick hybrid

    grammar {
  start = TheStickHybrid
  TheStickHybrid = element interview { question+}
  question = element question { text, answer+ }
  answer = element answer { text, answer* }

  • nested hierarchical
    grammar {
  start = Nested
  Nested = element interview { question }
  question = element question { text, answer+, question* }
  answer = element answer { text }

Here is an example of an XML tree:
            <?xml version="1.0" encoding="UTF-8"?>
                <Q text="q1"/>
                <A text="a11"/>
                <A text="a12"/>
                <Q text="q2"/>
                <A text="a21"/>

Attila Csala,
Mar 6, 2012, 4:45 AM
Attila Csala,
Mar 6, 2012, 4:46 AM