DTD - Entity


An entity is a variable used to define shortcuts that reference plain text or special characters.

  • Entity references are references to entities.

  • Entities can be declared internally or externally.


An internal entity declaration

Syntax

<!ENTITY entity-name "entity-value">

Example

DTD example:

<!ENTITY writer "Donald Duck.">
<!ENTITY copyright "Copyright example.com">

XML example:

<author>&writer;&copyright;</author>

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


An external entity declaration

Syntax

<!ENTITY entity-name SYSTEM "URI/URL">

Example

DTD example:

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

XML example:

<author>&writer;&copyright;</author>
other extensions