Why Use XML In Web Design and Development
XML is used for designing the web pages in an application. XML means Extensible Markup Language. It is a markup language containing tags to define data. The tags used in the language contain the content specific meaning. The data is stored in a structured format. XML is a cross platform, hardware and software independent markup language. It helps computers to transfer data between the heterogeneous systems. It is used as a common data interchange format in number of applications.
Some of the advantages of XML in web designing are as mentioned below:
1. Domain specific vocabulary: It uses a set of predefined tags to present data in different format. While working with HTML, you are restricted to use only the specific tags. On the other hand, XML does not contain any predefined tags. User can create new tags based on the requirements of the application.
2. Data interchange: It is essential for performing business transactions. User needs to establish standard interfaces among the related enterprises in which the data is stored in disparate forms to facilitate data interchange. XML produces files that are unambiguous, easy to generate, and easy to read.
3. Smart Searches: HTML provides with a set of predefined tags, it is difficult to implement a search on an HTML document. Consider the following example.
4. Granular updates: Document updates are slow as the entire document needs to be refreshed from the server. In uploading an XML document, only the part of the document is uploaded.
5. User selected view of data: In HTML, user needs to create separate HTML pages to display the information in different formats. XML document focus on the data and not its presentation.
6. Message transformation: In XML, a message can be stored in the form of a document, object data or data from a database. The messages are designed such that they reflect the information content and not the use of the messages.
XML was defined by W3C to ensure that structured data is uniform and independent of vendors and applications. Due to the flexibility for customization in XML, W3C made certain rules that need to be followed by the users. They are as mentioned below:
An XML application is considered to be well designed if it is robust and scalable. To design a robust and scalable XML application, user needs to perform the following steps:
An information model is a description of the information used in an organization. In the absence of an information model, there is only data and no information.
In XML, an information model is used to understand the structure and meaning of information that will be stored in XML documents. It helps to identify the objects involved in an application, properties of the objects, and relationship among them.
XML provides the following capabilities to information modeling.
A static information model helps to define all the objects in an application and the relationship among them.
The best approach for the model is the step by step method. The method is described as follows:
In the dynamic model, data flow diagrams and process diagrams are used to determine the flow of information. User can determine the information flow of an application in the form of messages.
Some of the approaches of the dynamic model are as follows:
XML enables to store the structured data such that different devices can recognize it. User needs to recognize the data before storing it in the XML document. This involves arranging the data in a hierarchy. The various components of the XML document are as follows:
1. Processing Instruction (PI): An XML document usually begins with the XML declaration statement called the Processing Instruction known as PI. The PI provides the information on how the XML file should be processed. The statement can be written as follows:
2. Tags: They are used to specify the name of a given piece of information. It is the means of identifying data. The tag consists of opening and closing angular brackets. The name is enclosed in the tag. They occur in pairs.
The start tag contains the name of the tag and the end tag includes the forward slash (/) before the name of the tag. The example for the tag is as shown below:
3. Elements: They are the basic units to identify and describe the data in XML. They are used as building blocks of an XML document. Elements are represented using tags.
XML gives meaningful names to the elements. It helps to improve the readability of the code. Consider the following example.
An XML document must always have a root element. A root element contains all other elements in a document. Consider the following example.
4. Content: Content refers to the information represented by the elements of an XML document. Consider the following example.
XML enables to declare and use elements that contain different types of information. An element can contain:
a. Character or data content
Elements can contain only textual information. Consider the following example.
b. Element Content
Element can contain other elements. The elements contained in another element are called child elements. The containing element is called the parent element. A parent element can contain many child elements. All the child elements of a parent element are siblings and are related to each other. Consider the following example.
c. Combination or Mixed Content
Elements can contain textual information as well as other elements as shown in the following example.
Attributes provide additional information about the elements for which they are declared. An attribute consists of a name – value pair. Consider the following example.
Elements can have more than one attributes. User must decide whether the specific piece of information is represented as an element or as an attribute.
An entity is a name that is associated with the block of data. The data can be a text or reference to an external file that contains the textual or binary information. It is a set of information that can be used by specifying a single name.
XML provides predefined entities called internal entities that enable user to express characters in an XML document.
Some of the predefined internal entities that form a part of the XML specification are as mentioned below:
Internal Entity Description
Consider the following code snippet.
Comments are statements used to explain the XML code. They are used to provide documentation information about the XML file or the application to which the file belongs. The parser ignores the comment entries during the code execution.
Comments are not essential in an XML file. It is a good programming practice to add the comments along with the code. Comments are created by using the opening angular brackets followed by an exclamation mark and two hyphens (
You have learnt about the basic components of the XML document. These components can be used to create a well formed XML document.
The rules that are followed while creating the XML document are as follows:
1. Every start tag must have an end tag. They cannot be inferred. They must be explicitly specified. Every XML document must have a root element that contains the other elements used in the document.
2. Empty tags must be closed using a forward slash (/). They do not contain any information. They contain only attributes. The values are specified within the opening and closing angular brackets.
4. Tags must appear in proper nesting. The opening tags must appear in the reverse order in which they appear. Consider the following example.
|All times are GMT +5.5. The time now is 12:40.|