Java Reference
In-Depth Information
Symbol
Rule
No symbol
Exactly one element is allowed.
+
One or more elements are allowed.
?
Zero or one elements are allowed.
*
Zero or one or more elements are allowed.
A TTRIBUTES
An element can also be described in more detail with information that varies with
each instance of the element in the document. For example, suppose you would like
the Order element to contain an attribute named orderNumber . In any particular
Order element, this attribute would hold the unique ID that identified this Order .
Attributes are defined and used in much the same manner as elements. The
DTD declares which attributes exist for an element. Particular elements in the doc-
ument body can then be qualified with these attributes.
In the sample, an element named Order is declared in the DTD. It consists of
one or more LineItems . An attribute for Order named orderNumber is defined as
well. It can contain any valid string and is required for each instance of Order , as
specified in this partial DTD:
<!ELEMENT Order (LineItem)+>
<!ATTLIST Order orderNumber CDATA #REQUIRED>
An Order element can now exist in the body of the sample document as follows:
<Order orderNumber="81332713233407">
<LineItem>
...
</LineItem>
</Order>
Notice that attributes are entered inside the initial element tag. Attribute values
must be inside quotes, and the first quote must be preceded by an equals sign, after
the attribute name.
(<Order ..>).
Common data types for attributes are shown in the following table:
 
Search WWH ::




Custom Search