Fadi Yamani

advertisement
XML
Fadi Yamani
What is XML?
2
¨ 
XML stands for Extensible Markup Language . It is a
markup language much like HTML and it’s used to describe
data.
Java= Portable Programs
XML= Portable Data
What is Markup language?
3
¨ 
¨ 
¨ 
Markup language is combination of words and symbols, this
combination give us instruction and formatting for the page
layout.
The most advantages of this kind of language is that it’s
written within a text file, and the concept of this language is
not limited to computer programming.
A good and well known example of this kind of language is
HTML, XML.
What is XML?
4
¨ 
¨ 
XML does not specify the tag set or grammar of the language.
A simple text editor well do the job, the user can defined his
own tags, it is self descriptive.
¨ 
XML is a plain text with tags enclosed in angle brackets.
¨ 
The XML document is easily creatable, visible and modifiable.
(Purpose) why use XML?
5
¨ 
¨ 
Reusability
XML allow us to easily reuse our web sites and
services.
(Purpose) why use XML?
6
¨ 
¨ 
Adapting the data which is used in our websites or service for
future needs can be easily done by using XML, it could be
easily transformed to a new data format to build a new
services from our existing data.
XML also serves as a common platform for the transmission
and sharing of data between separate systems, allowing the
rapid development of Web services that query, retrieve and
share data among many sources.
(Purpose) why use XML?
7
How XML do that?
¨ 
Using XML related technologies (including XSLT, XQL, SGML,
W3C, HTML, SAX, DOM, JDOM) allowed us to transform
documents between other incompatible formats, present the
data in a specific format and style and it make it easy to
querying data from other resources.
(Purpose) why use XML?
8
(Key Features) Why XML Is So Important?
9
¨ 
Plain Text
In XML it is easy to create and edit files with anything from a
standard text editor to a visual development environment.
¨ 
Data Identification
The markup tags in XML documents identify the information
and break up the data into parts.
(Key Features) Why XML Is So Important?
10
¨ 
XML make data sharing easy
Data could be found in a different formats in the databases and
computer systems.
XML data is stored in plain text format. This provides a software- and
hardware-independent way of storing data.
This makes it much easier to create data that can be shared by
different applications.
(Key Features) Why XML Is So Important?
11
¨ 
XML makes data exchange easer
Exchanging data between different systems over the Internet is one of the
most time consuming operations for users.
Exchanging data as XML greatly reduces this complexity, since the data can
be read by different incompatible applications.
(Key Features) Why XML Is So Important?
12
¨ 
XML simplifies system upgrading
changing platform to new systems is always time consuming, large
amounts of data must be converted and incompatible data is often lost.
XML data is stored in text format. This makes it easier to expand or
upgrade to new operating systems, new applications, or new browsers,
without losing data.
Important parts, annotations or methods
13
¨ 
Relationship between XML elements is much like
parent and children.
Important parts, annotations or methods
14
¨ 
Imagine that this xml document is a description of an e-mail:
<?xml version="1.0" encoding="ISO-8859-1"?>
<E-mail>
<To>Fadi</To>
<From>Ali</From>
<Subject>Surprise....</Subject>
<Body>Be ready for next Friday</Body>
</E-mail>
¨ 
¨ 
¨ 
Here, E-mail is the root element.
To, From, Subject and Body are the child elements of the E-mail , at the same
time they are siblings because they have the same parentage
This concludes that all the XML Elements have relationships.
Important parts, annotations or methods
15
¨ 
The XML declaration: ¨ 
Always the first line in the xml document.
The XML declaration should always be included at the first line in the xml document. It
defines the XML version and the character encoding used in the document. In this case
the document conforms to the 1.0 specification of XML and uses the
ISO-8859-1 (Latin-1/West European) character set.
<?xml version="1.0" encoding="ISO-8859-1"?>
Important parts, annotations or methods
16
¨ 
Root Element:
The next line defines the first element of the document. <E-mail>
¨ 
Child Elements: The next lines describe the children elements of the root (To,
From, Subject and Body).
<To>Fadi</To>
<From>Ali</From>
<Subject>Surprise....</Subject>
<Body>Be ready for next friday</Body>
¨ 
And finally the last line defines the end of the root element.
</E-mail>
Important parts, annotations or methods
17
¨ 
All XML elements must have a closing tag
In XML all the elements must have a closing tag like this:
<To>Rohan</To>
<From>Amit</From>
¨ 
XML tags are case sensitive
XML tags are case sensitive. The tag <To> is different from the tag
<to>.Hence the opening and closing tags must be written with the same case:
<To>Rohan</To>
<to>Rohan</to>
Important parts, annotations or methods
18
¨ 
XML Documents Must Have a Root Element
All XML documents must contain a single tag pair to define a root element. All
other elements must be written within this root element. All elements can have
sub elements called as child elements. Sub elements must be correctly nested
within their parent element:
<root>
<child>
<subchild>.....</subchild>
</child>
</root> Role in Web Services
19
¨ 
¨ 
¨ 
XML and Web Services
common language for information interchange between
services and clients.
Defining Web services operations.
References
20
¨ 
¨ 
¨ 
¨ 
¨ 
¨ 
Sams Teach Yourself XML in 24 Hours, Third Edition
Learning XML 2nd Edition OReilly
Processing XML with Java Elliotte Rusty Harold's
Sun page on XML and Java (http://java.sun.com/xml/)
J2EE and XML development Kurta Gabrick, David Weiss
Code examples (http:// www.roseindia.net/)
Download