There are three main attribute types; a string type, tokenized types, and enumerated types.
They are classified as follows.
Tokenised attribute type: | Attribute description: |
ID | ID is a unique identifier of the attribute. IDs of a particular value should not appear more than once in an XML document . An element type may only have one ID attribute . An ID attribute can only have an #IMPLIED or #REQUIRED default value . The first character of an ID value must be a letter, '_', or ':' . See example. |
IDREF | IDREF is used to establish connections between elements. The IDREF value of the attribute must refer to an ID value declared elsewhere in the document . The first character of an ID value must be a letter, '_', or ':' . See example. |
IDREFS | Allows multiple ID values separated by whitespace . |
ENTITY | ENTITYs are used to reference data that act as an abbreviation or can be found at an external location. The first character of an ENTITY value must be a letter, '_', or ':' . See example. |
ENTITIES | Allows multiple ENTITY names separated by whitespace . See example. |
NMTOKEN | The first character of an NMTOKEN value must be a letter, digit, '.', '-', '_', or ':' . See example. |
NMTOKENS | Allows multiple NMTOKEN names separated by whitespace . |
CDATA Example: |
<?xml version="1.0"?>
<!DOCTYPE image [
<!ELEMENT image EMPTY>
<!ATTLIST image height CDATA #REQUIRED>
<!ATTLIST image width CDATA #REQUIRED>
]>
<image height="32" width="32"/> |
ID Example: |
<?xml version="1.0"?>
<!DOCTYPE student_name [
<!ELEMENT student_name (#PCDATA)>
<!ATTLIST student_name student_no ID #REQUIRED>
]>
<student_name student_no="a9216735">Jo Smith</student_name> |
IDREF Example: |
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE lab_group [
<!ELEMENT lab_group (student_name)*>
<!ELEMENT student_name (#PCDATA)>
<!ATTLIST student_name student_no ID #REQUIRED>
<!ATTLIST student_name tutor_1 IDREF #IMPLIED>
<!ATTLIST student_name tutor_2 IDREF #IMPLIED>
]>
<lab_group>
<student_name student_no="a8904885">Alex Foo</student_name>
<student_name student_no="a9011133">Sarah Bar</student_name>
<student_name student_no="a9216735"
tutor_1="a9011133" tutor_2="a8904885">Jo Smith</student_name>
</lab_group> |
ENTITY Example: |
<?xml version="1.0" standalone="no"?>
<!DOCTYPE experiment_a [
<!ELEMENT experiment_a (results)*>
<!ELEMENT results EMPTY>
<!ATTLIST results image ENTITY #REQUIRED>
<!ENTITY a SYSTEM "http://www.university.com/results/experimenta/a.gif">
]>
<experiment_a>
<results image="a"/>
<experiment_a> |
ENTITIES Example: |
<?xml version="1.0" standalone="no"?>
<!DOCTYPE experiment_a [
<!ELEMENT experiment_a (results)*>
<!ELEMENT results EMPTY>
<!ATTLIST results images ENTITIES #REQUIRED>
<!ENTITY a1 SYSTEM "http://www.university.com/results/experimenta/a1.gif">
<!ENTITY a2 SYSTEM "http://www.university.com/results/experimenta/a2.gif">
<!ENTITY a3 SYSTEM "http://www.university.com/results/experimenta/a3.gif">
]>
<experiment_a>
<results images="a1 a2 a3"/>
</experiment_a> |
NMTOKEN Example: |
<?xml version="1.0"?>
<!DOCTYPE student_name [
<!ELEMENT student_name (#PCDATA)>
<!ATTLIST student_name student_no NMTOKEN #REQUIRED>
]>
<student_name student_no="9216735">Jo Smith</student_name> |
NOTATION Example: |
<?xml version="1.0"?>
<!DOCTYPE code [
<!ELEMENT code (#PCDATA)>
<!NOTATION vrml PUBLIC "VRML 1.0">
<!ATTLIST code lang NOTATION (vrml) #REQUIRED>
]>
<code lang="vrml">Some VRML instructions</code> |
Enumerated Example: |
<?xml version="1.0"?>
<!DOCTYPE ToDoList [
<!ELEMENT ToDoList (task)*>
<!ELEMENT task (#PCDATA)>
<!ATTLIST task status (important|normal) #REQUIRED>
]>
<ToDoList>
<task status="important">This is an important task that must be completed</task>
<task status="normal">This task can wait</task>
</ToDoList> |