<!DOCTYPE root-elt-name External-ID [ internal part of DTD ]>
In new applications - see W3C XML Core Working Group (http://www.w3.org/XML/Core/#Publications) for the answer:
Problems with DTD?
http://www.zvon.org/xxl/DTDTutorial/General/contents.html (including a Czech version)
http://edutechwiki.unige.ch/en/DTD_tutorial (not just DTD but much more)
DTDeclaration is placed immediately before the root element!
<!DOCTYPE root-elt-name External-ID [ internal part of DTD ]>
Internal or external part (internal or external subset) might or might not be present, or both can be present.
External identifier can be either
PUBLIC "PUBLIC ID" "URI"
(suitable for ”public”, generally recognized DTDs) or
SYSTEM "URI"
for private- or other not-that-well-established DTDs
(”URI” need not be just real URL on network, may also be a file on (local)
filesystem, resolution according to system where it is resolved)
The significancy of internal a external parts is the same (they must not be
in conflict - eg. two defeinitions of the same element). DTD contains a list of
definitions for individual elements, list of attributes of them, entities, notations
For "commenting out" portions of DTDs e.g. for experimenting:
<![IGNORE[ this will be ignored ]]> <![INCLUDE[ this will be included into DTD (i.e. not ignored)]]>
Describes allowed content of the element, in form of <!ELEMENT element-name … >
,
where … can be
for empty element which may be represented as <element/>
or
<element></element>
with the same logical meaning
any element content allowed, i.e. text nodes, child elements, …
may contain child elements - <!ELEMENT element-name (specification of child elements)>
containing both text and child elements given by enumeration
<!ELEMENT element-name (#PCDATA | specification of child elements)*>
For MIXED, the order or cardinality of concrete child elements cannot be specified.
The star (*
) is required and any number of occurencies is always allowed.
For specifying the child elements, we use:
,
|
()
have usual meaning
*
, ?
, + having usual meaning.
Describes (data) type and/or implicit attribute values for the respective element.
<!ATTLIST element-name attribute-name attribute-value-type implicit-value>
Allowed value types are as follows:
CDATA NMTOKEN NMTOKENS ID IDREF IDREFS ENTITY ENTITIES
(value1|hodnota2|hodnota3)
NOTATION (notace1|notace2|notace3)
Attributes may have obligatory presence:
#REQUIRED
attribute is required
#IMPLIED
attribute is optional
#FIXED "fixed-value"
is required and must have the value fixed-value
Attribute (incl. optional one) might have an implicit value: then the attribut is optional, but if not present, then the implicit value is used instead.
We distinguish:
files with a (well formed) markup,
eg. binary files,
eg. >
refers to a char entity.
Example from XML Base specification http://www.w3.org/TR/xmlbase/
<?xml version="1.0"?> <e1 xml:base="http://example.org/wine/"> <e2 xml:base="rosé"/> </e1>
In the example below, the base URI of element e2 should be returned as "http://example.org/wine/rosé".
[1] : Note the use of the reserved prefix xml
[1]