My solution may differ from yours. However, here was my thought process
that drove my design:
- The exam seems to consist of two general parts: a set of instructions
and a set of questions. So I created tags for instructions and
questions. Each of the parts formed a group, so I created children
elements for each group, namely an instruction and a question.
- The instructions were optional, so if they appeared, there needed to
be at least one of them.
- There should be at least one question since how can there be an
exam without a question?
- The questions had a couple of common elements, namely a prologue that
introduced the question and a point value. Hence I created tags for
the prologue and the points and made these tags children of a
question.
- The questions seemed to fall into three categories: 1) essay type
questions, 2) matching questions, and 3) true/false style questions
(the true/false question was is this statement correct or incorrect,
which can also be thought of as true or false).
Hence I made these three types of questions into alternative elements
for a question.
- All three types of questions had a subpart, so I created a subpart
tag.
- Each subpart of an essay question had a question and an answer, so
I created tags for both. Since
I already had a question tag, I called the question part a
questionStatement.
- A matching question had a set of choices followed by a set of
subparts. Each subpart had a question and an answer. Hence I
created a choices tag and gave it one or more choice elements.
For the subpart I had tags for the question statement and the answer.
- A trueFalseQuestion had one or more subparts. Each subpart had
a question and an answer, so I created tags for a question statement
and an answer.
- When I was done I had the same subpart structure for each type
of question. For a DTD I would have created a separate element for
the subpart, and used it in all three questions. If
I had been forced to create a schema, I might have
assigned different types to some of the answers, and hence had to
define three different types of subparts. For example,
might have only allowed "true" or "false" as the answer for a
true-false question. I schema allows me to create elements with
the same name but different types, so long as they appear in
different contexts.
exam
exam_header
course
department
number
exam_number
date
semester
year
instructions
instruction+
question+
prologue
points
essayQuestion | matchingQuestion | trueFalseQuestion
essayQuestion
subpart+
questionStatement
answer
matchingQuestion
choices
choice+
subpart+
questionStatement
answer // the choice that was made
trueFalseQuestion
subpart+
questionStatement
answer // correct or incorrect