Quantcast

In a previous tutorial, attributes and elements of DTD were discussed. In this tutorial, we would focus mainly on the various entities used in DTD. An XML document is made up of data. XML documents can get data and declarations from many different sources, including CGI scripts, databases, and other XML files. Each of these items is an entity. In simple words, Entities are variables used to define shortcuts to standard text or special characters. The file you use to write your XML declaration, document type declaration, and root element is called the document entity.

Entities can be declared either internal or external. The syntax of an internal entity declaration is as follows:

Consider an example for internal entity declaration:

DTD Example:

XML example:

Now, consider the syntax and an example of external entity declaration:

Syntax:

Example:

XML example:

The entity reference (or name, in this context) must be preceded by an ampersand (&) and end with a semicolon (;). The period is optional, but conventional. Typically, the period separates the entity’s element or target from the type of entity.

Entities can be external to your XML document, like a style sheet or XSL document, or internal like something you define. The most common internal entity is a general entity. This is used as an abbreviation for commonly used text, or text that is difficult to type.

Which is more appropriate to use: internal or external entities? Using the external approach is preferable because the content (XUL) does not have to be touched during the translation process. If someone opts to create a tool to extract and/or insert strings, their job would be much easier if they had to parse one less file type. This may remove context somewhat, but it can be overcome by actively commenting the DTD file.

Looking for a quality hosting service? here are a few I suggest.
BlueHost | HostGator | Media Temple
Admin
Admin
Ali has been an entrepreneur in web, video and related technologies. Having worked with many business across the globe, Ali stands truly a great pillar in the business working with him.