Book HomeXML SchemaSearch this book

A.5. XML DTDs

Inherited from SGML, the XML DTD is the most widely deployed means of defining an XML schema. Defined in the XML 1.0 Recommendation, DTDs do not support namespaces, which were specified later. This, together with the fact that its datatype system is weak and applies only to attributes, is one of the main motivations for the W3C to develop a new schema language. Table A-1 provides the fact sheet for XML DTDs.

Table A-1. XML DTD fact sheet

Author:

W3C.

Status:

Recommendation ("embedded" in XML 1.0).

Location:

http://www.w3.org/TR/REC-xml.

Type:

Grammar-based.

PSVI:

Yes (weak).

Structures:

Yes.

Datatypes:

Yes (weak).

Integrity:

Yes (internal through ID/IDREF/IDREFS attributes).

Rules:

No.

Vendor support:

Excellent.

Miscellaneous:

Non-XML syntax; no support for namespaces. Schema definition is only one of the features of DTDs. Requires deterministic content models.

A.5.1. Example

<!ELEMENT author (name, nickName, born, dead)>
<!ATTLIST author
  id ID #REQUIRED
>
<!ELEMENT author-ref EMPTY>
<!ATTLIST author-ref
  id IDREF #REQUIRED
>
<!ELEMENT book (isbn, title, author-ref*, character-ref*)>
<!ATTLIST book
  id ID #REQUIRED
>
<!ELEMENT born (#PCDATA)>
<!ELEMENT character (name, since, qualification)>
<!ATTLIST character
  id ID #REQUIRED
>
<!ELEMENT character-ref EMPTY>
<!ATTLIST character-ref
  id IDREF #REQUIRED
>
<!ELEMENT dead (#PCDATA)>
<!ELEMENT isbn (#PCDATA)>
<!ELEMENT library (book+, author*, character*)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT nickName (#PCDATA)>
<!ELEMENT qualification (#PCDATA)>
<!ELEMENT since (#PCDATA)>
<!ELEMENT title (#PCDATA)>


Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.