Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

1) Write a note on XML?

Ans:
 Extensible Markup Language (XML) is a markup language that defines a
set of rules for encoding documents in a format that is both human-
readable and machine-readable.
 The design goals of XML focus on simplicity, generality, and usability
across the Internet. It is a textual data format with strong support via
Unicode for different human languages.
 Although the design of XML focuses on documents, the language is
widely used for the representation of arbitrary data structures such as
those used in web services.
o XML stands for extensible Markup Language
o XML is a markup language like HTML
o XML is designed to store and transport data
o XML is designed to be self-descriptive

Features of xml:

1. XML is an easy and automatically parseable way to describe data.


2. More flexible and adaptable information identification.
3. XML is extensible.
4. XML lets us design our own customized mark-up language.
5. XML is a mark-up language much like HTML.
6. XML was designed to describe data.
7. XML tags are not predefined. You must define your own tags.

Application of xml:

I. Data transfer
II. Formatting documents
III. Web searching
IV. Creating layouts
V. Storing configuration data

2) What are the various components of xml?


Ans:
The components of xml are as follows:

1.Processing Instructions:

An XML Documents usually begins with the XML declaration statement called
the Processing Instructions .This statement provides information on how the
XML file should be processed.
e.g. <?xml version =”1.0” encoding=”UTF-8”?>
The Processing Instruction statement uses the encoding property to specify the
encoding scheme used to create the XML file
2. Tags:
Tags are used to specify a name for a given piece of information. It is a means
of identifying data. Data is marked up using tags.
3. Elements:
Elements are the basic units used to identify and describe the data in XML.
They are the building blocks of an XML document. Elements are represented
using tags.
4. Content:
Content refers to the information represented by the elements of an XML
document. Consider the following example:
<name>Jayanta</name >

Here Jayanta is content

5. Attributes:
Attributes provide additional information about the elements for which they are
declared. An attribute consists of a name-value pair. Consider the following
example:
<Student_name S_ID = “101”> Jayanta </ Student_name >
6. Entities:
An entity is a name that is associated with a block of data, such as chunk of text
or a reference to an external file that contains textual or binary information. It is
a set of information that can be specifying a single name.
7. Comments:
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 comments entries during code
execution.
3) Write difference between XML & XSLT?

Ans:

XML XSLT
XML is used for storing data in XSLT is used for transforming
a structured format. and also for formatting XML
file to display the content or to
process the content.
XML does not perform XSLT is a specialized language
transformation of data. that performs transformation
of one XML document into a
different XML document. XSLT
can also perform
transformation of XML
document into HTML
document and XHTML
document.
XPath is a specialized language XSLT will be using XPath for
that is used to address transformation and formatting
portions of the XML file of XML file.
XML stands for extensible XSLT stands for Extensible
markup language stylesheet language
transformation.

4) What are XML Schemas? Give difference between XSD and


DTD?

Ans:

XML Schema:
 XML schema is a language which is used for expressing constraint
about XML documents. There are so many schema languages which
are used now a days for example Relax- NG and XSD (XML schema
definition).
 An XML schema is used to define the structure of an XML document.
It is like DTD but provides more control on XML structure.
 XML Schema is commonly known as XML Schema Definition (XSD).
It is used to describe and validate the structure and the content of
XML data. XML schema defines the elements, attributes and data
types.
 Schema element supports Namespaces. It is similar to a database
schema that describes the data in a database.

XML Schema Data types

There are two types of data types in XML schema.

1. simple Type
2. complex Type

Simple Type:

The simple Type allows you to have text-based elements. It contains less
attributes, child elements, and cannot be left empty.

Complex Type:

The complex Type allows you to hold multiple attributes and elements. It
can contain additional sub elements and can be left empty.

DTD XSD
DTD stands for Document Type XSD stands for XML Schema
Definition. Definition
DTDs are derived from SGML syntax XSDs are written in XML.
DTD doesn't support datatypes. XSD supports datatypes for elements
and attributes.
DTD doesn't support namespace. XSD supports namespace.
DTD doesn't define order for child XSD defines order for child elements.
elements.
DTD is not extensible. XSD is extensible.
DTD is not simple to learn. XSD is simple to learn because you
don't need to learn new language.
DTD provides less control on XML XSD provides more control on XML
structure. structure.

5) What is XML namespace? Why it is important?


Ans:
XML Namespace is used to avoid element name conflict in XML document.
An XML namespace is declared using the reserved XML attribute. This attribute
name must be started with "xmlns".

In XML, elements name are defined by the developer so there is a chance


to conflict in name of the elements. To avoid these types of confliction we
use XML Namespaces. We can say that XML Namespaces provide a
method to avoid element name conflict.
Generally these conflict occurs when we try to mix XML documents from
different XML application.
XML namespace syntax:
<element xmlns:name = "URL">
Here, namespace starts with keyword "xmlns". The word name is a namespace
prefix. The URL is a namespace identifier.
Importance of xml namespace:
One of the primary motivations for defining an XML namespace is to avoid
naming conflicts when using and re-using multiple vocabularies. XML Schema is
used to create a vocabulary for an XML instance, and uses namespaces heavily.
Thus, having a sound grasp of the namespace concept is essential for
understanding XML Schema and instance validation overall.

You might also like