Professional Documents
Culture Documents
Introduction To XML
Introduction To XML
Chapter 1
1
Chapter Objectives -1
Discuss markup language
List and explain drawbacks of HTML
Discuss the architecture of XML documents
List the benefits of XML
Discuss Parser
Processing Instructions
Entities
General Entities
Parameter Entities
1111 of 35
Core XML / Chapter 1 / Slide
XML -2
XML is a metalanguage and it describes other
languages.
The data contained in an XML file can be displayed
in different ways.
It can also be offered to other applications for further
processing.
Style sheets help transform structured data into
different HTML views. This enables data to be
displayed on different browsers.
1212 of 35
Core XML / Chapter 1 / Slide
XML Architecture - 1
XML supports three-tier architecture for handling
and manipulating data.
It can be generated from existing databases using a
scalable three-tier model.
XML tags represent the logical structure of data that
can be interpreted and used in various ways by
different applications.
The middle-tier is used to access multiple databases
and translate data into XML.
1313 of 35
Core XML / Chapter 1 / Slide
XML Architecture -2
1414 of 35
Core XML / Chapter 1 / Slide
XML – A Universal data format
HTML is a single markup language, but XML is a family
of markup languages.
Any type of data can be easily defined in XML.
XML is popular because it supports a wide range of
applications and is easy to use.
XML has a structured data format, which allows it to store
complex data
1515 of 35
Core XML / Chapter 1 / Slide
Benefits of XML
The three-tier architecture has easier
scalability and better security.
The benefits of XML are classified into the
following:
Business benefits
Technological benefits
1616 of 35
Core XML / Chapter 1 / Slide
Business Benefits
Information sharing:
Allows businesses to define data formats in XML
Provides tools to read, write and transform data between
XML and other formats
XML inside a single application:
Powerful, flexible and extensible language
Content Delivery:
Supports different users and channels, like digital TV,
phone, web and multimedia kiosks
1717 of 35
Core XML / Chapter 1 / Slide
Technological Benefits
Separation of data and
presentation
Re-use of data
1818 of 35
Core XML / Chapter 1 / Slide
XML Document Structure
An XML document is composed of sets of
“entities” identified by unique names.
All documents begin with a root or document
entity.
Entities are aliases for more complex functions.
Documents are logically composed of declarations,
elements, comments, character references, and
processing instructions.
1919 of 35
Core XML / Chapter 1 / Slide
Well formed and Valid Documents
An XML document is considered as well formed, if a
minimum set of requirements defined in the XML 1.0
specification are satisfied.
The requirements ensure that correct language terms are
used in the right manner .
A valid XML document is a well-formed XML
document, which conforms to the rules of a Document
Type Definition (DTD).
DTD defines the rules that an XML markup in the XML
document must follow.
2020 of 35
Core XML / Chapter 1 / Slide
Parsers - 1
Parsers help the computer interpret an XML
file.
<?xml
version=“1.0”?
>
<nxn>
</nxn>
2323 of 35
Core XML / Chapter 1 / Slide
Creating an XML Document
To create an XML document:
State an XML declaration
Create a root element
2424 of 35
Core XML / Chapter 1 / Slide
Stating an XML Declaration
Syntax
Element
2727 of 35
Core XML / Chapter 1 / Slide
Creating the XML Code -2
Rules govern the elements:
At least one element required
XML tags are case sensitive
2828 of 35
Core XML / Chapter 1 / Slide
Verify the document
The document should follow the
XML rules; otherwise it will not be
read by the browser or by any other
XML reader
2929 of 35
Core XML / Chapter 1 / Slide
Comments
This is information for the understanding of
the user, and is to be ignored by the processor.
Syntax
<!- - Write the comment here -- >
3131 of 35
Core XML / Chapter 1 / Slide
Character Data
The text between the start and end tags is
defined as ‘character data’.
Character data may be any legal (Unicode).
Character data is classified into:
PCDATA
CDATA
3232 of 35
Core XML / Chapter 1 / Slide
PCDATA
It stands for parsed character data.
PCDATA is text that will be parsed by a Parser.
Tags inside the text will be treated as markup and
entities will be expanded.
3535 of 35
Core XML / Chapter 1 / Slide
Examples of Entities
An example of Parameter entities An example of a General entity
< CLIENT = "&APTECH;" PRODUCT
= "&PRODUCT_ID;" QUANTITY <!ENTITY full_address " My
= "15"> Address 12 Tenth Ave. Suite 12
Entity declaration Paris, France">
Syntax Entity declaration
%PARAMETER_ENTITY_NAM Syntax
E; &ENTITY_NAME;
Example Example
%address; &address;
3636 of 35
Core XML / Chapter 1 / Slide
The DOCTYPE declarations
The <!DOCTYPE [..]> declaration follows the XML
declaration in an XML document.
Syntax
<?xml version="1.0"?>
<!DOCTYPE myDoc [
...declare the entities here....
<myDoc>
...body of the document....
</myDoc>
Example
<!DOCTYPE CUSTOMERS [
<!ENTITY firstFloor "15 Downing St Floor 1">
<!ENTITY secondFloor "15 Downing St Floor 2">
<!ENTITY thirdFloor "15 Downing St Floor 3">
]>
3737 of 35
Core XML / Chapter 1 / Slide
Attributes
An attribute gives information about an
element.
Attributes are embedded in the element start
tag.
An attribute consists of an attribute name and
attribute value.
Example
<TV count="8">SONY</TV>
<LAPTOP count="10">IBM</LAPTOP>
3838 of 35
Core XML / Chapter 1 / Slide
Summary-1
A markup language defines a set of rules that adds meaning to the content
and structure of documents
XML is extensible, which means that we can define our own set of tags,
and make it possible for other parties (people or programs) to know and
understand these tags. This makes XML much more flexible than HTML
XML inherits features from SGML and includes the features of HTML.
XML can be generated from existing databases using a scalable three-tier
model. XML-based data does not contain information about how data
should be displayed
An XML document is composed of a set of “entities” identified by unique
names
3939 of 35
Core XML / Chapter 1 / Slide
Summary-2
A well-formed document is one that conforms to the basic rules of XML;
a valid document is a well-formed document that conforms to the rules of
a DTD (Document Type Definition)
The parser helps the computer to interpret an XML file
Steps involved in the building of an XML document are:
Stating an XML declaration
4040 of 35
Core XML / Chapter 1 / Slide
Summary-3
Entities are used to avoid typing long pieces of text repeatedly
in a document. The two types of entities are:
General entities
Parameter entities
4141 of 35
Core XML / Chapter 1 / Slide