HTML and CSS Reference
In-Depth Information
SGML Content Exclusion and Inclusion
Occasionally, the need arises to declare that an element type cannot contain certain other
element types. This is known as a content exclusion. The excluded tags follow the model
group, enclosed by parentheses and preceded by the minus sign under an SGML doctype:
(model group) - (excluded tags)
A related special need is the capability to declare that an element type can occur anywhere
inside a content model. This is known as a content inclusion. The included tags follow the
model group and are enclosed by parentheses and preceded by the plus sign:
(model group) +(included tags)
As an example, the HTML 4.01 declaration for the body element illustrates both
excluded and included elements:
<!ELEMENT BODY O O (%block;) -(BODY) +(INS|DEL)>
Why are insertions and deletions used in this declaration? The content inclusion says
that <ins> and <del> tags can occur anywhere in the content enclosed by <body> and
</body> tags . While the content exclusion says that a body element cannot contain another
body element, in this case it's necessary because of the curious “ %block ” declaration used
in the model group. The leading % character identifies this as a parameter entity, essentially
a macro symbol that refers to a longer character string declared elsewhere in the DTD.
Parameter entities, which commonly occur in DTDs, are discussed shortly (see the section
“Parameter Entities”). The “ %block ” entity reference is a shorthand way of referring to all
block element types that happen to include <body> . It is easier to exclude <body> from the
list of block elements than to define a special-purpose declaration. Interestingly, XML
eliminates the use of content inclusion and exclusion from the XHTML DTD, and thus it is
both more verbose and in some ways simpler to read.
Attribute Declarations
Once an element's syntax has been defined, we have to address its attributes. All attribute
declarations begin with the keyword ATTLIST , followed by the element name, attribute
name, attribute type, and default data information, as you can see in the following:
<!ATTLIST element-name attribute-name attribute-type default-data>
The HTML 4.01 <bdo> tag type illustrates a small attribute declaration:
<!ATTLIST BDO
%coreattrs;
lang NAME #IMPLIED
dir (ltr|rtl) #REQUIRED
>
Search WWH ::




Custom Search