Annex C: Extensible Markup Language (XML)
295
XML entity
An XML entity is a mechanism for text substitution. It can make XML documents
simpler to read and quicker to write. In the following we define an XML entity
named "XML" which are used in a "p" element:


This is written in XML (&XML;).


The entity reference "&XML;" in the

element indicates that the reference
shall be replaced with the text of the entity. Only text entities that can be parsed as
XML can be referenced directly in the XML document.
XML entities are divided into text and binary entities. Binary entities do not contain valid XML and must therefore be referenced in an XML element's attribute of
the ENTITY type. Here we define an external binary entity named my.sign and refer
to it in the src attribute of an image element.



src
ENTITY
#REQUIRED>
This is my signature:
There is also a distinction between internal entities and external entities. An internal entity has a value associated with it as part of the entity declaration. An external
entity associates a name with a physical storage unit (file name). The "my.sign" entity above is an example of an external entity and the "XML" entity is an example of
an internal entity.
There is a special construct that only can be used in the DTD called a parameter
entity. A parameter entity can be used as a shortcut for commonly occurring text
structures. A parameter entity declaration is similar to an entity declaration except
with a "%" sign followed by aspace before the entity name. The parameter entity
will be substituted with its text by the XML processor when it reads the DTD. An
example of a declaration of a parameter entity called "Boolean" and its usage is as
follows:


Précédent

- 303/331

Suivant