1
***************************************************
2
***** .dtd (Document Type Definition)
3
***************************************************
6
<?xml version = "1.0" encoding = "UTF-8"?>
8
|<!DOCTYPE address SYSTEM "address.dtd">
9
|<!DOCTYPE address PUBLIC "URL/address.dtd">
12
*********************************
13
* Something like class definition
14
*********************************
15
<?xml version='1.0' encoding='UTF-8' ?>
16
<!ELEMENT name (first,midle,last)>
17
<!ELEMENT contact (address, phone)>
19
<!ELEMENT first (#PCDATA)>
20
<!ELEMENT middle (#PCDATA)>
21
<!ELEMENT last (#PCDATA)>
22
<!ELEMENT address (#PCDATA)>
23
<!ELEMENT phone (#PCDATA)>
27
<!ATTLIST name type (current|past) #REQUIRED id ID #IMPLIED
28
<!ATTLIST mobile type CDATA #IMPLIED
29
name - Element name for which specifiying attributes
30
type,id - Attribute names
32
current|past - Possible values (enumeration type)
34
ID - Name(letters,_) which UNIQUE for xml document
35
IDREF, IDREFS, ENTITY, ENTITIES, NMTOKEN, NMTOKENS
37
#REQUIRED - attribute is required
38
#IMPLIED - attribute isn't required
45
* Optional and Repeatable
48
<!ELEMENT name(first,middle?,last)>
49
<!ELEMENT contact(phone|mobile,address)>
54
** Something like #define, once defined in .dtd, then can be referenced from
55
** later in .dtd or .xml documents, for example author of dtd:
56
<!ENTITY dtd-author "Kain the Dragon">
57
** Referencing in .xml document
60
** Or more complex (list of elements)
61
<!ENTITY %person "name, contact">
62
<!ELEMENT Manager (%person;)>
63
<!ELEMENT Admin (%person;)>
65
** Or list of attributes
66
<!ATTLIST % name attrname datatype #use>
67
** Yes ATTLIST not ENTITY (only differs from ATTLIST with '%' symbol)
69
<!ATTLIST Manager %name;>
71
** Including external file with entities
72
<!ENTITY % name SYSTEM "filename.dtd">
74
<!ENTITY % name PUBLIC "http://URL">
79
<!-- multiline comment -->