2. WHAT IS XML?
Extensible Markup Language (XML)
is a markup language that defines a
set of rules for encoding documents in
a formatwhich is both human-
readable and machine-readable
XML was designed to carry data, not
to display data
3. XML HTML
Used to carry data
Can create own tags
Platform independent and language
independent
Tags and attributes are case sensitive &
must be quoted
XML elements must be properly nested
All XML elements must have a closing
tag
XML is used to create new internet
languages. Here are some examples:
◦ WSDL for describing available web
services
◦ WAP and WML as markup languages for
handheld devices
◦ RSS languages for news feeds
◦ RDF and OWL for describing resources
and ontology
◦ SMIL for describing multimedia for the web
Used to display data
Cant create own tags
Not language
independent
Tags are not case
sensitive & quotes is not
complusory
4. WHERE AND WHY XML?
SCENARIO
A web service client or server written in
java must convert between its internal
representation of data and character
strings appropriate for representing the
data in a SOAP document(or any kind of
doc used for displaying the data in the
web)
Eg: Currency convertor
From dollars : web service has to convert
the java double value to represent the
amount in string
5. Contd..
What would be the constraints in this
process??
Data range decision
Value constraints
Usage of scientific notation
Precision issues and etc..
6. Solution???
XML SCHMEA (XML VOCABULARY):
It has a definition of collection of
standard data types.
It has the range of values that could
be used for a particular data type and
then datas on how to represent the
values
7. XML SCHEMA
WELL FORMED XML DOCUMENT
XML with correct syntax is "Well Formed" XML.
XML validated against a DTD is "Valid" XML.
Example for XML Document
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me! </body>
</note>
8. XML ELEMENT &
VOCABULARY
XML Element
An XML element is everything from (including) the element's
start tag to (including) the element's end tag.
An element can contain:
other elements
text
attributes
Or a mix of all of the above...
XML vocabulary
XML vocabulary is used to define
element and attribute names
element content
Semantics of elements and attributes
Some of the xml vocabularies are XHTML, RSS, XSL, DTD,
and Schema
9. Xml schema and DTD
DTD SCHEMA
Defines the structure with a
list of defined elements in the
xml document.
<!DOCTYPE note
[
<!ELEMENT note
(to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from
(#PCDATA)>
<!ELEMENT heading
(#PCDATA)>
<!ELEMENT body
(#PCDATA)>
]>
Extension: .dtd
Has only two data types: CDATA
& PDATA
It is an alternative to DTD to define the
structure of an XML document.
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element
name="to" type="xs:string"/>
<xs:element
name="from" type="xs:string"/>
<xs:element name="heading"
type="xs:string"/>
<xs:element
name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
This definition file is stored with .xsl
extension.
Can have primitive and complex data
types.
10. DATA TYPES IN XML
SCHEMA
DATA TYPES
SIMPLE
PRIMITIVE(BUILT-
IN)
USER DEFINED
COMPLEX
PRIMITIVE(BUILT-
IN)
USER DEFINED
11. A quick comparison..
SIMPLE DATA TYPE
Values are
represented in xml
doc by character
data
Used to represent
individual values
COMPLEX DATA
TYPE
Values are
represented using
mark up.
Used to represent
structured
data(highly
organised).
12. Built in data type..
Simplebuiltindatatypes
The data types
defined by xml
schema
specification itself
are called built-in
data types.
Eg:
<latitude
xsi:type=“xsd:decim
al”>40.28</latitude>
Xsd decimal is a
reference to XML
schema
Xml schema type is
similar to java ‘s primitive
types. Except for boolean
XML schema types
appear as type and
message elements.
Within types, user
defined data types are
the building blocks for
user-defined types.
Within message
elements built in types
are used to declare data
type for an operation
parameter or return
value.
13. XML NAMESPACES
It is a collection of element and
attributes names associated with an
XML vocabulary. XML Namespaces
provide a method to avoid element
name conflicts.
doc1
• <table>
<tr>
<td>Apples</
td>
<td>Bananas
</td>
</tr>
</table>
Doc 2
•<table>
<name> Coffee
Table</name>
<width>80</widt
h>
<length>120</le
ngth>
</table>
Namespace
usage
• <h:table>
<h:tr>
<h:td>Apples</h:td
>
<h:td>Bananas</h:
td>
</h:tr>
</h:table>
<f:table>
<f:name>African
Coffee
Table</f:name>
<f:width>80</f:width
>
<f:length>120</f:len
gth>
</f:table>
14. USER DEFINED TYPES..
USER DEFINED
SIMPLE TYPES
<simpleType
name=“memberType”>
<restriction
base=“string”>
<enumeration
value=“platinum”/>
<enumeration
value=“gold”/>
</restriction>
</simpleType>
Facets of simple data
type:
length,minlength,maxlen
gth
USER DEFINED
COMPLEX TYPE
<anExchangeValue
xsi:type=“ExchangeVal
ues”>
<dollars>1.0</dollars>
<euros>0.7468</euros
>
</anExchangeValue>