Attributes: Examples
The following table contains examples of attribute definitions and their descriptions.

Example

Description

<!ELEMENT message (#PCDATA)>
<!ATTLIST message number CDATA "1234">

The message element has an attribute called number, which contains a default value 1234. You can specify any value for this attribute. The valid XML markup for this element can be any one of the following:
    <message number="1001">
    <message number="1234">
    <message number="anyvalue">

<!ELEMENT message EMPTY>
<!ATTLIST message priority CDATA #FIXED "high">

The element message does not have a child element. However, it has one attribute called priority, which contains the character data high, whose value cannot change. The valid XML markup for this element is as follows:
    
<message priority="high">

<!ELEMENT message EMPTY>
<!ATTLIST message priority (high|low|notapplicable) #REQUIRED>

The element message does not have a child element, but it has one attribute called priority containing enumerated values that are mandatory. The valid XML markup for the message element can be any one of the following:
    < message priority ="high" >
    < message priority ="low" >
    < message priority ="notapplicable" >

<!ELEMENT message EMPTY>
<!ATTLIST message priority CDATA #IMPLIED>

The message element has one attribute called priority that is optional and contains character data. In XML markup, this message element is written as follows:
    <message priority="high" />    or    <message />

Click the Next button to continue.