0% found this document useful (0 votes)
2 views

XML_PPT

XML (eXtensible Markup Language) is a meta-markup language designed for data exchange on the web, allowing users to define their own tags and structure. Unlike HTML, which focuses on data presentation, XML is focused on describing data and is more flexible and adaptable. XML documents must adhere to specific syntax rules and can be validated against a Document Type Definition (DTD) to ensure they are well-formed and valid.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

XML_PPT

XML (eXtensible Markup Language) is a meta-markup language designed for data exchange on the web, allowing users to define their own tags and structure. Unlike HTML, which focuses on data presentation, XML is focused on describing data and is more flexible and adaptable. XML documents must adhere to specific syntax rules and can be validated against a Document Type Definition (DTD) to ensure they are well-formed and valid.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

XML

XML (eXtensible Markup


Language)
By Ms.
RIDDHI RANA
XML
What Is XML?

• eXtensible Markup Language


• XML is Meta-markup language (define your own markup
languages (tags) for your own problem domain)
• A simplified version of SGML
• More flexible and adaptable than HTML
• Designed for interoperability with SGML as well as
HTML
• Plays an important role in data exchange on the Web and in
other application areas

1
XML
What is XML ?
•“XML is a text that follows certain rules.” those are
very similar with html but having some
enhancement.
• It is a defector language which is used to exchange
the data over internet.
•The purpose of xml is X-extensible: (means it
is extended to meet the various requirements).
•Markup Language( used to identify the structure of
the documents and add meaning to different part of the
documents. )

2
XML
Limitation of HTML
• HTML does not provide arbitrary structure.
• It does not check the syntax.
• Unable to sort the data.
• No capability for advanced formatting.
•Having little ability to specify the meaning of
the information
• It is not readable.
• It does not support object oriented language

3
XML

Benefits of XML
• XML is used in Internet.
• It support a variety of applications.
• It prepares the document quickly and clearly.
• It minimizes the complexness of the document.
• It is designed to store, carry and exchange data over internet
but not to display data.
• It provide structured and Integrated data.
• It sort information easily and reuse the information.
• It provides self-description to data.
• It is Hierarchical
– Faster to access
– Easier to rearrange
4
XML
Need of XML
•XML is created to use user defined
structural document over the web
• It’s mainly used
 To exchange the data
 To share data
 To store data
 Separate data
 Create new language
• It’s bridging the gap between SGML and
HTML
5•
It provides the structure and implementation.
XML

Difference between XML and HTML


Different goals:
XML was designed to describe data and to focus on what data is.
- XML was designed to carry data, not displaying data
- Tags are user defined and it is very much suitable to send data
between two incompatible application.
-XML file is a small data base.<every thing you can
store.> It is a mother language to create other lanuage. Like
WML.

HTML was designed to display data and to focus on how data


looks.

– Tags are predefined and it apply some style on data.


– HTML is about displaying information, XML is about
6 describing information.
XML
Structure: HTML vs. XML

HTML (Automatic Presentation of Data)


<b> John Doe 1234 </b> // Display in bold

XML (Automatic Interpretation of Data)


<Employee>
<Name>
<firstName> John </firstName>
<lastName> Doe </lastName>
</Name>
<EmployeeID> 1234 </EmployeeID>
</Employee>

7
XML
XML Building blocks

• Element
Delimited by angle brackets
Identify the nature of the content they
surround General format: <element> …
</element> Empty element: <empty-
Element/>
• Attribute
Name-value pairs that occur inside start-tags after
element name, like: <element attribute=“value”>

8
XML
XML Tree
• XML documents form a tree structure that starts at "the root" and branches to
"the leaves".

9
XML

Example
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book category="social“ >
<title lang="en“ >Everyday
Italian</title>
<author >Giada De laury</author>
<year >2005</year>
<price >30</price>
</book>
</bookstore>

10
XML

XML
Syntax
•XML tags are case sensitive but the texts are
case insensitive.
• XML must have ending tags and every XML
document contain a root element.
• Elements are user defined in any XML document.
• One child element may have another child element.
<person><name>
<fname>xyz/Xyz</fname>
</name> </person>
• XML Elements Must be Properly Nested like
<b><i>Test Text</i></b>
11
XML
Rules for Element naming
• XML elements are naming by character.
• The tag declaration is as
<?xml Version=“1.0”?>(not part of doc)
• In place of attributes we can create child elements.
• Document must be validated and welformed
• XML elements must not have Blank space.
• <Date Of Birth>should be <Date-Of-Birth>
• Attribute value must be placed within double quotes
• <title lang=“en”>

12
XML

Entity References
• Some characters have a special meaning in
XML.
• If you place a character like "<" inside an XML
element, it will generate an error because the
parser interprets it as the start of a new element.
<message>if salary < 1000 then</message>
• To avoid this error, replace the "<" character
with an entity reference:
• <message>if salary &lt; 1000
then</message>
13
XML

Entity References
• There are 5 predefined entity references in XML:
Entity References Character

&lt; <
&gt; >
&amp; &
&quot; “
&apos; ‘
14
XML
Displaying XML

• XML documents do not carry information


about how to display the data
• We can add display information to XML with
– CSS (Cascading Style Sheets)
– HTML binding
– XSL (eXtensible Stylesheet Language)

15
XML
XML Components
XML main component is DTD and Document,
The other components are elements and Attributes

XML specifications defines 2 types of


documents:
• welformed
• valid

16
XML
Welformed documents
• An XML document with correct syntax is
called "Well Formed".
• It should be well organized and accurate.
• XML doc must contains at least one element
called root elements
• The root element must be unique and it
contains other child elements.
• Each start tag must have corresponding end tag

17
XML
Valid documents
• An XML document validated against a DTD.
• It requires a document type (!DOCTYPE)
• XML document refers to all rules declared in
a DTD

18
XML
DTD (Document Type Definition)
• The purpose of a DTD is to define the structure of an
XML document.
• A DTD describes the components and the guidelines
any xml vocabulary and its elements.
• It defines the various possible relationships between
these elements and how they can be nested.
• DTD are of two types :
– External DTD
– Internal DTD

19
XML
Internal DTD
• Documents are designed inside the same file
Example: “Address.xml”
<?xml version="1.0"?>
<!DOCTYPE address
[<!ELEMENT address (building,street,city)>
<!ELEMENT building (#PCDATA)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT city (#PCDATA)> ]>
<Address>
<building>Sweet plaza, 29 </building>
<street> Big bazar </street>
<city> Brahmapur </city>
</Address>
20
XML
External DTD
• External DTD is used highly than internal DTD
• As it uses multiple documents which are created using
the same class
• In this case a separate file is created that defines the
elements.

2`1
XML
External DTD
Example: “Addressdoc.dtd”
<!ELEMENT address (building,street,city)>
<!ELEMENT building (#PCDATA)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT city (#PCDATA)>

“Address.xml”
<?xml version="1.0"?>
<!DOCTYPE Address SYSTEM "Addressdoc.dtd">
<Address> :
<building> Sweet plaza, 29 </building>
<street> Big bazar </street>
<city> Brahmapur </city>
</Address>

22
XML
External DTD using css
“style.xml”
<?xml version="1.0"?>
<!DOCTYPE cdlib SYSTEM "cdlib.dtd">
<?xml-stylesheet href="cdlib.css"
type="text/css"?>
<cdlib> <cd>
<title>Mera Bharat</title>
<type>Mahan</type>
</cd>
</cdlib>
23
XML
External DTD
“cdlib.dtd”

• <!ELEMENT cdlib (cd+)>


• <!ELEMENT cd (title,type)>
• <!ELEMENT title (#PCDATA)>
• <!ELEMENT type (#PCDATA)>

24
XML
cdlib.css
“cdlib.css”
title{display : black;
color : green;
font-size : 48;
background-
color : red;
}
type { display : table;
color : red;
font-size : 44
}

25
XML
Uses of symbols in XML
( , ) : It separate the items
(|) : It indicates the occurrence of either left or right
operands or both
( ? ) : It indicates that operands may appears once or not at all
( * ) : It indicates zero or more occurrence for an element
( + ) : It indicates one or more occurrence for an element
( ) : It is used to combine the elements in mathematical way
Example:

<!ELEMENT family((father | mother)+, offspring ?)>


<!ELEMENT father(#PCDATA)>
<!ELEMENT mother(#PCDATA)>
26
XML
ELEMENT descriptions
• Suffixes:
? optional foreword?
+ one or more chapter+
* zero or more appendix*

• Separators
, both, in order foreword?, chapter+
| or section|chapter

• Grouping
() grouping (section|chapter)+

27
XML
Component of DTD
• PCDATA :-
– It parse the content of the element into character
data.
– It represent the text that found in between the begin
and end tag. It also expands the entities.
• CDATA or DOCTYPE :-
– It extracts the value of the particular text
from the respective XML tag.
– It does not parse by XML parser and does not
expand the XML entity.
28
XML

PCDATA
• PCDATA means parsed character data
• An XML parser is an API that reads the content of an
XML document
– Currently popular APIs are DOM (Document
Object Model) and SAX (Simple API for XML)
• Text found between the start tag and the end tag of an
XML element
• Text that will be parsed
• Tags inside the text will be treated as markup and
entities will be expanded

29
XML

CDATA

• CDATA means character data


• Text that will NOT be parsed
• Tags inside the text will NOT be treated as markup
and entities will not be expanded

30
XML
Declaring DTD elements
• Root elements are declared by !ELEMENT declaration tag
Syntax: <!ELEMENT elem-name (element-
contents)>
Ex: <!ELEMENT rootelem (child1,child2,...)>
• Child elements are also created in the above method
Syntax: <!ELEMENT elem-name (#PCDATA)>
Ex: <!ELEMENT childelem (#PCDATA)>
• Creating empty elements by using the EMPTY key-word
(element with no content)
Syntax: <!ELEMENT elem-name EMPTY>
31
XML
Declaring DTD elements cont..
• Declaring only one occurrence of the same element
Syntax:
<!ELEMENT rootelem (child-name)>
• Declaring one or more occurance of the same element
Syntax:
<!ELEMENT childelem (child-name)+>
• Declaring zero or more occurrence of the same element
Syntax:
<!ELEMENT childelem (child-name)*>

32
XML
Declaring DTD elements cont..
• Entities
These are the variables use to define the short-cut for
some common text.
It is declared using ENTITY declaration tag
Syntax:
<!ELEMENT entity-name "entity-value">
Ex:
<!ELEMENT price (#PCDATA)>
<!ENTITY cost "500">
<price> $cost </price>

33
XML

A DTD Example
<!DOCTYPE novel [
<!ELEMENT novel (foreword, chapter+)>
<!ELEMENT foreword (paragraph+)>
<!ELEMENT chapter (paragraph+)>
<!ELEMENT paragraph (#PCDATA)>
<!ATTRIBUTE chapter number CDATA #REQUIRED>
]>

• A novel consists of a foreword and one or more chapters, in that order


• A foreword consists of one or more paragraphs
• A chapter also consists of one or more paragraphs
• A paragraph consists of parsed character data (text that cannot contain
any other elements)
• Each chapter must have a number attribute

34
XML

Conclusion
• XML is a self-descriptive language

• XML is a powerful language to describe structure data


for web application

• XML is currently applied in many fields

• Many vendors already supports or will support XML

35
XML

Thank
You…

36

You might also like