MENU

Chapter 8 Introduction to XML Solutions

Question - 21 : - Explain the structure of XML document.

Answer - 21 : -

Structure of XML- File/Document
Every XML document includes both physical and logical structure which are as follows:
1. Physical Structure
It contains the actual data used in a document. The basic storage unit called entity, each of which may refer to other entities. An entity has a name and content. It contains references to other entities. There is a special entity called document entity or root, that serves as a main storage unit. XML processor always start document processing from that unit.
We have three classifications of entities, these are as follows:
1. Internal and External Entities
For internal entity, there is no separate physical storage object and the content of the entity is given in the declaration. It contained inside the document. If the entity is not internal, then it is an external entity.
2. General and Parameter Entities
General entities are entities which are used within the document content. In this specification, general entities are sometimes referred to with the unqualified entity, when this leads to no ambiguity. Generally, entities are declared and used differently. Parameter entities are parsed and used only in the DTD part of the XML document.
3. Parsed and Unparsed Entities
Parsed entities contain text that is referred as replacement text intended to be processed by the parser and is considered as an integral part of the document. Unparsed entities are resources that can be of any type including text objects. This type of entity is never process by parser.
2. Logical Structure
It is a template that enables the elements to be included in a document and in the order in which they have to be included.
The logical structure includes the basic components of the XML document. It indicates how a document is built, irrespective of what a document contains. The first structural element is prolog which is the base for the logical structure.
The structure of the document of example code:
                          

Question - 22 : - A well-formed document must have a root element. Explain with an example.

Answer - 22 : -

To create a well-formed XML document, it is necessary for it to have a root element. A root element is a unique element that contains all other elements in the XML document.
The XML document cannot contain more than one root element.
The following code is an example of a well-formed document:

Delhi
Delhi
India
Consider the same code written in the following way: 
Delhi
Delhi
India
The preceding code is not a well-formed document, since it does not contain a root element.

Question - 23 : - Define CSS. How to create a CSS file?

Answer - 23 : -

CSS is a simple design language intended to simplify the process of making Web pages presentable.
CSS is a type of stylesheet and this stylesheet consists of a list of rules. You can include a CSS in multiple XML documents that have the same data structure.
Syntax
selector
{
property: value; } Declaration Block
}
Creating a CSS File
To create a CSS file, you need to have all the style rules composed in it and save it with extension .css.

You can define the color in CSS by name as well as by code like green color may be written as #008000 or rgb(0,128,0).

Question - 24 : - Write two points of difference in HTML and XML. Write three points of well-formed XML document. Write the code to create an XML document to present following data: 

Answer - 24 : -

Two points of difference between HTML and XML follows:

HTML

XML

HTML is a markup language that creates the form and appearance of the Web page.

XML is a text-based markup language for processing and displaying data in a structured format.

HTML documents are viewable in a browser.

XML documents can be viewed only if proper stylesheet file is also available alongwith XML file.

Three points of well-formed XML document are as follows:
1. The document must have a root element.
2. The element must have the opening and closing tags.
3. XML attributes values, should be in double quotation marks.
Table
Wood
75
1st
Chair
Plastic
85
IInd

Question - 25 : - XML document structure can be divided in which two parts? What is meant by valid XML document (write three points)? Write the code to create an XML document to present following data:  

Answer - 25 : -

XML document structure can be divided into two parts as follows:

Well-formed XML document
Valid XML document
A valid XML document means to follow several terms, such as follows:

It is not only a well-formed document but as well as check error against a DTD.
It signifies that a document is well-formed.
It uses XML parser, XML validator for validation.
The XML code is
Srishti
Programmer
Engineering
5E
Aditi
Designer
Marketing
19T

Question - 26 : - Write two points of differences between XML and HTML. What is meant by a well-formed XML document (write two points)? Write the code to create an XML document with following data:

Answer - 26 : -

The differences between XML and HTML are as follows:

HTML has predefined tags while XML has user-defined tags.
HTML document can be viewed directly by the Web browser while XML document cannot be viewed directly and need some proper stylesheet files.
A well-formed document means to follow several generic rules, such as follows:

XML document must contain atleast one element.
All tags must have the opening and closing tags as these XML tags are case sensitive.
The XML code is
Singapore
200000
8
Aeroplane
Shimla
10000
4
Bus

Question - 27 : - Explain with a help of an example, how root elements are placed in a XML document?

Answer - 27 : -

XML documents must contain one element that is the parent of all other elements. This element is called the root element. The root element encloses all other elements in XML. All other elements inside the root elements are the form of child element. The structure of the XML file should look like

....
e.g.
101
Rahul
102
Sahil
103
Muskan
You can see in the above example that the root element declared out here is then comes the child element which in turn stores the and of the employee in the tags.

Free - Previous Years Question Papers
Any questions? Ask us!
×