You are on page 1of 22

E

xtensible Markup Language

I. NABEELA JASMINE

Page 1

THE RISE OF XML

XML is useful for representing any structured or unstructured data. Structured data refers to data that is identifiable because it is organized in a structure. Unstructured data refers to data that has no identifiable structure. For example: Videos, email Any such document following XML rules are said to be as XML document.
Page 2

ANATOMY OF XML DOCUMENT

XML stands for Extensible Markup Language. It is similar to HTML but designed to describe data. XML tags are not predefined. We define our own tags. It uses a Document Type Definition (DTD) or an XML schema to describe the data.
Page 3

DOCUMENT TYPE DEFINITION

DTD defines a legal building block of an XML document. It defines the document with list of its elements and attributes. DTD can be declared in 2 ways: Inside an XML document(internal DTD) As an external reference(externalDTD)
Page 4

INTERNAL DTD DECLARATION

If DTD is declared inside XML file, it should be wrapped in a DOCTYPE definition with the following syntax:
<!DOCTYPE root_element[element_declaration]>

Page 5

EXAMPLE
<?xml version="1.0"?> <!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> ]> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend</body> </note>
Page 6

THE DTD ABOVE IS INTERPRETED LIKE THIS:


!DOCTYPE note defines that the root element of this document is note !ELEMENT note defines "to,from,heading,body that the note element contains four elements:

!ELEMENT to defines the to element to be of type "#PCDATA(parsed character data) it is keyword to specify mixed content, an element may contain character data as well as child element in an orbitary order. Example: <!ELEMENT b(#PCDATA)>

<!ELEMENT p(#PCDATA|a|b)*> in this code element b must contain character data only,element p can contain a mixture of any combination of character data <a>,<b> elements. !ELEMENT from defines the from element to be of type "#PCDATA !ELEMENT heading defines the heading element to be of type "#PCDATA !ELEMENT body defines the body element to be of type "#PCDATA"

Page 7

EXTERNAL DTD DECLARATION

If the DTD is declared in an external file, it should be wrapped in a DOCTYPE definition with the following syntax:
<!DOCTYPE root-element SYSTEM "filename">
Page 8

EXAMPLE
<?xml version="1.0"?> <!DOCTYPE note SYSTEM "note.dtd"> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> Page 9

XML SCHEMA

XML Schema is an XML-based alternative to DTD. An XML schema describes the structure of an XML document.
Page 10

WHAT IS AN XML SCHEMA?


The purpose of an XML Schema is to define the legal building blocks of an XML document, just like a DTD. An XML Schema: defines elements that can appear in a document defines attributes that can appear in a document defines which elements are child elements
Page 11

Cont
defines the order of child elements defines the number of child elements defines whether an element is empty or can include text defines data types for elements and attributes defines default and fixed values for elements and attributes
Page 12

AN XML SCHEMA
The following example is an XML Schema file called "note.xsd" that defines the elements of the XML document above ("note.xml"): <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified">
Page 13

DIFFERENCE BETWEEN XML & HTML

XML
Data is stored in separate XML files. It is user defined language. It is used to describe data and focus on what data is All elements must be properly nested within each other XML is dynamic Is case-sensitive

HTML Data is store inside the files.

It is predefined language. It is used to display data and focus on how data looks Not much necessary
It is static Not case-sensitive
Page 14

HOW CAN XML BE USED?


Page 15

XML SEPARATES DATA FROM HTML

When HTML is used to display data, the data is stored inside your HTML with XML, data can be stored in separate XML files.

Page 16

XML CAN BE USED TO SHARE DATA


With XML, plaintext files can be used to share data. Since XML data is stored in plain text form at, XML provides a software and hardware independent way of sharing data.

Page 17

WORING WITH ELEMENTS AND ATTRIBUTES


Page 18

XML ELEMENTS
XML elements must have a closing tag. The following example is legal in HTML. <p> This is a paragraph <p> This is a another paragraph In XML all elements must have a closing tag. <p> This is a paragraph</p> <p> This is a another paragraph</p> Page 19

XML TAGS ARE CASE SENSITIVE

With XML, the tag <Letter> is different from <letter> opening and closing tags must therefore be written in same case.

<message> THIS IS INCORRECT </Message> <message> THIS IS CORRECT </message>


Page 20

ALL ELEMENTS MUST BE PROPERLY NESTED


In HTML, some elements can be improperly nested. <b><i> This text is bold and italic </b></i> In XML, all elements must be properly nested. <b><i> This text is bold and italic </i></b>
Page 21

THANK YOU!

Page 22

You might also like