DTD - Entities

❮ 前章へ 次章へ ❯

Entities are used to define shortcuts to special characters.

Entities can be declared internal or external.


An Internal Entity Declaration

Syntax

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

DTD Example:

<!ENTITY writer "Donald Duck.">
<!ENTITY copyright "Copyright W3Schools.">

XML example:

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

注: An entity has three parts: an ampersand (&), an entity name, and a semicolon (;).



An External Entity Declaration

Syntax

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

DTD Example:

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

XML example:

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

❮ 前章へ 次章へ ❯