|
|
|
document, it should be wrapped in a
DOCTYPE definition with the following syntax:
<!DOCTYPE root-element [elementdeclarations]>
Example of a XML document with an internal DTD: E-mail.xml
<?xml version=”1.0"?>
<!DOCTYPE E-mail[
<!ELEMENT E-mail (To,From,subject,Body)>
<!ELEMENT To (#PCDATA)>
<!ELEMENT From (#PCDATA)>
<!ELEMENT Subject (#PCDATA)>
<!ELEMENT Body (#PCDATA)>
]>
<E-mail>
<To>Rohan</To>
<From>Amit</From>
<Subject>Surprise....</Subject>
<Body>Be ready for a cruise...i will catch u
tonight</Body>
</E-mail> |
Open the file E-mail.xml in a web-browser.
External DTD
If the DTD is defined in an external file, it
should be wrapped in a DOCTYPE definition
with the following syntax:
<!DOCTYPE root-element SYSTEM “filename”> |
|
This is the same XML document as
above,(but with an external DTD ) : Email.
xml
<?xml version=”1.0"?>
<!DOCTYPE E-mail SYSTEM “E-mail.dtd”>
<E-mail>
<To>Rohan</To>
<From>Amit</From>
<Subject>Surprise....</Subject>
<Body>Be ready for a cruise...i will catch u
tonight</Body>
</E-mail>
And this is the file “E-mail.dtd” which contains
the following DTD:
<!ELEMENT E-mail (To,From,subject,Body)>
<!ELEMENT To (#PCDATA)>
<!ELEMENT From (#PCDATA)>
<!ELEMENT Subject (#PCDATA)>
<!ELEMENT Body (#PCDATA)> |
Open the file E-mail.xml in a web-browser.
Importance of a DTD:
1. With a DTD, a XML file carries a
description of its own format.
2. With a DTD, independent groups of
people can agree to use a standard DTD
for interchanging data.
3. User application can use a standard DTD
to verify that the data he receives from
the outside world is valid.
4. User can also use a DTD to verify his
own data. |
|
|
|
|
Jan
2008 | Java Jazz Up |30 |
|
|
|
View All Topics |
All Pages of this Issue |
Pages:
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53 ,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63 ,
64,
65 ,
66 ,
67 ,
68 ,
69 ,
70 ,
71 ,
72 ,
73 ,
74 ,
75 ,
76 ,
77 ,
78 ,
79 ,
80 ,
81 ,
82 ,
83,
84 ,
85 ,
86,
87 ,
88,
89 ,
90 ,
91 ,
92 ,
93 ,
94 ,
95 ,
96 ,
97 ,
98 ,
99 ,
100 ,
101 ,
102 ,
103,
104 ,
105 ,
106,
107,
Download PDF |
|
|
|
|
|
|
|
|
|