Wednesday, 1 December 2010

Role of Entites

Discuss the roles of entities in XML, giving examples what problems can occur when they are not used properly.

# XML presents both a logical and a physical structure to a document. The logical notifies what elements should be in a document and in what order. However physical structure governs the content in a document in form of storage units called entities. An entity is a symbolic representation of data and information, to organize the documents into several files and to make it less complicated for writing DTDs. It has a number of uses. Such as it allows creating “macros” for content, which can be referred to in the document simply by referring to its name. Which is reusability of same content without the need of unnecessary repetition of them in the document. It also leads to efficient management and future modifications as now they can reside in a central location. Entities can be categorized into internal general, external general and parameter entities.
Internal entities: Instead of typing the same text again and again, an internal entity can be defined to contain the text and then we can need to use it where ever we want to insert that particular text. The text which is placed in by an entity reference is also known as the replacement text.
There are five internal entities which are predefined in XML:
  • 1t: less than sign (<)
  • gt: greater than sign (>)
  • amp: ampersand (&)
  • apos: single quote or apostrophe (‘)
  • quot: double quote (“)
All XML processors should recognize these entities whether they are declared or not.
Whereby, character reference refers to specific characters. It allows including the specified Unicode standard character directly into the document, even if they are not portable across applications and operating systems. Character references are numeric and can be practice without any special declaration.
Roles of internal entities: Basically, the role of internal entities depends on two possible views, from programming viewpoints and from publishing viewpoints.
  • In many XML documents, it contains URLs and it lack persistence and are complicated for maintaining. So, use of entities helps to make this easier.
  • XML numeric character references belong to the Unicode character set in either decimal or hexadecimal representation are not very perceptive. So, use of entities defines abbreviations to them and use entity references instead of the character references.
  • It allows defining shortcuts for frequently typed text, which improves accuracy while saving network bandwidth.
External entities: It offers a mechanism for dividing the document up into logical chunks. Example a big folder with 10 reports of customer, which can be break part each report of customers into different small folder in different files and use external entities to source in those reports. Because external entities in different documents can refer to the similar files on file system, it provides a prospect to implement reuse. External entities includes names and are reference in the similar approach as internal entities, although they are declared differently,
Roles of external general entities:
  • External entities can contain binary data which can be used to reference images and other non-XML content in the document.
  • It allows an XML document to incorporate content from external files.
Parameter Entities:  For effect of entities and entity references n DTD, parameter entities must be used, as external and internal entity references are not expanded in the DTD. Roles of Parameter entity:
  • It is mostly used to customize and extend DTDs. Basically; it is used to modularize a DTD for reuse and ease of maintenance. 

No comments:

Post a Comment