Entities are variables that define shortcut names. The parsing process replaces them with common text. You can declare entities either internally or externally. "General entities" are entities for use within the document content (see Section 4.5.1). The XML Recommendation refers to these entities using the unqualified term "entity." By comparison, "parameter entities" are parsed entities for use only within the DTD (see Section 4.5.2). General and parameter entities occupy different namespaces; a parameter entity and a general entity with the same name are two distinct entities.
4.5.1 Internal General Entity Reference DeclarationsYou define internal general entity references in the DTD by using an "<!ENTITY>" declaration. General entity values cannot contain a percent sign ("%"), ampersand ("&"), or double quote (" " "), unless these characters are inserted through character references. The syntax for an entity declara tion has the following format, where "name" is the abbreviation for the replacement text: <!ENTITY name "replacement text"> Make sure to enclose the replacement text in quotes, as it might contain white spaces. You can use general entity references in the DTD only where their use will be part of document content. In other places in the DTD, you must use parameter entities as described in Section 4.5.2. 4.5.2 Parameter Entity Reference DeclarationsParameter entity references are similar to general entity references except that they begin with a percent sign ("%") and can appear only in the DTD. Developers frequently use parameter entities to encapsulate part of a declaration that is used frequently and has multiple variants. Parameter entity references also prove useful when multiple elements use the same content model for example, when you want to share common lists of children and elements between elements. You must declare parameter entity references before using them. A parameter entity reference declaration has the following syntax: <!ENTITY % name "replacement text"> By using parameter entities, you can shorten the declarations of other elements and attributes. For example, you can place parameter entity references in an internal DTD subset when they provide whole declarations. You can place parameter entities inside a declaration in an external DTD subset to define content models, element names, and other parts of declarations in the DTD subset. |