|
XML : DTD |
|
2. DTD - XML Constituent
DTDs are made up by the following
integrants:
·1. Elements
·2. Attributes
·3. Entities
·4. PCDATA
·5. CDATA
Elements
Elements are the main constituent components
of both XML documents.
Elements can contain text, other elements, or
be empty.
<To>Rohan</To>
<From>Amit</From> |
Attributes
Attributes provide extra information about
elements. Attributes are always placed inside
the opening tag of an element. Attributes
always come in name/value pairs. The
following “img” element has additional
information about a source file:
<img src=”computer.gif” /> |
The name of the element is “img”. The name of
the attribute is “src”. The value of the attribute
is “computer.gif”. Since the element itself is
empty it is closed by a “ /”.
Entities:
Entities are expanded when a document is
parsed by a XML parser. Some characters have
a special meaning in XML, like the less than
sign (<) that defines the start of an XML tag,
the greater than sign (>) that defines the end
of a XML tag.
The following entities are predefined in
XML: |
|
Entity References Character
< <
> >
& &
" “
' ‘
PCDATA:
PCDATA means parsed character data. It can
be thought as the character data (text) found
between the start tag and the end tag of a
XML element. PCDATA is a text to be parsed by
a parser. The text is checked by the parser for
entities and markup.
Tags inside the text will be treated as markup
and entities will be expanded. However, parsed
character data should not contain any &, <, or > characters. These should be represented by
the &, <, and > entities, respectively.
CDATA:
CDATA is character data that will NOT be parsed
by a parser. Tags inside the text will NOT be
treated as markup and entities will not be
expanded.
3. DTD-Elements
In a DTD, elements are declared with an
ELEMENT declaration.
Declaring Elements: syntax
In a DTD, XML elements are declared with the
following syntax:
<!ELEMENT element-name category>
or
<!ELEMENT element-name (elementcontent)>
Empty Elements
Empty elements are declared with the
keyword EMPTY inside the parentheses.
<!ELEMENT element-name EMPTY> |
|
|
Jan 2008 | Java Jazz Up | 31 |
|
|
|
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 |
|
|
|
|
|
|
|
|
|