PREV NEXT
- DTDs are a set of rules that define how XML data should be structured.
- Cooperating applications can share a single description of data known as XML vocabulary. A group of XML documents that share common XML vocabulary is known as document type and each individual document that conforms to a document type is a document instance.
- Multiple documents and applications can share DTDs
- Validity constraints ensure that any XML data conforms to its associated DTD.
- Only one DTD may be associated with a given XML document or data object.
- DTD has 2 parts – internal subset, external subset. DTD declarations in internal subset have priority over those in external subset.
- An XML document can be associated with only one DTD using a single DOCTYPE declaration.
- Syntax of DOCTYPE declaration:
- <!DOCTYPE doc_element SYSTEM location [internal_subset]>
- <!DOCTYPE doc_element PUBLIC identifier location [internal_subset]>
- Only comments and PIs cam be inserted between XML declaration and DOCTYPE declaration.
- DTDs are associated with the entire element tree via the document element.
- “#” character as URI fragment identifier cannot be used in the location of a DTD.
- The use of PUBLIC identifier should be limited to internal systems and legacy SGML applications.
- Four basic keywords used in DTD declaration are:
- ELEMENT
- ATTLIST
- NOTATION
- ENTITY
- ELEMENT:
Syntax: <!ELEMENT ele_name content_category> <!ELEMENT ele_name (content_model)cardinality)> Content_category : ANY or EMPTY
- Content_Model : Text only, Element only, Mixed
- Child elements in mixed content can appear (or not) in any order, any number of times.
- Syntax of mixed content:
- No fixed sequence
- #PCDATA must be the first item
- “*” operator is needed as the mixed content doesn’t constain the no. of occurrences of the child elements.
- ATTLIST declaration Syntax:
- Attribute defaults: #REQUIRED, #IMPLIED, #FIXED, Default values
- Attribute types: (10 in number)
- CDATA
- Enumeration
- ID
- IDERF
- IDERFS
- NMTOKEN
- NMTOKENS
- NOTATION
- ENTITY
- ENTITIES
- Order of attributes cannot be enforced
- ID attribute type must not be used with #FIXED
- ID value must be unique within a given document
- Only one ID attribute for each element type
- NMTOKEN attribute prevents the inclusion of whitespace and some punctuation characters
- NOTATION can be used to identify
- The format of unparsed entities
- The format of element attributes of ENTITY and ENTITIES type
- The application associated with a PI
- Entities can be used to include a document inside a DTD
- If an element is declared more than once, its an error
- If an entity is declared more than once, only the first declaration is binding, other declarations are ignored.
Post Your Thoughts