Entity Declared
In a document without any DTD, a document with only an
internal DTD subset that contains no parameter entity
references, or a document with standalone='yes
' for an entity
reference that does not occur within the external subset or a
parameter entity, the Name
given in the entity reference must match that in an entity
declaration that does not occur within the external subset or a
parameter entity, except that well-formed documents need not
declare any of the following entities: amp
, lt
, gt
, apos
, quot
. The declaration of a parameter
entity must precede any reference to it. Similarly, the
declaration of a general entity must precede any reference to
it, which appears in a default value in an attribute-list
declaration. Note that if entities are declared in the external
subset or in external parameter entities, a non-validating
processor is not obligated to read and process their
declarations; for such documents, the rule that an entity must
be declared is a well-formedness constraint only if standalone='yes
'.
This long constraint lists the only situations in which an entity reference may appear without a corresponding entity declaration. Since a nonvalidating parser is not obliged to read and parse the external subset, the parser must give the document the benefit of the doubt, if an entity could possibly have been declared.