DTD - Entity

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 example:

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

XML Examples:

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

Comments: 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 example:

<!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>