0% found this document useful (0 votes)
17 views10 pages

Write Short Notes On Importance of XML

The document discusses XML and related technologies. It begins by defining XML and its importance, noting that XML is a markup language used to structure data and is a W3C recommendation. It then discusses XML syntax and rules for creating XML documents, including elements, tags, and nesting. Finally, it covers XML style sheets, XML transformations with XSLT, and the XML Document Object Model (DOM) which allows programs to dynamically modify XML documents.

Uploaded by

Parkchimochi 1
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views10 pages

Write Short Notes On Importance of XML

The document discusses XML and related technologies. It begins by defining XML and its importance, noting that XML is a markup language used to structure data and is a W3C recommendation. It then discusses XML syntax and rules for creating XML documents, including elements, tags, and nesting. Finally, it covers XML style sheets, XML transformations with XSLT, and the XML Document Object Model (DOM) which allows programs to dynamically modify XML documents.

Uploaded by

Parkchimochi 1
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

WEB TECHNOLOGIES

Unit – V
1. Write short notes on importance of XML.
Extensible Markup language (XML) is a simple markup language that describes the
structure of a document. It has been derived from the Standard Generalized Markup
Language (SGML). It is also used in data exchange on web.
XML does not display data but carry and store data. XML defines a set of rules with
the help of which other markup languages can be created. It may be referred as “Meta-
markup”.
XML is a W3C recommendation. The W3C is responsible for releasing the SML
versions. The latest version of XML is XML 2.0.
Features of XML:
1. It is a platform independent language.
2. It is very simple as HTML and has very few syntax rules.
3. XML files are text files and can be managed by all text editors.
4. It is extensible.
5. It is suitable for document storage and processing, both online and offline.
6. It supports Unicode.
7. It is a subset of SGML and is used to structure data as well as documents.
8. It can represent common data structures such as records, lists and trees.
9. It has a strict syntax and parsing requirements.
10. It provides a communication gateway between applications.
11. It is used for describing the data.
12. It stores the data in the form of tree.
13. It is suitable for handle complex structured data.

2. Explain in detail about syntax and rules for creating XML document.
XML document:
XML document can be defined as a file that contains variety of data and elements in an
orderly package.
Syntax:
<?xml version = “1.0”>
<root>
<child>
<subchild> ……… </subchild>
</child>
</root>
Steps for creating XML document:
1. Begin the program with a declaration statement.
<?xml version = “1.0”?>
2. Develop the root element. This element holds all the other elements is the first element
after declaration.
Ex:
<?xml version = “1.0” ?>
<Books>
</Books>
3. Declare the child element inside the root element.
Ex:
<?xml version =”1.0”?>
<Books>
<Subject>
</Subject>
</Books>
4. Declare a subchild inside the child element. This holds the data provided by users.
Ex:
<?xml version = “1.0”?>
<Books>
<Subject>
<Web Technologies>
</Web Technologies>
</Subject>
</Books>
Rules for XML document:
The rules of XML syntax are as follows:
1. The tags used in the XML document are case sensitive. It can use either upper case or
lower case or mixed case letters.
Ex:
<Good> …. </Good> (OR) <GOOD>…. </GOOD> (OR) <good>…. </good>
2. For every opening tag of XML document there must be a closing tag.
Ex:
<p> Welcome </p>
<place> India </place>
3. Every XML document must contain one root element. A root element is present at the
beginning of XML document.
Ex:
<start>
<body> ……… </body>
</start>
4. The elements of the XML document must be nested.
Ex:
<company>
<name> Samsung </name>
</company>
5. The attribute values of XML document are written with in a single or double quotation
marks.
Ex:
<image picture=”[Link]”/>
6. XML document support white spaces. It does not require any ASCII characters for
adding spaces.
Ex:
&nbsp
7. Root element should be closed first.
Ex:
<company>
<name> Samsung </name>
<location> India </location>
</company>
Program:
<?xml version = “1.0” ?>
<document>
<student>
<name>
<firstname> Siddhartha </firstname>
<lastname> College </lastname>
</name>
<rollno> 118620405001 </rollno>
<address> Dilsukhnagar</address>
<city> Hyderabad </city>
</student>
</document>

3. Explain about XML – style sheets.


Style sheet can be defined as a form that species a set of layouts of document used in
either word processing or desktop publishing.
XML style sheet is a language that provides styles to XML document by using:
1. Extensible Stylesheet Language (XSL)
2. Extensible Stylesheet Language Transformation (XSLT)
3. Cascading Style Sheet (CSS)
1. Extensible Stylesheet Language (XSL):
XSL is a language capable of transforming as well as formatting given XML documents.
➔ It can format or structure XML data depending on the supplied values.
➔ It can sort or filter XML documents.
Various tasks by using XSL are
➢ Adding/deleting elements
➢ Sorting and filtering of XML elements
➢ Testing and making decisions about elements to included or deleted etc.
Ex:
[Link]
<?xsl-stylesheet type=”text/xsl” href=”[Link]”?>
<menu>
<dvd>
<name> Don </name>
<actor> Prakash Chopra </actor>
<place> India </place>
<amount> Rs. 150 </amount>
<year of release> 2006 </year of release>
</dvd>
</menu>
[Link]
<xsl:Stylesheet>
<xsl:template match=”/”>
<html>
<body>
<table border=”1”>
<tr>
<th> Name </th>
<th> Actor </th>
</tr>
<xsl: for each select = “menu/dvd”>
<tr>
<td><xsl:value of select=”name”/> </td>
<td><xsl:value of select=”actor”/> </td>
</tr>
</xsl:for each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
2. Extensible StyleSheet Language Transformation (XSLT):
XSLT is a declarative programming language that converts and restructures as XML
document to some other form such as HTML or CSV. The steps of transformation in XSLT
are performed using an XSLT processors.
➢ Takes the source document as input.
➢ Creates a “source tree” of the document.
➢ Processes the source tree as per the templates in XSLT style sheet.
➢ Generates a “result tree”.
➢ Creates the result document from the result tree.
Ex:
[Link]
<Books>
<Book>
<Title> Web Technologies </Title>
<Author> XYZ </Author>
<Publisher> PQR </Publisher>
</Book>
</Books>
[Link]
<xsl:stylesheet
xmlns:xsl = “[Link]
version = “1.0”>
<xsl:template match=”/”>
<html>
<head>
<title> List of Books </title>
</head>
<body>
<h1>Books Details </h1>
</body>
</html>
</xsl:template>
<xsl:template match =”Books”>
<h2> <xsl:value_of select = “Title”/></h2>
<xsl:value_of select = “Author”/>
<xsl:value_of select = “Publisher”/>
</xsl:template>
</xsl:stylesheet>
[Link]
<html>
<head>
<tilte> List of Books </title>
</head>
<body>
<h1>Books Details </h1>
<h2> Web Technologies </h2>
ABC
PQR
</body>
</html>
3. Cascading Style Sheet (CSS)
CSS can be defined with XML as XSL for a given XML file.
[Link]
<?xml version = “1.0” encoding =”ISO-8859-1”?>
<?xml-stylesheet type=”text/css” href=”[Link]”>
<catalog>
<book>
<booktitle> Web Technologies </booktitle>
<author> ABC </author>
<amount> Rs.500 </amount>
</book>
</catalog>
[Link]
catalog {background-color:pink;
width:150%;}
book { display:block;
margin-bottom:20pt;
margin-left:0.5;}
booktitle { color:blue;
font-size:25pt;}
author {color:fuchsia;
font-size:25pt;}
amount {display:block;
color: purple;
margin-left:25pt;}
4. Explain XML Document Object Model (DOM).
XML Document Object Model (DOM) is an interface using which given programs/scrips
can dynamically alter the contents of a given XML document.
Features:
1. It is an Application Programming Interface (API) for XML document.
2. It allows user to access XML documents.
3. It allow user to change/modify XML documents.
4. It allow user to insert/delete XML documents.
5. It defines standard programming interface that allow user to work on any environment.
6. It provides a cross platform on which objects of XML document interact.
7. It defines objects and properties of XML element.
8. It defines objects and properties of XML document.
9. It specifies methods to access XML elements.
DOM Levels:
W3C has supplied certain specifications related to DOM which are claimed under various
levels. A few essentials corresponding to each of these levels are:
1. Essential Conditions at Level 0:
This level claimed all the specifications which existed even prior to DOM’s maturity.
Ex: DHTML object model
2. Essential Conditions at Level 1:
❖ Elements corresponding to HTML
❖ Content alteration
❖ Navigation of DOM document
3. Essential Conditions at Level 2:
❖ Support to events
❖ Support to views
❖ XML namespace
4. Essential Conditions at Level 3:
❖ Core
❖ Load and save, views and formatting
❖ Xpath
❖ Requirement and validations
Ex:
<table>

<tbody>

<tr> <tr>

<td> <td> <td> <td>

Apple Mango Grapes Orange

Program:
<table>
<tbody>
<tr>
<td>Apple</td>
<td>Mango</td>
</tr>
<tr>
<td>Grapes</td>
<td>Orange</td>
</tbody>
</table>

5. Explain in detail about X-Query or XML Query.


XML Query Language:
Xquery is a functional programming language developed by working group of W3C
recommendation. It is a xml query language that has been designed for retrieving data
stored in xml database. This language is used for querying xml data as well as for
transforming both structured and unstructured data stored in xml database into various
other formats.
Benefits of Xquery:
1. It is expressive language that enables a user to type a query irrespective of the data
structure.
2. The statements are relatively very brief when compared to the statements in SQL.
3. It is a flexible language that enable the user to query hierarchical as well as tabular data.
4. It is a consistent language.
5. It can be used as a URL in both xml and HTML attributes.
Uses of Xquery:
1. It extracts data from database to use it in webservices.
2. It creates reports in a summarized form on data stored in data base.
3. It has the ability of transforming xml data into XHTML.
4. It uses the extracted data for integrating applications.
5. It divides a single document that performs multiple transactions into multiple documents.
6. It defines syntaxes for creating new xml documents.
7. It searches data from relevant text based documents.

6. Advantages of XML DOM.


The advantages of XML DOM are:
1. It remains as a language and platform independent.
2. It allows the developer to the content of a given XML document dynamically.
3. It is traversable that means, it allows the developer to traverse into hierarchically
organized information to access the required data.
===================================================================

You might also like