Você está na página 1de 44

Module-5

XML and Ajax


Modules (Hours-42)

1. Introduction to Computers and the


Internet (HTML5)
2. Introduction to Cascading Style Sheets
(CSS)
3. JavaScript:
4. Document Object Model (DOM):
5. XML & Ajax
6. Web Servers & Server Side Programming
with PHP
XML:
• Introduction,
• XML Basics,
• Structuring Data,
• XML Namespaces,
• Document Type Definitions (DTDs),
• W3C XML Schema Documents,
• XML Vocabularies: MathML,
• Extensible Style sheet Language and XSL
Transformations,
• Document Object Model (DOM).

Ajax-Enabled Rich Internet Applications with XML and


JSON:
• Introduction,
• Rich Internet Applications (RIAs) with Ajax,
• Using XML and the DOM ,
• Creating a Full-Scale Ajax-Enabled Application
XML  : Introduction
• XML stands for eXtensible Markup
Language.
Markup:
• Markup means enclosing the textual
information in between two tags. ie
opening tag and closing tag is called as
Markup.
• Eg:
<empName> raja</empName>
<empSalary>9000</ empSalary>
Extensible:
XML tags are user defined tags.
that means :
1.The functionality of tags are also defined
by user.
2.These tags functionality possible to
extend as per the application
requirements. There for it is called
extensible markup language.
Language:
• Consider a web service application.
• In web server programming has a client
application and a server application.
• So as to exchange the data from client to
server and server to client for always using
XML format.
• The client application is Java/.net or any
other language application.
• The server application is Java/.net or any
other language application.
• So as to provide the communication
between or exchange the data between
one language application to another
language application are also using XML
format only.
• So XML is acting as a mediator or it is a
communicator between two different
language applications because of the
reason it is called language.
The Difference Between XML and
HTML
XML HTML
1. XML tags are user defied 1. HTML tags are
tags. predefined tags.
2. XML tags functionality 2. HTML tags functionality
defining by user and are limited because tags
extensible. are predefined tags.
3. XML tags are case 3. HTML tags are
sensitive . insensitive .
4. XML is mainly used to 4. HTML is used to display
describe the data. the data.
5. In XML , every opening 5. But in HTML, for all the
tags should required tag the closing tag is
closing tags. optional.
Use of XML 

• XML is mainly used to describe the data.


• XML documents possible to maintain text
based data bases.
• XML was designed to store and transport
data from one application to another
application.
• XML was designed to be both human- and
machine-readable.
XML Simplifies Things

• It simplifies data sharing


• It simplifies data transport
• It simplifies platform changes
• It simplifies data availability
XML Basics
• XML permits document authors to create
markup (i.e., a text-based notation for
describing data) for virtually any type of
information, enabling them to create entirely
new markup languages for describing any
type of data, such as mathematical formulas,
software configuration instructions, chemical
molecular structures, music, news, recipes
and financial reports. XML describes data in a
way that human beings can understand and
computers can process.
• Figure 15.1 is a simple XML document
that describes information for a baseball
player. We focus on lines 5–9 to introduce
basic XML syntax.
Structuring Data
XML Markup for a Business
Letter
XML Namespaces
• XML Namespaces provide a method to
avoid element name conflicts.
Name Conflicts
• In XML, element names are defined by the
developer.
• This often results in a conflict when trying
to mix XML documents from different
XML applications.
• This XML carries HTML table information:
• This XML carries information about a table
(a piece of furniture):
• If these XML fragments were added
together, there would be a name conflict.
• Both contain a <table> element, but the
elements have different content and
meaning.
Eg:2
• For example
<subject>Geometry</subject> and
<subject>Cardiology</subject>

• Namespaces can differentiate these two


subject elements—for example:
<highschool:subject>Geometry</highschool:
subject> and
<medicalschool:subject>Cardiology</
medicalschool:subject>
• use element subject to mark up data. In
the first case, the subject is something
one studies in school, whereas in the
second case, the subject is a field of
medicine.
• Both highschool and medicalschool are
namespace prefixes. A document author
places a namespace prefix and colon (:)
before an element name to specify the
namespace to which that element belongs.
Solving the Name Conflict Using
a Prefix
• Name conflicts in XML can easily be
avoided using a name prefix.
• This XML carries information about an
HTML table, and a piece of furniture:
• In the example above, there will be no
conflict because the two <table> elements
have different names.
XML Namespaces - The xmlns
Attribute
• When using prefixes in XML,
a namespace for the prefix must be
defined.
• The namespace can be defined by
an xmlns attribute in the start tag of an
element.
• The namespace declaration has the
following syntax.
xmlns:prefix="URI".
• In the example above:
• The xmlns attribute in the first <table>
element gives the h: prefix a qualified
namespace.
• The xmlns attribute in the second <table>
element gives the f: prefix a qualified
namespace.
• When a namespace is defined for an
element, all child elements with the same
prefix are associated with the same
namespace.
Namespaces can also be
declared in the XML root
element:
Default Namespaces

• To eliminate the need to place namespace


prefixes in each element, document
authors may specify a default namespace
for an element and its children.

• It has the following syntax:


xmlns="namespaceURI"
• This XML carries HTML table information:
• This XML carries information about a
piece of furniture:
Differentiating Elements with Namespaces

• Figure 15.5 demonstrates namespaces. In


this document, namespaces differentiate
two distinct elements—the file element
related to a text file and the file document
related to an image file.

Você também pode gostar