Java Reference
In-Depth Information
E LEMENTS
An element is the user-defined atomic data unit. An XML document is a collection
of elements. An element can contain text, other elements, or even a combination of
the two. The syntax for an element in an XML document is <Name> content </Name> .
An element is roughly analogous to a data item in a COBOL program.
These are four of the elements from the XML sample:
<Title>Debt of Honor</Title>
<Author>Tom Clancy</Author>
<BookType>&PAPERBACK</BookType>
<Price>$6.99</Price>
The sample also contained a LineItem element, which was comprised solely of
other elements:
<LineItem>
<Title>Debt of Honor</Title>
<Author>Tom Clancy</Author>
<BookType>&PAPERBACK</BookType>
<Price>$6.99</Price>
</LineItem>
The LineItem element consists of other elements. A group item in a COBOL
program is similar, since it consists of other data items.
A document's DTD declares all the elements a document can contain, the car-
dinality rules, whether or not elements have attributes, and the order and arrange-
ment of those elements. A DTD is roughly equivalent to the WORKING-STORAGE
area in a COBOL program, except that a DTD can contain much more descriptive
information about its elements.
In the sample, an element named Title is defined in the DTD with the follow-
ing construct:
<!ELEMENT Title (#PCDATA)>
The Title element can now exist in the body of the sample document as follows:
<Title>Debt of Honor</Title>
The symbols used to specify cardinality rules for particular elements are shown
in the following table:
Search WWH ::




Custom Search