? Zero or one of the element is allowed.
* Zero or more of the element is allowed.
+ One or more of the element is required.
In narrative documents, it's common for a single element to contain both child elements and un-marked up, nonwhitespace character data. For example, recall this definition element from Chapter 2:
<definition>A <term>Turing Machine</term> refers to an abstract finite
state automaton with infinite memory that can be proven equivalent
to any any other finite state automaton with arbitrarily large memory.
Thus what is true for one Turing machine is true for all Turing
machines no matter how implemented.
</definition>
The definition element contains some nonwhitespace text and a term child. This is called mixed content. An element that contains mixed content is declared like this:
<!ELEMENT definition (#PCDATA | term)*>
If an element is empty, then it can contain nothing, not even whitespace.
There are 10 attribute types in XML. They are:
CDATA
NMTOKEN
NMTOKENS
Enumeration
ENTITY
ENTITIES
ID
IDREF
IDREFS
NOTATION
An ID type attribute must contain an XML name (not a name token but a name) that is unique within the XML document. More precisely, no other ID type attribute in the document can have the same value. (Attributes of non-ID type are not considered.) Each element may have no more than one ID type attribute.
As the keyword suggests, ID type attributes assign unique identifiers to elements. ID type attributes do not need to have the name "ID" or "id", although they very commonly do. For example, this ATTLIST declaration says that every employee element must have a social_security_number ID attribute:
<!ATTLIST employee social_security_number ID #REQUIRED>
ID numbers are tricky because a number is not an XML name and therefore not a legal XML ID. The normal solution is to prefix the values with an underscore or a common letter. For example:
<employee social_security_number="_078-05-1120"/>
In addition to providing a data type, each ATTLIST declaration includes a default declaration for that attribute. There are four possibilities for this default:
#IMPLIED
The attribute is optional. Each instance of the element may or may not provide a value for the attribute. No default value is provided.
#REQUIRED
The attribute is required. Each instance of the element must provide a value for the attribute. No default value is provided.
#FIXED
The attribute value is constant and immutable. This attribute has the specified value regardless of whether the attribute is explicitly noted on an individual instance of the element. If it is included, though, it must have the specified value.
Literal
The actual default value is given as a quoted string.
This ATTLIST declaration says that every web_page element has a protocol attribute. If a particular web_page element doesn't have an explicit protocol attribute, then the parser will supply one with the value http:
<!ATTLIST web_page protocol NMTOKEN "http">