Enumerated attribute values
Syntax:
<!ATTLIST element-name attribute-name (eval|eval|..) default-value>DTD example:
<!ATTLIST payment type (check|cash) "cash">
Example 1.
<payment type="check">
or
<payment type="cash">
Example 2.
This enforces the ALIGN attribute of the P element to have the value of either LEFT, or RIGHT, or CENTRE. A default can be supplied as follows:
<!ATTLIST P ALIGN (LEFT|RIGHT|CENTRE) "LEFT">
Defines the attributes list for the specified tag. You can declare multiple attributes at the same time, each with its type and value. An attribute can be of type CDATA, or it can be an item of a collection. Its value can be fixed, implied or required (see below). Here are a few examples:
Example. 1
<?xml version="1.0"?>
<!DOCTYPE payment [
<!ELEMENT payment (#PCDATA)>
<!ATTLIST payment type CDATA "check">
<!ATTLIST payment bank CDATA "TD">
]>
<payment type="check" bank="TD">
test
</payment>
Example 2.
<?xml version="1.0"?>
<!DOCTYPE payment [
<!ELEMENT payment (#PCDATA)>
<!ATTLIST payment type CDATA "check" bank CDATA "TD">
]>
<payment type="check" bank="TD">
test
</payment>
The word "EMPTY" designates the element has no content. Here's an example from the HTML 4 transitional DTD:
Example:
<!ELEMENT ADDRESS (STREET, CITY, STATE, ZIP, COUNTRY)>
<!ELEMENT STREET EMPTY>
<!ELEMENT CITY EMPTY>
<!ELEMENT STATE EMPTY>
<!ELEMENT ZIP EMPTY>
<!ELEMENT COUNTRY EMPTY>
No comments:
Post a Comment