ATTLIST tag |
|
ATTLIST tag |
|
An ATTLIST tag is used to specify attributes for use with an element.
An ATTLIST tag contains:
|
|
single attribute
In the source of the example to the left, you can see: |
|
list of attributesAs the name implies, an ATTLIST tag can be used to specify a list of several attributes for an element.
In the source of the example to the left, you can see: |
|
two attributesIf you prefer, you can use several ATTLIST tags to specify the attributes for an element.
In the source of the example to the left, you can see: |
|
CDATACDATA is different in XML and DTD.
In XML you code:
In DTD you code:
For example, in the value for the
|
|
order
You can specify element contents of an ELEMENT tag
to be ordered, such as Attributes never have a specified order. The attributes in XML can always be written in any order. The order cannot be controlled by the DTD. |
|
DTD organizationAs you begin to write more tags in a DTD, you need to keep them in some order, so you can find them. You might consider putting the ATTLIST tags just after their ELEMENT tag. |
|
Attribute value declaration |
|
Attribute Value Declarations determine if the attribute is required, and control the default for the attribute value. There are four kinds of attribute value declarations:
|
|
default attribute valueA default value can be specified for an attribute.
In the source of the example to the left, you can see: |
|
required attribute
The user can be required to provide an attribute.
In the source of the example to the left, you can see: |
|
optional attribute (implied)
An attribute can be optional.
In the source of the example to the left, you can see: |
|
fixed attribute value
The user does not need to code the attribute.
In the source of the example to the left, you can see: |
|
Attribute data types |
|
  |
The type of text in the attribute value can be specified. Different types are processed in different ways. The attribute value types are:
|
CDATA
We have already been using CDATA.
In the source of the example to the left, you can see: |
|
ID
In the source of the example to the left, you can see: |
|
IDREFThe IDREF value must be the same as the value of the ID given in a different element.
In the source of the example to the left, you can see: |
|
IDREFSThe IDREFS value is a space seperated list of IDREF values, referring to the ID values given in different elements.
In the source of the example to the left, you can see: |
|