DTD - Entities

Entities are variables used to define shortcuts for referencing common text or special characters.

Entity reference is a reference to an entity.

Entities can be declared internally or externally.

A declaration of an internal entity

Syntax:

<!ENTITY entity_name "The value of the entity">

Example:

DTD Examples:

<!ENTITY writer "Bill Gates">
<!ENTITY copyright "Copyright codew3c.com">

XML Examples:

<author>&writer;©right;</author>

Comment: An entity consists of three parts: a ampersand (&), an entity name, and a semicolon (;).

A declaration of an external entity

Syntax:

<!ENTITY entity_name SYSTEM "URI/URL">

Example:

DTD Examples:

<!ENTITY writer SYSTEM "http://www.codew3c.com/dtd/entities.dtd">
<!ENTITY copyright SYSTEM "http://www.codew3c.com/dtd/entities.dtd">

XML Examples:

<author>&writer;©right;</author>