|
|
-
You can describe the attributes of an XML file as well. The syntax
is:
<!ATTLIST element attribute type default>
-
The attribute types are defined on page 1133 in the book. They include
CDATA, (string| attribute| list), NMTOKEN, ID, IDREF, and ENTITY.
-
Defaults are also described in the book. They include #REQUIRED,
#IMPLIED, optional-default, and FIXED default.
-
For example, let's say we want to add an attribute to the drivername, which
is the English name for our driver (ConnectorJ, in our case). We
could specify this with an optional attribute, like so:
<!ATTLIST drivername englishname CDATA #IMPLIED>
Where
-
<!ATTLIST starts the tag,
-
drivername is the name of the element that has this attribute,
-
englishname is the name of the attribute,
-
CDATA states that any character string for the value is fine,
and
-
#IMPLIED notes that this is an optional attribute.
-
Similarly, we could have an attribute that describes the type
of the driver. It would look like this:
<!ATTLIST drivername drivertype (I|II|III|IV) IV>
Where
-
<!ATTLIST and drivername are the same as above,
-
drivertype is the name of this attribute,
-
(I|II|III|IV) are the four values that this attribute can have,
and
-
IV is the default value if this attribute is not specified.
Planning our Enhanced XML with DTD
|