The ENTITY
statement is used to define entities in the DTD, for use in both the XML document associated with the DTD and the DTD itself.
<!ENTITY [%] name [SYSTEM|PUBLIC publicID] resource [NDATA notation] >
General entity (parsed internal)
The following declares an internal general entity that can be referenced as öaut;
in XML documents that use the DTD.
<!ENTITY oumlaut "&#246;">
The XML parser expands the raw entity value (&#246;) to make it part of the internal XML document. In the final parsed document output, the "&" value becomes an "&" and the value appears as "ö" in the final parsed document.
Parameter entity (parsed internal)
The following declares an internal parameter entity that can be referenced as %lists;
in other places in the DTD. This allows repeated references to the XHTML list elements, <ul>
and <ol>
.
<!ENTITY % lists "ul | ol">
Unparsed external entity
The following declares an unparsed external entity that allows you to encode links to non-XML data (in this case, an image file in GIF format) for inclusion in your XML document.
<!ENTITY image.banner SYSTEM "banner.gif" NDATA image_gif >
In this case, the use of the NDATA
keyword requires that a NOTATION
declaration for a notation called "gif" must also be used in combination with this declaration. For more information, see NOTATION.
Entities can be used in a variety of ways. If you are not sure how to define an entity for use, the following questions might help you better understand the different conditions for using the entities you declare in the DTD:
ATTLIST (Attribute List) | ELEMENT | NOTATION