Home

DTDs

Document Type Definitions (DTDs) are a schema language used to define the structure and legal content of SGML and XML documents. A DTD specifies which elements are permitted, the order and nesting of child elements, and the attributes that elements may have. It can also declare entities and notations used within the document.

DTDs originated with SGML, the ancestor of XML, and were carried into XML as a lightweight schema

An external DTD subset is referenced from the DOCTYPE via PUBLIC or SYSTEM identifiers, for example a

Validation and limitations: If a parser is configured to validate, a document can be checked against its

DTDs remain in use in legacy SGML/XML contexts and for simple validation tasks, though many modern XML

mechanism.
In
XML,
a
DTD
can
be
declared
as
an
internal
subset
within
the
DOCTYPE
declaration
or
as
an
external
subset
stored
in
a
separate
file.
Key
declarations
include
<!ELEMENT>
to
define
element
content
models,
<!ATTLIST>
to
declare
attributes
(types
and
defaults),
<!ENTITY>
to
declare
general
and
parameter
entities,
and
<!NOTATION>
for
identifying
non-XML
data.
DOCTYPE
that
points
to
an
external
DTD
file.
An
internal
subset
allows
defining
elements
and
attributes
directly
inside
the
DOCTYPE.
DTDs
can
also
use
parameter
entities
to
reuse
DTD
fragments
and
general
entities
for
text
reuse
within
the
document.
DTD
to
ensure
it
is
valid
in
addition
to
being
well-formed.
DTDs
provide
basic
structural
and
attribute
constraints
but
have
a
limited
datatype
system
(for
example
CDATA,
ID,
IDREF,
ENUMERATION)
and
lack
the
expressive
power
of
XML
Schema
or
RELAX
NG.
They
also
have
limited
native
support
for
namespaces.
projects
prefer
schema
languages
with
richer
data
typing
and
flexibility.