XML entities

 

+
Search Tips   |   Advanced Search

 

 

Overview

An entity in a DTD file is a shortcut used to represent complex strings or symbols that would otherwise be impossible, difficult or repetitive to include by hand. For example, to place a copyright notification at the end of every page of a book, create something like the following entity...

<!ENTITY copyright "Copyright 2004. MyCompany publishing.">

...where copyright is the name of the entity and "Copyright 2004. MyCompany publishing" is the text that the copyright entity represents.

To create an entity,...

  1. Open the DTD in the DTD editor.

  2. In the Outline view, right-click the DTD Image of the DTD icon and click Add Entity.

  3. In the Properties view, type the new name of the entity in the Name field.

  4. From the Entity Type drop down list, select General or Parameter. General entities are used in XML files, whereas parameter entities are used only in the DTD and do not have any use in an XML file.

  5. Select the External check box if you want to declare the entity as an external entity. An external entity references an external document or data.

  6. If you did make the entity external, the following fields appear:

    Public ID (Optional) Path to the DTD. In the DTD, you can use the resources in the file you are referencing.
    System ID Path to the external data or document you want to reference, or browse for it. In the DTD, you can use the resources in the file you are referencing.

    You only need to specify the Public ID or the System ID, not both. If, in the DTD, you want to use any of the resources (such as elements or attributes) contained in the document you have referenced, make this entity a Parameter entity, and "expand" the entity by creating an external parameter entity reference (right-click the DTD Image of the DTD icon, click Add Parameter Entity Reference, and select the entity you just created).

  7. If you did not make the entity external, you can specify the entity value in the Entity value field.

Reusing internal parameter entities in an attribute name or type
DTDs use entities to provide a mechanism to associate a name with a piece of text. Whenever you need to replace that text within a document, you can just use the name instead. There are many ways you can design entities in a DTD for reuse purposes.

Reusing the value of one entity in another entity
DTDs use entities to provide a mechanism to associate a name with a piece of text. Whenever you need to replace that text within a document, you can just use the name instead. There are many ways you can design entities in a DTD for reuse purposes.

 

Parent topic

Editing DTDs

 

Related tasks

Reusing external parameter entities in an element's content model
Deleting elements, attributes, entities, notations, and comments