Schema
A language defniition that specifies which elements and attributes are allowed or required in a document
Schemas are not required but are important tools for keeping documents consistent
Document Type Definition
DTD is an older but widely used system of rules with a peculiar and somewhat limited syntax
A *.dtd file is a collection of these rules
DTD Element Stucture
- ELEMENT must be all caps
<!ELEMENT tagName EMPTY><!ELEMENT tagName (#PCDATA)><!ELEMENT tagName (childElement, ...)>- Don't need to close rule definitions with
/>
#PCDATA
"Parsed Character Data" - everything (numbers, letters, symbols,...) except markup text
Major limitation of DTD's - Can't specify data types. It's only text.
<year>1993</year> can also be<year>Dragon</year>
Declarations
<!ELEMENT animal (name+, threats*, weight?)>- threats can contain it's own child elements
- "?" -> 0 - 1
- "*" -> 0 - many
- "+" -> 1 - many
- Can use a "|" (pipe) in child element definition to say this OR that
<!ELEMENT animal (name+, threats*, weight | height)>means weight OR height- Children (inside the parentheses) must be in the correct order
Examples:
<!ELEMENT weight (#PCDATA)>- element "weight" defined as text only<!ELEMENT mammal (whales)>- element "mammal" must contain only one element "whales"-
<!ELEMENT mammal (whales, elephants, (gorillas | monkeys))>- element "mammal" must contain, in order, one "whales" element, one "elephants" element, and one of either the "gorillas" or "monkeys" elements