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

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

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

it should be wrapped in a DOCTYPE definition with the following syntax: <!DOCTYPE root_element[element_declaration]> Page 5 .INTERNAL DTD DECLARATION • If DTD is declared inside XML file.

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 .EXAMPLE <?xml version="1.0"?> <!DOCTYPE note [ <!ELEMENT note (to.from.heading.

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>. • • • !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 . an element may contain character data as well as child element in an orbitary order.<b> elements.from.THE DTD ABOVE IS INTERPRETED LIKE THIS: • • • • !DOCTYPE note defines that the root element of this document is note !ELEMENT note defines "to.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.heading.

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

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 .

Page 10 . • An XML schema describes the structure of an XML document.XML SCHEMA • XML Schema is an XML-based alternative to 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 .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.

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 .

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

• 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 used to display data and focus on how data looks • Not much necessary • It is static • Not case-sensitive Page 14 .DIFFERENCE BETWEEN XML & HTML XML • Data is stored in separate XML files. • It is user defined language. • It is predefined language.

HOW CAN XML BE USED? Page 15 .

data can be stored in separate XML files. the data is stored inside your HTML with XML.XML SEPARATES DATA FROM HTML When HTML is used to display data. Page 16 .

Since XML data is stored in plain text form at. XML provides a software and hardware independent way of sharing data.XML CAN BE USED TO SHARE DATA With XML. plaintext files can be used to share data. Page 17 .

WORING WITH ELEMENTS AND ATTRIBUTES Page 18 .

XML ELEMENTS • XML elements must have a closing tag. <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 . • The following example is legal in HTML.

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 .

some elements can be improperly nested. all elements must be properly nested. <b><i> This text is bold and italic </b></i> • In XML.ALL ELEMENTS MUST BE PROPERLY NESTED • In HTML. <b><i> This text is bold and italic </i></b> Page 21 .

THANK YOU…! Page 22 .