XML DTD Entities
Entities are used to define shortcuts to special characters.
Entities can be declared internal or external.
note
An entity has three parts:
- An ampersand (
&
) - An entity name
- A semicolon (
;
)
Example of Internal Entity Declaration
Syntax
<!ENTITY entity-name "entity-value">
Example
DTD
<!ENTITY writer "Tom Nolan">
<!ENTITY copyright "Copyright TutorialReference.">
XML
<author>&writer;©right;</author>
Example of External Entity Declaration
Syntax
<!ENTITY entity-name SYSTEM "URI">
or
<!ENTITY entity-name SYSTEM "URL">
Example
DTD
<!ENTITY writer SYSTEM "https://tutorialreference.com/entities.dtd">
<!ENTITY copyright SYSTEM "https://tutorialreference.com/entities.dtd">
XML
<author>&writer;©right;</author>