Element Type Declarations




Download 2,96 Mb.
Pdf ko'rish
bet70/131
Sana14.05.2024
Hajmi2,96 Mb.
#232039
1   ...   66   67   68   69   70   71   72   73   ...   131
Bog'liq
Ceponkus, Hoodbhoy - Applied XML - Toolkit for Programmers

Element Type Declarations
XML documents are primarily concerned with elements. The structure of your XML 
documents is implicitly defined by the nesting of elements. However, at some point, an 
explicit description of the desired information structure has to be made. The DTD is the 
place to do it, and the 
element type declaration
is the syntax that is used to make the 
structure official.
An element type declaration is a statement that heralds the existence and defines the 
structure of a class (type) of elements. In general, it provides the parser with three 
important pieces of information about each element type that occurs in your XML 
document:

Its name

The type of information (content) that it can contain (also called the element type’s 
content model
)

The attributes associated with it
In a DTD, the order in which declarations are made makes a big difference. This is 
important to keep in mind when you are defining elements with nesting.
In general, the syntax of an element type declaration looks like this:
A content model is the type of data that the element can contain. Granted, that sounds a 
little vague. Allow us to make things more lucent.
There are several ways of declaring element structures. Generally an element can be 
made of other elements, character data, or a mixture of both. Let’s take the simplest 
case: when you want to declare the existence of a single element that contains character 
data (that is, text). Let’s say you’d like to have an element called First_Name that should 
contain the text of a person’s name. Here’s the simplest way of declaring it in your DTD:


- 67 -
Simple, right?
Table 3.4 walks through several examples of element type declarations and their 
equivalent interpretations and is included in case you want to use it as a quick reference 
guide. We go through all of these (and more) in our description of the content model.

Download 2,96 Mb.
1   ...   66   67   68   69   70   71   72   73   ...   131




Download 2,96 Mb.
Pdf ko'rish