- The DTD might be defined as follows:
<!ELEMENT exam (code, title, date, questions) >
<!ELEMENT date (month, year) >
<!ELEMENT questions (question, question, question, question, question, question?) >
<!ELEMENT question ((part)+) >
<!ELEMENT part (#PCDATA|part)* >
<!ELEMENT code (#PCDATA) >
<!ELEMENT title (#PCDATA) >
<!ELEMENT month (#PCDATA) >
<!ELEMENT year (#PCDATA) >
A valid instance is:
<exam>
<code>IWT</code>
<title>Internet and Web Technologies</title>
<date>
<month>May</month>
<year>2014</year>
</date>
<questions>
<question><part/></question>
<question><part/></question>
<question><part/></question>
<question><part/></question>
<question><part/></question>
</questions>
</exam>
Instance <exam/>
is invalid since the
exam
element cannot be empty. Instance
<exam>
<title>Internet and Web Technologies</title>
<code>IWT</code>
</exam>
is invalid since the code
element must precede the
title
element and because the date
and
questions
elements are missing.
- One DTD is:
<!ELEMENT programme (degree, year, results)>
<!ELEMENT results ((distinction)?, (merit)?, (pass)?, (fail)?)>
<!ELEMENT distinction ((name)*)>
<!ELEMENT merit ((name)*)>
<!ELEMENT pass ((name)*)>
<!ELEMENT fail ((name)*)>
where element names without content models specified are assumed
to have #PCDATA
as their content model.
The results
categories need not be optional. Alternatively,
(name)+
could be used instead of (name)*
,
but only if results categories are optional; otherwise there is no
way of representing an empty list of names.
- A possible JSON schema is as follows:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Example",
"type": "object",
"properties": {
"programme": {
"description": "...",
"type": "object",
"properties": {
"degree": {"type": "string"},
"year": {"type": "string"},
"results": {
"distinction": {
"type": "array",
"items": {"type": "string"}
},
"merit": {
"type": "array",
"items": {"type": "string"}
},
"pass": {
"type": "array",
"items": {"type": "string"}
},
"fail": {
"type": "array",
"items": {"type": "string"}
}
}
},
"required": ["degree", "year"]
}
}
}