DTD - Entities
DTD Entities
DTD entities are used to define shortcuts to special characters.
DTD entities can be declared internal or external.
Internal Entity Declaration
An internal entity declaration in a DTD defines a shortcut text that can be reused inside your XML document.
Syntax
<!ENTITY entity-name "entity-value">
Example
DTD Example:
<!ENTITY writer "Donald Duck.">
<!ENTITY copyright "Copyright W3Schools.">
XML example:
<author>&writer;©right;</author>
Note: An entity has three parts: an ampersand (&), an entity name, and a semicolon (;).
External Entity Declaration
An external entity declaration in a DTD defines a custom entity whose content is loaded from an external source, using the SYSTEM or PUBLIC keyword.
Syntax
<!ENTITY entity-name SYSTEM "URI/URL">
Example
DTD Example:
<!ENTITY writer SYSTEM "https://www.w3schools.com/entities.dtd">
<!ENTITY copyright SYSTEM "https://www.w3schools.com/entities.dtd">
XML example:
<author>&writer;©right;</author>