>> English << | česky | Español | По-русски | Français | Italiano | Deutsch | MagyarZVON > Tutorials > DTD Tutorial


 Example 1   An XML document is valid if it has an associated document type definition and if the document complies with the constraints expressed in it. The document type definition must appear before the first element in the document. The name following the word DOCTYPE in the document type definition must match the name of root element.
 Example 2  An element type has element content when elements of that type must contain only child elements (no character data), optionally separated by white space.
 Example 3  If an element name in DTD is followed by the star [*], this element can occur zero, once or several times.
 Example 4  If an element name in DTD is followed by the plus [+], this element can occur once or several times.
 Example 5  If an element name in DTD is followed by the question mark [?], this element can occur zero or one times.
 Example 6  This example uses a combination of [ + * ?]
 Example 7  With character [ | ] you can select one from several elements.
 Example 8  Text can be interspersed with elements.
 Example 9  Attributes are used to associate name-value pairs with elements. Attribute specifications may appear only within start-tags and empty-element tags. The declaration starts with ATTLIST then follows the name of the element the attributes belong to and then follows the definition of the individual attributes.
 Example 10  An attribute of CDATA type can contain any character if it conforms to well formedness constraints. NMTOKEN type can contain only letters, digits and point [ . ] , hyphen [ - ], underline [ _ ] and colon [ : ] . NMTOKENS can contain the same characters as NMTOKEN plus whitespaces. White space consists of one or more space characters, carriage returns, line feeds, or tabs.
 Example 11  The value of an attribute of ID type can contain only characters permitted for NMTOKEN and must start with a letter. No element type may have more than one ID attribute specified. The value of an ID attribute must be unique between all values of all ID attributes.
 Example 12  The value of IDREF attribute must match the value of some ID attribute in the document. The value of IDREFS attribute can contain several references to elements with ID attribute separated with whitespaces.
 Example 13  Permitted attribute values can be defined in DTD.
 Example 14  If an attribute is implied, a default value can be provided for the case when the attribute is not used.
 Example 15  An element can be defined EMPTY. In such a case it can contain only attributes but no text.