DTD – Entities

To define shortcuts to special characters, the entities are used which can be declared either internal or external. There are three parts of an entity:

  • An ampersand (&)
  • An entity name
  • A semicolon (;)

An Internal Entity Declaration:

Syntax:

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

Example:

DTD Example:

<!ENTITY writer "Vigesa.">
<!ENTITY copyright "Copyright W3spoint.">

XML example:

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

An External Entity Declaration:

Syntax:

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

Example:

DTD Example:

<!ENTITY writer SYSTEM "https://www.w3spoint.com/entities.dtd">
<!ENTITY copyright SYSTEM "https://www.w3spoint.com/entities.dtd">

XML example:

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