Predefined Entities |
Besides user-defined entity references, XML includes the five named entity references shown in Table 21-1 that can be used without being declared. These references are a subset of those available in HTML documents.

Predefined entities

Entity | Character | XML declaration
&lt; | < | <!ENTITY lt "&#38;#60;">
&gt; | > | <!ENTITY gt "&#62;">
&amp; | & | <!ENTITY amp "&#38;#38;">
&apos; | ' | <!ENTITY apos "&#39;">
&quot; | " | <!ENTITY quot "&#34;">

The &lt; and &amp; entities must be used wherever < or & appear in element content or attribute values. The &gt; entity is frequently used wherever > appears in document content, but it is only mandatory to avoid putting the sequence ]]> into content. &apos; and &quot; are generally used only within attribute values to avoid conflicts between the value and the quotes used to contain the value.

Although the parser must recognize these entities regardless of whether they have been declared, you can declare them in your DTD without generating errors.

The presence of these "special" predefined entities creates a conundrum within an XML document. Because it is possible to use these references without declaring them, it is possible to have a valid XML document that includes references to entities that were never declared. The XML specification actually encourages document authors to declare these entities to support older SGML parsers that don't predefine these entities. In practical terms, declaring these entities only adds unnecessary complexity to your document.