Вы находитесь на странице: 1из 45

Extensible Markup Language

Rationale

Data interchange is essential to carry out business


transactions. However, organizations store data in disparate
formats, which makes the process of data interchange
complex and time-consuming.
Extensible Markup Language (XML) is a standard, simple
way of storing the data in a format that can be exchanged
across multiple systems across an enterprise. Providing an
insight into XML will benefit students as it is a standard
technology to describe and define documents.
The course is applicable to students who want to create
well-formed XML documents. This course introduces
students to the fundamentals of XML.

Ver. 1.0 Session 1 Slide 1 of 45


Extensible Markup Language
Objectives

In this session, you will learn to:


Identify the need for XML as a standard data interchange
format
Identify the structure of XML documents
Introduce XML Schema

Ver. 1.0 Session 1 Slide 2 of 45


Extensible Markup Language
Getting Started with XML

Traditionally, preprinted formats were used to exchange


information between businesses.
Need for a more effective way of communicating and
processing business data led to the emergence of
Electronic Data Interchange (EDI).
EDI refers to the process of exchanging documents in a
standard format between two computer systems.
EDI has the following limitations:
Rigid transaction set
Fixed business rules
High costs
Slow pace of standards evolution

Ver. 1.0 Session 1 Slide 3 of 45


Extensible Markup Language
Introducing XML

XML is a text-based markup language that enables storage


of data in a structured format.
XML is a cross-platform, hardware and software
independent markup language that enables structured data
transfer between heterogeneous systems.
XML is used as a common data interchange format in a
number of applications.

Let us understand the usage of XML with the help of the


diagram.

Ver. 1.0 Session 1 Slide 4 of 45


Extensible Markup Language
Introducing XML (Contd.)

Mobile Application Web Services

Windows Application

Web Application

XML

DB2 Oracle
SQL Server Access
Data Sources

Ver. 1.0 Session 1 Slide 5 of 45


Extensible Markup Language
Introducing XML (Contd.)

Web Architecture Using XML


In a traditional Web architecture, a client sends a request to
the server in a pre-defined format and receives the response
accordingly.
The advantage of using XML in the Web architecture is that the
structure of the request can be obtained from the server at run
time.
XML can encode non-relational data as well as relational data
structure.

Ver. 1.0 Session 1 Slide 6 of 45


Extensible Markup Language
Introducing XML (Contd.)

Web Architecture Using XML (Contd.)


The following figure depicts the XML Web architecture.

Ver. 1.0 Session 1 Slide 7 of 45


Extensible Markup Language
Introducing XML (Contd.)

Difference Between SGML, HTML, and XML


Standard Generalized Markup Language (SGML) allows
documents to describe their grammar by specifying the tag set
used in the document and the structural relationship that these
tags represent.
Hypertext Markup Language (HTML) is used for data
presentation.
XML is used for data description and definition.

Ver. 1.0 Session 1 Slide 8 of 45


Extensible Markup Language
Introducing XML (Contd.)

Difference Between SGML, HTML, and XML (Contd.)

SGML HTML XML


Extensibility
Yes Yes Yes

Structure
Yes No Yes

Validation Yes No Yes

Browser Low High Low


Dependency
Cost/Benefit Poor Good Medium

Ver. 1.0 Session 1 Slide 9 of 45


Extensible Markup Language
Introducing XML (Contd.)

Advantages of XML
Some of the advantages of XML are:
Domain-specific vocabulary
Data interchange
Smart searches
Granular updates
User-selected view of data
Message transformation

Ver. 1.0 Session 1 Slide 10 of 45


Extensible Markup Language
Introducing XML (Contd.)

Advantages of XML
Some of the advantages of XML are:
Domain-specific vocabulary In HTML, only the predefined tags can
be used.
Data interchange
Smart searches In XML, you can create new tags based
on the requirements of the application.
Granular updates
Various languages such as MathML and
User-selected view of data WML have been derived from XML.
Message transformation

Ver. 1.0 Session 1 Slide 11 of 45


Extensible Markup Language
Introducing XML (Contd.)

Advantages of XML
Some of the advantages of XML are:
Domain-specific vocabulary
Data interchange XML produces files that are
unambiguous, easy to generate,
Smart searches
and easy to read.
Granular updates
XML provides a structure to
User-selected view of data store data in textual format,
Message transformation which can then be used as a
standard format or protocol for
data interchange.

Ver. 1.0 Session 1 Slide 12 of 45


Extensible Markup Language
Introducing XML (Contd.)

Advantages of XML
Some of the advantages of XML are:
Domain-specific vocabulary
Data interchange
Smart searches The flexibility to create user-defined
tags in XML enables creation of
Granular updates
smart search engines.
User-selected view of data
You can differentiate whether you
Message transformation want do to search based on a text
or on a tag, which enables the
browser to perform a focused
search and return precise
information that matches the search
query.

Ver. 1.0 Session 1 Slide 13 of 45


Extensible Markup Language
Introducing XML (Contd.)

Advantages of XML
Some of the advantages of XML are:
Domain-specific vocabulary
Data interchange
Smart searches
Granular updates Document updates in HTML
are slow as the entire
User-selected view of data document needs to be
Message transformation refreshed from the server.
Document updates in XML are
faster as only the changed
content needs to be
downloaded.

Ver. 1.0 Session 1 Slide 14 of 45


Extensible Markup Language
Introducing XML (Contd.)

Advantages of XML
Some of the advantages of XML are:
Domain-specific vocabulary
Data interchange
Smart searches
Granular updates
User-selected view of data In HTML, you need to create
separate HTML pages to
Message transformation display the same information
in different formats while XML
concentrates on data and not
on its presentation.
HTML does not allow
conditional formatting of a
document while in XML
conditional formatting is
possible.

Ver. 1.0 Session 1 Slide 15 of 45


Extensible Markup Language
Introducing XML (Contd.)

Advantages of XML
Some of the advantages of XML are:
Domain-specific vocabulary
Data interchange
Smart searches
Granular updates
User-selected view of data
Message transformation In XML, a message can be stored in
the form of a document, object data,
or data from a database.
XML design provides flexibility while
storing data as it does not impose
any restriction on the field size and
the order in which the data is stored.

Ver. 1.0 Session 1 Slide 16 of 45


Extensible Markup Language
Introducing XML (Contd.)

Future of XML
The future uses of XML can be summarized as:
XML will be widely used in e-commerce.
XML will have a huge core market in the form of Business to
Business (B2B).
XML will be used for mobile devices due to its ability to easily
convert into the appropriate format for any device.
XML will be used to solve communication problems in EDI and
Enterprise Application Integration (EAI) as it provides
interoperability between disparate applications.

Ver. 1.0 Session 1 Slide 17 of 45


Extensible Markup Language
Introducing W3C

W3C is responsible for the development of Web


specifications that describe communication protocols and
technologies for the Web.
Due to the flexibility for customization in XML, W3C has laid
down these rules that need to be followed by all XML
vendors:
XML must be directly usable over the Internet.
XML must support a wide variety of applications.
XML must be compatible with SGML.
XML should have absolute minimum number of optional
features, ideally zero.
XML documents must be human legible and clear.
XML design must be formal and concise.
XML documents must adhere to a set of constraints called full
normalization.

Ver. 1.0 Session 1 Slide 18 of 45


Extensible Markup Language
Identifying the Structure of XML Documents

An XML application is considered well designed if it is


robust and scalable.
To design a robust and scalable XML application, the
following steps need to be performed:
1. Create an information model.
2. Identify the required components of the XML document.
3. Create the XML document.

Ver. 1.0 Session 1 Slide 19 of 45


Extensible Markup Language
Information Modeling

An information model is a description of the information


used in an organization.
Information modeling helps identify:
Objects involved in an application
Properties of the objects
Relationships among objects
XML provides the following additional capabilities to
information modeling:
Heterogeneity Each record can contain different data
fields.
New data types can be added
Extensibility
whenever
Data fieldsrequired.
can vary in size and
Flexibility configuration between instances.

Ver. 1.0 Session 1 Slide 20 of 45


Extensible Markup Language
Information Modeling (Contd.)

Types of information models that can be created for an XML


application are:
Static model: Helps define all the objects in an application and
the relationships among them.
Dynamic model: Helps to determine the information flow of an
application in the form of messages.

Ver. 1.0 Session 1 Slide 21 of 45


Extensible Markup Language
Components of an XML Document

The various components of an XML document used for


representing data in a hierarchical order are:
Processing Instruction (PI)
Tags
Elements
Content
Attributes
Entities
Comments

Ver. 1.0 Session 1 Slide 22 of 45


Extensible Markup Language
Components of an XML Document (Contd.)

<?xml version=“1.0” encoding=“UTF-8”?>


<STOREDATA> Processing Instruction (PI)

<!--STOREDATA is the root element--> Provides information on how


the XML file should be
<STORE STOREID=“S101”>
processed.
<PRODUCTNAME>Toys</PRODUCTNAME>
<QUANTITY>100</QUANTITY>
<DISPLAY>The price of this toy is
&lt; 200 </DISPLAY>
</STORE>
</STOREDATA>

Ver. 1.0 Session 1 Slide 23 of 45


Extensible Markup Language
Components of an XML Document (Contd.)

<?xml version=“1.0” encoding=“UTF-8”?>


<STOREDATA>
<!--STOREDATA is the root element--> Tags
<STORE STOREID=“S101”> Is a means of identifying
<PRODUCTNAME>Toys</PRODUCTNAME> data. Tags consist of start
<QUANTITY>100</QUANTITY> tag and end tag.
<DISPLAY>The price of this toy is
&lt; 200 </DISPLAY>
</STORE>
</STOREDATA>

Ver. 1.0 Session 1 Slide 24 of 45


Extensible Markup Language
Components of an XML Document (Contd.)

<?xml version=“1.0” encoding=“UTF-8”?>


<STOREDATA>
Root Element
<!--STOREDATA is the root element-->
Contains all other elements
<STORE STOREID=“S101”>
in the document.
<PRODUCTNAME>Toys</PRODUCTNAME>
<QUANTITY>100</QUANTITY>
<DISPLAY>The price of this toy is
&lt; 200 </DISPLAY>
</STORE>
</STOREDATA>

Ver. 1.0 Session 1 Slide 25 of 45


Extensible Markup Language
Components of an XML Document (Contd.)

<?xml version=“1.0” encoding=“UTF-8”?>


<STOREDATA>
<!--STOREDATA is the root element-->
Comments
<STORE STOREID=“S101”>
Are statements used to
<PRODUCTNAME>Toys</PRODUCTNAME>
explain the XML code.
<QUANTITY>100</QUANTITY>
<DISPLAY>The price of this toy is
&lt; 200 </DISPLAY>
</STORE>
</STOREDATA>

Ver. 1.0 Session 1 Slide 26 of 45


Extensible Markup Language
Components of an XML Document (Contd.)

<?xml version=“1.0” encoding=“UTF-8”?>


<STOREDATA>
<!--STOREDATA is the root element-->
<STORE STOREID=“S101”> Child Elements
<PRODUCTNAME>Toys</PRODUCTNAME>
Are the basic units used to
<QUANTITY>100</QUANTITY>
identify and describe data in
<DISPLAY>The price of this toy is XML.
&lt; 200 </DISPLAY>
</STORE>
</STOREDATA>

Ver. 1.0 Session 1 Slide 27 of 45


Extensible Markup Language
Components of an XML Document (Contd.)

<?xml version=“1.0” encoding=“UTF-8”?>


<STOREDATA>
<!--STOREDATA is the root element-->
<STORE STOREID=“S101”>
Attributes
<PRODUCTNAME>Toys</PRODUCTNAME>
<QUANTITY>100</QUANTITY> Provide additional
information about the
<DISPLAY>The price of this toy is
elements for which they are
&lt; 200 </DISPLAY> declared.
</STORE>
</STOREDATA>

Ver. 1.0 Session 1 Slide 28 of 45


Extensible Markup Language
Components of an XML Document (Contd.)

<?xml version=“1.0” encoding=“UTF-8”?>


<STOREDATA>
<!--STOREDATA is the root element-->
<STORE STOREID=“S101”>
<PRODUCTNAME>Toys</PRODUCTNAME> Content
<QUANTITY>100</QUANTITY>
Refers to the information
<DISPLAY>The price of this toy is represented by the elements
&lt; 200 </DISPLAY> of an XML document. An
</STORE> element can contain:
</STOREDATA> • Character or data content
• Element content
• Combination or mixed
content

Ver. 1.0 Session 1 Slide 29 of 45


Extensible Markup Language
Components of an XML Document (Contd.)

<?xml version=“1.0” encoding=“UTF-8”?>


<STOREDATA>
<!--STOREDATA is the root element-->
<STORE STOREID=“S101”>
<PRODUCTNAME>Toys</PRODUCTNAME>
<QUANTITY>100</QUANTITY>
<DISPLAY>The price of this toy is Entities
&lt; 200 </DISPLAY> Is a set of information that
</STORE> can be used by specifying a
</STOREDATA> single name.

Ver. 1.0 Session 1 Slide 30 of 45


Extensible Markup Language
Identifying the Rules for Creating XML Documents

The rules that govern the creation of a well-formed XML


document:
Every start tag must have an end tag.
Empty tags must be closed using a forward slash (/).
All attribute values must be given in double quotation marks.
Tags must have proper nesting.
XML tags are case sensitive.

Ver. 1.0 Session 1 Slide 31 of 45


Extensible Markup Language
Demo: Creating an XML Document

Problem Statement:
CyberShoppe, Inc. sells toys and books in the United States. It
has three branches in different parts of the country. Currently,
the three branches maintain data on their local computer
systems. The IT manager at CyberShoppe has identified that a
centralized data repository on the products sold through its
e-commerce site is required. The data from all branches must
be collated and housed in a centralized location. This data
must be made available to the Accounts and Sales sections at
the individual branches, regardless of the hardware and
software platforms being used at the branches.
In addition, the sales personnel require access to the data
using palmtops and cellular phones. The product details of
CyberShoppe consist of the product name, a brief description,
the price, and the available quantity on hand. A product ID
uniquely identifies each product.

Ver. 1.0 Session 1 Slide 32 of 45


Extensible Markup Language
Introducing XML Schema

An XML schema defines the list of elements and attributes


that can be used in an XML document.
An XML schema specifies the order in which the elements
appear in the XML document, and their data types.
Microsoft has developed the XML Schema Definition (XSD)
language to define the schema of an XML document.

Ver. 1.0 Session 1 Slide 33 of 45


Extensible Markup Language
Advantages of XML Schema Created Using XSDs

Some of the advantages of creating an XML schema by


using XSD are:
XSD provides control over the type of data that can be
assigned to elements and attributes.
XSD enables you to create your own data types.
XSD enables you to specify restrictions on data.
The syntax for defining an XSD is the same as the syntax used
for XML documents.
XML schema content models can be used to validate mixed
content.
XML schema is extensible.
XML schema is self documenting.

Ver. 1.0 Session 1 Slide 34 of 45


Extensible Markup Language
Support for XML Schemas in Various Parsers

Parsers that provide support for XML schemas are:


IBM XML4J: Validates XML documents against several types
of XML schemas.
MSXML 6.0: Enables loading of XML data from anonymous or
untrusted sources in a secured manner.

Ver. 1.0 Session 1 Slide 35 of 45


Extensible Markup Language
Data Types in XML Schemas

In an XML schema created using XSD, every element must


be associated with a data type.
XSD provides the following list of predefined data types:
Primitive
Derived
Atomic
List
Union

Ver. 1.0 Session 1 Slide 36 of 45


Extensible Markup Language
Data Types in XML Schemas (Contd.)

In an XML schema created using XSD, every element must


be associated with a data type.
XSD provides the following list of predefined data types:
Primitive Do not contain elements or attributes.

Derived Contain only values.

Atomic
List
Union

Ver. 1.0 Session 1 Slide 37 of 45


Extensible Markup Language
Data Types in XML Schemas (Contd.)

In an XML schema created using XSD, every element must


be associated with a data type.
XSD provides the following list of predefined data types:
Primitive
Derived Are defined by using other data types
called base types.
Atomic
Can be built-in or user-defined.
List
Union

Ver. 1.0 Session 1 Slide 38 of 45


Extensible Markup Language
Data Types in XML Schemas (Contd.)

In an XML schema created using XSD, every element must


be associated with a data type.
XSD provides the following list of predefined data types:
Primitive
Derived
Atomic Cannot be broken down into smaller
units.
List
Can be primitive or derived.
Union

Ver. 1.0 Session 1 Slide 39 of 45


Extensible Markup Language
Data Types in XML Schemas (Contd.)

In an XML schema created using XSD, every element must


be associated with a data type.
XSD provides the following list of predefined data types:
Primitive
Derived
Atomic
List Are derived data types that contain a set
of values of atomic data types.
Union
Elements referring to a list data type can
contain a value only from that defined
set.

Ver. 1.0 Session 1 Slide 40 of 45


Extensible Markup Language
Data Types in XML Schemas (Contd.)

In an XML schema created using XSD, every element must


be associated with a data type.
XSD provides the following list of predefined data types:
Primitive
Derived
Atomic
List
Union Are derived from the atomic and list data
types.

Ver. 1.0 Session 1 Slide 41 of 45


Extensible Markup Language
Summary

In this session, you learned that:


EDI refers to the process of exchanging documents in a
standard format between two computer systems.
XML is a text-based markup language that enables you to
store data in a structured format by using meaningful tags.
Using XML in Web architecture enables loose coupling
between the server application and the client application.
XML has the following advantages:
Domain‑specific vocabulary
Data interchange
Smart searches
Granular updates
User‑selected view of data
Message transformation

Ver. 1.0 Session 1 Slide 42 of 45


Extensible Markup Language
Summary (Contd.)

In future, XML will be widely used in:


E-commerce
B2B services
Mobile services
EDI and EAI
XML was defined by W3C to ensure that structured data is
uniform and independent of vendors and applications.
In XML, an information model is used to understand the
structure and meaning of information that will be stored in XML
documents.
You can create static, dynamic, or a combination of both these
information models for an XML application.
A static information model helps you define all the objects in an
application and the relationships among them.

Ver. 1.0 Session 1 Slide 43 of 45


Extensible Markup Language
Summary (Contd.)

In a dynamic model, data flow diagrams and process diagrams


are used to determine the flow of information.
An XML document consists of:
Processing Instruction (PI)
Tags
Elements
Content
Attributes
Entities
Comments
An XML schema can be used to specify the list of elements
and the order in which these elements must appear in the XML
document.
The XSD language is used to describe the structure of the
elements in a schema.

Ver. 1.0 Session 1 Slide 44 of 45


Extensible Markup Language
Summary (Contd.)

The data types supported by an XML schema can be


categorized as follows:
Primitive
Derived
Atomic
List

Ver. 1.0 Session 1 Slide 45 of 45

Вам также может понравиться