Document Type Definitions
- A document type definition is used to describe the format of valid XML documents
- It can be used to verify XML documents
- It can be used to parse XML documents decomposing them into a tree
- Defines allowed elements
- For each element defines content and supported attributes
- Specified element content can be
- Parsed character data
- Indicated by #PCDATA
- Child element
- Indicated (name)
- Sequence of elements
- Indicated by (child1, child2, ...)
- Zero or one child elements
- Indicated by name?
- Zero or more child elements
- Indicated by name*
- One or more child elements
- Indicated by name+
- A choice among different child elements
- Indicated by (name1 | name2 | ...)
Example:
<!ELEMENT booklist (book)*>
<!ELEMENT book (isbn,title,author+,price,edition?)*>
<!ELEMENT isbn (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ATTLIST title lang (german|english) "german">
<!ELEMENT author (givenname,familyname)>
<!ELEMENT givenname (#PCDATA)*>
<!ELEMENT familyname (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT edition (#PCDATA)>