SlideShare a Scribd company logo
1 of 55
COMPUTER SCIENCE
TOPIC: XML
BY: Priyanka pradhan
Priyanka Pradhan
Introduction to XML
O XML is extensible markup language.
O XML case sensitive.
O XML was designed to store and transport
data.
O XML is often used for distributing data
over the Internet.
O XML documents form a tree structure.
Priyanka Pradhan
Introduction to XML
<?xml version=“1.0”?>
<student detail>
<name>rohit</name>
<branch>csit</branch>
</student detail>
ROOT
ELEMENT
CHILD
ELEMENT
Priyanka Pradhan
Contd…
Student detail
Name: rohit
Branch: csit
Root Element
Child Element
Priyanka Pradhan
Priyanka Pradhan
What is the DOM?
O The HTML DOM defines a standard way for
accessing and manipulating HTML documents. It
presents an HTML document as a tree-structure.
O The XML DOM defines a standard way for
accessing and manipulating XML documents. It
presents an XML document as a tree-structure.
Priyanka Pradhan
The XML DOM
O All XML elements can be accessed through the
XML DOM.
O A standard object model for XML
O A standard programming interface for XML
O Platform- and language-independent
O A W3C standard
O The XML DOM is a standard for how to get,
change, add, or delete XML elements.
Priyanka Pradhan
DTD
O It is Document type definition
O An XML document with correct syntax is
called well formed.
O An XML document validated against a DTD is
both well formed and valid.
Priyanka Pradhan
Node Parents, Children, and Siblings
O Parent nodes have children. Children on the same
level are called siblings (brothers or sisters).
O In a node tree, the top node is called the root
O Every node, except the root, has exactly one parent
node
O A node can have any number of children
O A leaf is a node with no children
O Siblings are nodes with the same parent
Priyanka Pradhan
PCDATA
O PCDATA - Parsed Character Data
O XML parsers normally parse all the text in an XML document.
O When an XML element is parsed, the text between the XML tags is also parsed:
<message>This text is also parsed</message>
O The parser does this because XML elements can contain other elements, as in this
example, where the <name> element contains two other elements (first and last):
<name><first>Bill</first><last>Gates</last></name>
O and the parser will break it up into sub-elements like this:
<name>
<first>Bill</first>
<last>Gates</last>
</name>
Priyanka Pradhan
CDATA - (Unparsed) Character Data
O The term CDATA is used about text data that should not be parsed
by the XML parser.
O Characters like "<" and "&" are illegal in XML elements.
O "<" will generate an error because the parser interprets it as the
start of a new element.
O "&" will generate an error because the parser interprets it as the
start of an character entity.
O Some text, like JavaScript code, contains a lot of "<" or "&"
characters. To avoid errors script code can be defined as CDATA.
O A CDATA section starts with "<![CDATA[" and ends with "]]>":
Priyanka Pradhan
What is XPath?
O XPath stands for XML Path Language
O XPath uses "path like" syntax to identify and
navigate nodes in an XML document
O XPath contains over 200 built-in functions
O XPath is a major element in the XSLT
standard
O XPath is a W3C recommendation
Priyanka Pradhan
XPath uses path expressions to select nodes or node-sets in an XML document.
Priyanka Pradhan
XSLT
OXSL (eXtensible Stylesheet Language)
is a styling language for XML.
OXSLT stands for XSL Transformations.
OXSLT is used to transform XML
documents into other formats (like
transforming XML into HTML).
Priyanka Pradhan
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html> <body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr> </xsl:for-each>
</table> </body> </html></xsl:template></xsl:stylesheet>
Priyanka Pradhan
XSL(T) Languages
O XSLT is a language for transforming XML
documents.
O XPath is a language for navigating in XML
documents.
O XQuery is a language for querying XML
documents.
Priyanka Pradhan
What is a DTD?
O A DTD is a Document Type Definition.
O A DTD defines the structure and the legal
elements and attributes of an XML document.
O An application can use a DTD to verify that
XML data is valid.
Priyanka Pradhan
O If the DTD is declared inside the XML file, it
must be wrapped inside the <!DOCTYPE>
definition.
Priyanka Pradhan
O <?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>
Priyanka Pradhan
The DTD is interpreted like this:
O !DOCTYPE note defines that the root element of this document is
note
O !ELEMENT note defines that the note element must contain four
elements: "to,from,heading,body"
O !ELEMENT to defines the to element to be of type "#PCDATA"
O !ELEMENT from defines the from element to be of type
"#PCDATA"
O !ELEMENT heading defines the heading element to be of type
"#PCDATA"
O !ELEMENT body defines the body element to be of type
"#PCDATA"
Priyanka Pradhan
An External DTD Declaration
O XML document with a reference to an external DTD
O <?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>
Priyanka Pradhan
O And here is the file "note.dtd", which contains
the DTD:
O <!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
Priyanka Pradhan
DTD - XML Building Blocks
O Elements
O Attributes
O Entities
O PCDATA
O CDATA
Priyanka Pradhan
Elements
O Elements are the main building blocks of
both XML and HTML documents.
O <body>some text</body>
<message>some text</message>
Priyanka Pradhan
Attributes
O Attributes provide extra information about
elements.
O <img src="computer.gif" />
Priyanka Pradhan
Entities
Entity References Character
&lt; <
&gt; >
&amp; &
&quot; "
&apos; '
Priyanka Pradhan
DTD - Elements
<!ELEMENT element-name category>
or
<!ELEMENT element-name (element-content)>
Priyanka Pradhan
Empty Elements:
O <!ELEMENT element-name EMPTY>
Example:
<!ELEMENT br EMPTY>
XML example:
<br />
Priyanka Pradhan
Elements with Parsed Character
Data
O <!ELEMENT element-name (#PCDATA)>
Example:
<!ELEMENT from (#PCDATA)>
Priyanka Pradhan
Elements with any Contents
O <!ELEMENT element-name ANY>
Example:
<!ELEMENT note ANY>
Priyanka Pradhan
Elements with Children
(sequences)
O <!ELEMENT element-name (child1)>
or
<!ELEMENT element-name (child1,child2,...)>
Example:
<!ELEMENT note (to,from,heading,body)>
Priyanka Pradhan
Declaring Only One Occurrence
of an Element
O <!ELEMENT element-name (child-name)>
Example:
<!ELEMENT note (message)>
Priyanka Pradhan
Declaring Minimum One
Occurrence of an Element
O <!ELEMENT element-name (child-name+)>
Example:
<!ELEMENT note (message+)>
Priyanka Pradhan
Declaring Zero or More
Occurrences of an Element
O <!ELEMENT element-name (child-name*)>
Example:
<!ELEMENT note (message*)>
Priyanka Pradhan
Declaring Zero or One
Occurrences of an Element
O <!ELEMENT element-name (child-name?)>
Example:
<!ELEMENT note (message?)>
Priyanka Pradhan
Declaring either/or Content
O <!ELEMENT note
(to,from,header,(message|body))>
Priyanka Pradhan
Declaring Mixed Content
O <!ELEMENT note
(#PCDATA|to|from|header|message)*>
Priyanka Pradhan
Declaring Attributes
O <!ATTLIST element-name attribute-name attribute-type
attribute-value>
DTD example:
<!ATTLIST payment type CDATA "check">
XML example:
<payment type="check" />
Priyanka Pradhan
A Default Attribute Value
O DTD:
<!ELEMENT square EMPTY>
<!ATTLIST square width CDATA "0">
Valid XML:
<square width="100" />
Priyanka Pradhan
#REQUIRED
O <!ATTLIST element-name attribute-name attribute-type
#REQUIRED>
O DTD:
<!ATTLIST person number CDATA #REQUIRED>
Valid XML:
<person number="5677" />
Invalid XML:
<person />
Priyanka Pradhan
#IMPLIED
O <!ATTLIST element-name attribute-name attribute-type
#IMPLIED>
DTD:
<!ATTLIST contact fax CDATA #IMPLIED>
Valid XML:
<contact fax="555-667788" />
Valid XML:
<contact />
Priyanka Pradhan
#FIXED
O <!ATTLIST element-name attribute-name attribute-type
#FIXED "value">
O DTD:
<!ATTLIST sender company CDATA #FIXED
"Microsoft">
Valid XML:
<sender company="Microsoft" />
Invalid XML:
<sender company="W3Schools" />
Priyanka Pradhan
Enumerated Attribute Values
O <!ATTLIST element-name attribute-name
(en1|en2|..) default-value>
O DTD:
<!ATTLIST payment type (check|cash) "cash">
XML example:
<payment type="check" />
or
<payment type="cash" />
Priyanka Pradhan
DTD - Entities
O Entities are used to define shortcuts to special
characters.
O Entities can be declared internal or external.
Priyanka Pradhan
An Internal Entity Declaration
O <!ENTITY entity-name "entity-value">
O DTD Example:
<!ENTITY writer "Donald Duck.">
<!ENTITY copyright "Copyright W3Schools.">
XML example:
<author>&writer;&copyright;</author>
Priyanka Pradhan
An External Entity Declaration
O <!ENTITY entity-name SYSTEM "URI/URL">
O DTD Example:
<!ENTITY writer SYSTEM
"https://www.w3schools.com/entities.dtd">
<!ENTITY copyright SYSTEM
"https://www.w3schools.com/entities.dtd">
XML example:
<author>&writer;&copyright;</author>
Priyanka Pradhan
What is an XML Schema?
O An XML Schema describes the structure of an
XML document.
O The XML Schema language is also referred to
as XML Schema Definition (XSD).
Priyanka Pradhan
XSD
O <?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Priyanka Pradhan
O The purpose of an XML Schema is to define
the legal building blocks of an XML
document:
O the elements and attributes that can appear in a
document
O the number of (and order of) child elements
O data types for elements and attributes
O default and fixed values for elements and
attributes
Priyanka Pradhan
well-formed XML document
O it must begin with the XML declaration
O it must have one unique root element
O start-tags must have matching end-tags
O elements are case sensitive
O all elements must be closed
O all elements must be properly nested
O all attribute values must be quoted
O entities must be used for special characters
Priyanka Pradhan
A Simple XML Document
O <?xml version="1.0"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Priyanka Pradhan
A DTD File
O <!ELEMENT note (to, from, heading, body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
Priyanka Pradhan
An XML SchemaO <?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSche
ma"
targetNamespace="https://www.w3schools.com"
xmlns="https://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="note"> <xs:complexType>
<xs:sequence><xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence></xs:complexType></xs:element>xs:schema>
Priyanka Pradhan
A Reference to a DTD
O <?xml version="1.0"?>
<!DOCTYPE note SYSTEM
"https://www.w3schools.com/xml/note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Priyanka Pradhan
A Reference to an XML Schema
O <?xml version="1.0"?>
<note
xmlns="https://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.w3schools.com/xml/note.xsd"
>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Priyanka Pradhan

More Related Content

What's hot (20)

HTML/CSS/java Script/Jquery
HTML/CSS/java Script/JqueryHTML/CSS/java Script/Jquery
HTML/CSS/java Script/Jquery
 
Regular expression unit2
Regular expression unit2Regular expression unit2
Regular expression unit2
 
Intr To Html & Xhtml
Intr To Html & XhtmlIntr To Html & Xhtml
Intr To Html & Xhtml
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery Fundamentals
 
Html 5 tags
Html  5 tagsHtml  5 tags
Html 5 tags
 
Html tag list
Html tag listHtml tag list
Html tag list
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Hyper Text Mark-up Language
Hyper Text Mark-up Language Hyper Text Mark-up Language
Hyper Text Mark-up Language
 
IPW HTML course
IPW HTML courseIPW HTML course
IPW HTML course
 
Web Design Assignment 1
Web Design Assignment 1 Web Design Assignment 1
Web Design Assignment 1
 
Advanced Cascading Style Sheets
Advanced Cascading Style SheetsAdvanced Cascading Style Sheets
Advanced Cascading Style Sheets
 
Xml
XmlXml
Xml
 
Introduction to Cascading Style Sheets
Introduction to Cascading Style SheetsIntroduction to Cascading Style Sheets
Introduction to Cascading Style Sheets
 
Design Tools Html Xhtml
Design Tools Html XhtmlDesign Tools Html Xhtml
Design Tools Html Xhtml
 
Basic Html Knowledge for students
Basic Html Knowledge for studentsBasic Html Knowledge for students
Basic Html Knowledge for students
 
Intro to Javascript and jQuery
Intro to Javascript and jQueryIntro to Javascript and jQuery
Intro to Javascript and jQuery
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
 
Html training slide
Html training slideHtml training slide
Html training slide
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 
Php Simple Xml
Php Simple XmlPhp Simple Xml
Php Simple Xml
 

Similar to XML (20)

Dtd
DtdDtd
Dtd
 
2-DTD.ppt
2-DTD.ppt2-DTD.ppt
2-DTD.ppt
 
Xml2
Xml2Xml2
Xml2
 
distributed system concerned lab sessions
distributed system concerned lab sessionsdistributed system concerned lab sessions
distributed system concerned lab sessions
 
Xml2
Xml2Xml2
Xml2
 
It8074 soa-unit i
It8074 soa-unit iIt8074 soa-unit i
It8074 soa-unit i
 
it8074-soa-uniti-.pdf
it8074-soa-uniti-.pdfit8074-soa-uniti-.pdf
it8074-soa-uniti-.pdf
 
Unit iv xml
Unit iv xmlUnit iv xml
Unit iv xml
 
uptu web technology unit 2 Xml2
uptu web technology unit 2 Xml2uptu web technology unit 2 Xml2
uptu web technology unit 2 Xml2
 
Unit 5 xml (1)
Unit 5   xml (1)Unit 5   xml (1)
Unit 5 xml (1)
 
Xml
XmlXml
Xml
 
Xml
XmlXml
Xml
 
It8074 soa-unit i
It8074 soa-unit iIt8074 soa-unit i
It8074 soa-unit i
 
Xml
XmlXml
Xml
 
Xml11
Xml11Xml11
Xml11
 
Xml Presentation-1
Xml Presentation-1Xml Presentation-1
Xml Presentation-1
 
Web Technologies Unit 2 Print.pdf
Web Technologies Unit 2 Print.pdfWeb Technologies Unit 2 Print.pdf
Web Technologies Unit 2 Print.pdf
 
Xml
XmlXml
Xml
 
Xml
XmlXml
Xml
 
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
 

More from Priyanka Pradhan

Tomato disease detection using deep learning convolutional neural network
Tomato disease detection using deep learning convolutional neural networkTomato disease detection using deep learning convolutional neural network
Tomato disease detection using deep learning convolutional neural networkPriyanka Pradhan
 
programming with python ppt
programming with python pptprogramming with python ppt
programming with python pptPriyanka Pradhan
 
Image Processing Based Signature Recognition and Verification Technique Using...
Image Processing Based Signature Recognition and Verification Technique Using...Image Processing Based Signature Recognition and Verification Technique Using...
Image Processing Based Signature Recognition and Verification Technique Using...Priyanka Pradhan
 
GrayBox Testing and Crud Testing By: Er. Priyanka Pradhan
GrayBox Testing and Crud Testing By: Er. Priyanka PradhanGrayBox Testing and Crud Testing By: Er. Priyanka Pradhan
GrayBox Testing and Crud Testing By: Er. Priyanka PradhanPriyanka Pradhan
 
The agile requirements refinery(SRUM) by: Priyanka Pradhan
The agile requirements refinery(SRUM) by: Priyanka PradhanThe agile requirements refinery(SRUM) by: Priyanka Pradhan
The agile requirements refinery(SRUM) by: Priyanka PradhanPriyanka Pradhan
 
Social tagging and its trend
Social tagging and its trendSocial tagging and its trend
Social tagging and its trendPriyanka Pradhan
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanPriyanka Pradhan
 
software product and its characteristics
software product and its characteristicssoftware product and its characteristics
software product and its characteristicsPriyanka Pradhan
 
EDI(ELECTRONIC DATA INTERCHANGE)
EDI(ELECTRONIC DATA INTERCHANGE)EDI(ELECTRONIC DATA INTERCHANGE)
EDI(ELECTRONIC DATA INTERCHANGE)Priyanka Pradhan
 
collaborative tagging :-by Er. Priyanka Pradhan
collaborative tagging :-by Er. Priyanka Pradhancollaborative tagging :-by Er. Priyanka Pradhan
collaborative tagging :-by Er. Priyanka PradhanPriyanka Pradhan
 
Deploying java beans in jsp
Deploying java beans in jspDeploying java beans in jsp
Deploying java beans in jspPriyanka Pradhan
 
SOFTWARE PROCESS MONITORING AND AUDIT
SOFTWARE PROCESS MONITORING AND AUDITSOFTWARE PROCESS MONITORING AND AUDIT
SOFTWARE PROCESS MONITORING AND AUDITPriyanka Pradhan
 
s/w metrics monitoring and control
s/w metrics monitoring and controls/w metrics monitoring and control
s/w metrics monitoring and controlPriyanka Pradhan
 

More from Priyanka Pradhan (17)

Tomato disease detection using deep learning convolutional neural network
Tomato disease detection using deep learning convolutional neural networkTomato disease detection using deep learning convolutional neural network
Tomato disease detection using deep learning convolutional neural network
 
Applet
AppletApplet
Applet
 
Servlet
ServletServlet
Servlet
 
programming with python ppt
programming with python pptprogramming with python ppt
programming with python ppt
 
Core Java
Core JavaCore Java
Core Java
 
Image Processing Based Signature Recognition and Verification Technique Using...
Image Processing Based Signature Recognition and Verification Technique Using...Image Processing Based Signature Recognition and Verification Technique Using...
Image Processing Based Signature Recognition and Verification Technique Using...
 
GrayBox Testing and Crud Testing By: Er. Priyanka Pradhan
GrayBox Testing and Crud Testing By: Er. Priyanka PradhanGrayBox Testing and Crud Testing By: Er. Priyanka Pradhan
GrayBox Testing and Crud Testing By: Er. Priyanka Pradhan
 
The agile requirements refinery(SRUM) by: Priyanka Pradhan
The agile requirements refinery(SRUM) by: Priyanka PradhanThe agile requirements refinery(SRUM) by: Priyanka Pradhan
The agile requirements refinery(SRUM) by: Priyanka Pradhan
 
Social tagging and its trend
Social tagging and its trendSocial tagging and its trend
Social tagging and its trend
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka Pradhan
 
software product and its characteristics
software product and its characteristicssoftware product and its characteristics
software product and its characteristics
 
EDI(ELECTRONIC DATA INTERCHANGE)
EDI(ELECTRONIC DATA INTERCHANGE)EDI(ELECTRONIC DATA INTERCHANGE)
EDI(ELECTRONIC DATA INTERCHANGE)
 
collaborative tagging :-by Er. Priyanka Pradhan
collaborative tagging :-by Er. Priyanka Pradhancollaborative tagging :-by Er. Priyanka Pradhan
collaborative tagging :-by Er. Priyanka Pradhan
 
Deploying java beans in jsp
Deploying java beans in jspDeploying java beans in jsp
Deploying java beans in jsp
 
SOFTWARE PROCESS MONITORING AND AUDIT
SOFTWARE PROCESS MONITORING AND AUDITSOFTWARE PROCESS MONITORING AND AUDIT
SOFTWARE PROCESS MONITORING AND AUDIT
 
Pcmm
PcmmPcmm
Pcmm
 
s/w metrics monitoring and control
s/w metrics monitoring and controls/w metrics monitoring and control
s/w metrics monitoring and control
 

Recently uploaded

Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 

Recently uploaded (20)

Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 

XML

  • 1. COMPUTER SCIENCE TOPIC: XML BY: Priyanka pradhan Priyanka Pradhan
  • 2. Introduction to XML O XML is extensible markup language. O XML case sensitive. O XML was designed to store and transport data. O XML is often used for distributing data over the Internet. O XML documents form a tree structure. Priyanka Pradhan
  • 3. Introduction to XML <?xml version=“1.0”?> <student detail> <name>rohit</name> <branch>csit</branch> </student detail> ROOT ELEMENT CHILD ELEMENT Priyanka Pradhan
  • 4. Contd… Student detail Name: rohit Branch: csit Root Element Child Element Priyanka Pradhan
  • 6. What is the DOM? O The HTML DOM defines a standard way for accessing and manipulating HTML documents. It presents an HTML document as a tree-structure. O The XML DOM defines a standard way for accessing and manipulating XML documents. It presents an XML document as a tree-structure. Priyanka Pradhan
  • 7. The XML DOM O All XML elements can be accessed through the XML DOM. O A standard object model for XML O A standard programming interface for XML O Platform- and language-independent O A W3C standard O The XML DOM is a standard for how to get, change, add, or delete XML elements. Priyanka Pradhan
  • 8. DTD O It is Document type definition O An XML document with correct syntax is called well formed. O An XML document validated against a DTD is both well formed and valid. Priyanka Pradhan
  • 9. Node Parents, Children, and Siblings O Parent nodes have children. Children on the same level are called siblings (brothers or sisters). O In a node tree, the top node is called the root O Every node, except the root, has exactly one parent node O A node can have any number of children O A leaf is a node with no children O Siblings are nodes with the same parent Priyanka Pradhan
  • 10. PCDATA O PCDATA - Parsed Character Data O XML parsers normally parse all the text in an XML document. O When an XML element is parsed, the text between the XML tags is also parsed: <message>This text is also parsed</message> O The parser does this because XML elements can contain other elements, as in this example, where the <name> element contains two other elements (first and last): <name><first>Bill</first><last>Gates</last></name> O and the parser will break it up into sub-elements like this: <name> <first>Bill</first> <last>Gates</last> </name> Priyanka Pradhan
  • 11. CDATA - (Unparsed) Character Data O The term CDATA is used about text data that should not be parsed by the XML parser. O Characters like "<" and "&" are illegal in XML elements. O "<" will generate an error because the parser interprets it as the start of a new element. O "&" will generate an error because the parser interprets it as the start of an character entity. O Some text, like JavaScript code, contains a lot of "<" or "&" characters. To avoid errors script code can be defined as CDATA. O A CDATA section starts with "<![CDATA[" and ends with "]]>": Priyanka Pradhan
  • 12. What is XPath? O XPath stands for XML Path Language O XPath uses "path like" syntax to identify and navigate nodes in an XML document O XPath contains over 200 built-in functions O XPath is a major element in the XSLT standard O XPath is a W3C recommendation Priyanka Pradhan
  • 13. XPath uses path expressions to select nodes or node-sets in an XML document. Priyanka Pradhan
  • 14. XSLT OXSL (eXtensible Stylesheet Language) is a styling language for XML. OXSLT stands for XSL Transformations. OXSLT is used to transform XML documents into other formats (like transforming XML into HTML). Priyanka Pradhan
  • 15. <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Title</th> <th>Artist</th> </tr> <xsl:for-each select="catalog/cd"> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="artist"/></td> </tr> </xsl:for-each> </table> </body> </html></xsl:template></xsl:stylesheet> Priyanka Pradhan
  • 16. XSL(T) Languages O XSLT is a language for transforming XML documents. O XPath is a language for navigating in XML documents. O XQuery is a language for querying XML documents. Priyanka Pradhan
  • 17. What is a DTD? O A DTD is a Document Type Definition. O A DTD defines the structure and the legal elements and attributes of an XML document. O An application can use a DTD to verify that XML data is valid. Priyanka Pradhan
  • 18. O If the DTD is declared inside the XML file, it must be wrapped inside the <!DOCTYPE> definition. Priyanka Pradhan
  • 19. O <?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> Priyanka Pradhan
  • 20. The DTD is interpreted like this: O !DOCTYPE note defines that the root element of this document is note O !ELEMENT note defines that the note element must contain four elements: "to,from,heading,body" O !ELEMENT to defines the to element to be of type "#PCDATA" O !ELEMENT from defines the from element to be of type "#PCDATA" O !ELEMENT heading defines the heading element to be of type "#PCDATA" O !ELEMENT body defines the body element to be of type "#PCDATA" Priyanka Pradhan
  • 21. An External DTD Declaration O XML document with a reference to an external DTD O <?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> Priyanka Pradhan
  • 22. O And here is the file "note.dtd", which contains the DTD: O <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> Priyanka Pradhan
  • 23. DTD - XML Building Blocks O Elements O Attributes O Entities O PCDATA O CDATA Priyanka Pradhan
  • 24. Elements O Elements are the main building blocks of both XML and HTML documents. O <body>some text</body> <message>some text</message> Priyanka Pradhan
  • 25. Attributes O Attributes provide extra information about elements. O <img src="computer.gif" /> Priyanka Pradhan
  • 26. Entities Entity References Character &lt; < &gt; > &amp; & &quot; " &apos; ' Priyanka Pradhan
  • 27. DTD - Elements <!ELEMENT element-name category> or <!ELEMENT element-name (element-content)> Priyanka Pradhan
  • 28. Empty Elements: O <!ELEMENT element-name EMPTY> Example: <!ELEMENT br EMPTY> XML example: <br /> Priyanka Pradhan
  • 29. Elements with Parsed Character Data O <!ELEMENT element-name (#PCDATA)> Example: <!ELEMENT from (#PCDATA)> Priyanka Pradhan
  • 30. Elements with any Contents O <!ELEMENT element-name ANY> Example: <!ELEMENT note ANY> Priyanka Pradhan
  • 31. Elements with Children (sequences) O <!ELEMENT element-name (child1)> or <!ELEMENT element-name (child1,child2,...)> Example: <!ELEMENT note (to,from,heading,body)> Priyanka Pradhan
  • 32. Declaring Only One Occurrence of an Element O <!ELEMENT element-name (child-name)> Example: <!ELEMENT note (message)> Priyanka Pradhan
  • 33. Declaring Minimum One Occurrence of an Element O <!ELEMENT element-name (child-name+)> Example: <!ELEMENT note (message+)> Priyanka Pradhan
  • 34. Declaring Zero or More Occurrences of an Element O <!ELEMENT element-name (child-name*)> Example: <!ELEMENT note (message*)> Priyanka Pradhan
  • 35. Declaring Zero or One Occurrences of an Element O <!ELEMENT element-name (child-name?)> Example: <!ELEMENT note (message?)> Priyanka Pradhan
  • 36. Declaring either/or Content O <!ELEMENT note (to,from,header,(message|body))> Priyanka Pradhan
  • 37. Declaring Mixed Content O <!ELEMENT note (#PCDATA|to|from|header|message)*> Priyanka Pradhan
  • 38. Declaring Attributes O <!ATTLIST element-name attribute-name attribute-type attribute-value> DTD example: <!ATTLIST payment type CDATA "check"> XML example: <payment type="check" /> Priyanka Pradhan
  • 39. A Default Attribute Value O DTD: <!ELEMENT square EMPTY> <!ATTLIST square width CDATA "0"> Valid XML: <square width="100" /> Priyanka Pradhan
  • 40. #REQUIRED O <!ATTLIST element-name attribute-name attribute-type #REQUIRED> O DTD: <!ATTLIST person number CDATA #REQUIRED> Valid XML: <person number="5677" /> Invalid XML: <person /> Priyanka Pradhan
  • 41. #IMPLIED O <!ATTLIST element-name attribute-name attribute-type #IMPLIED> DTD: <!ATTLIST contact fax CDATA #IMPLIED> Valid XML: <contact fax="555-667788" /> Valid XML: <contact /> Priyanka Pradhan
  • 42. #FIXED O <!ATTLIST element-name attribute-name attribute-type #FIXED "value"> O DTD: <!ATTLIST sender company CDATA #FIXED "Microsoft"> Valid XML: <sender company="Microsoft" /> Invalid XML: <sender company="W3Schools" /> Priyanka Pradhan
  • 43. Enumerated Attribute Values O <!ATTLIST element-name attribute-name (en1|en2|..) default-value> O DTD: <!ATTLIST payment type (check|cash) "cash"> XML example: <payment type="check" /> or <payment type="cash" /> Priyanka Pradhan
  • 44. DTD - Entities O Entities are used to define shortcuts to special characters. O Entities can be declared internal or external. Priyanka Pradhan
  • 45. An Internal Entity Declaration O <!ENTITY entity-name "entity-value"> O DTD Example: <!ENTITY writer "Donald Duck."> <!ENTITY copyright "Copyright W3Schools."> XML example: <author>&writer;&copyright;</author> Priyanka Pradhan
  • 46. An External Entity Declaration O <!ENTITY entity-name SYSTEM "URI/URL"> O DTD Example: <!ENTITY writer SYSTEM "https://www.w3schools.com/entities.dtd"> <!ENTITY copyright SYSTEM "https://www.w3schools.com/entities.dtd"> XML example: <author>&writer;&copyright;</author> Priyanka Pradhan
  • 47. What is an XML Schema? O An XML Schema describes the structure of an XML document. O The XML Schema language is also referred to as XML Schema Definition (XSD). Priyanka Pradhan
  • 48. XSD O <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="note"> <xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:string"/> <xs:element name="body" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> Priyanka Pradhan
  • 49. O The purpose of an XML Schema is to define the legal building blocks of an XML document: O the elements and attributes that can appear in a document O the number of (and order of) child elements O data types for elements and attributes O default and fixed values for elements and attributes Priyanka Pradhan
  • 50. well-formed XML document O it must begin with the XML declaration O it must have one unique root element O start-tags must have matching end-tags O elements are case sensitive O all elements must be closed O all elements must be properly nested O all attribute values must be quoted O entities must be used for special characters Priyanka Pradhan
  • 51. A Simple XML Document O <?xml version="1.0"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> Priyanka Pradhan
  • 52. A DTD File O <!ELEMENT note (to, from, heading, body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> Priyanka Pradhan
  • 53. An XML SchemaO <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSche ma" targetNamespace="https://www.w3schools.com" xmlns="https://www.w3schools.com" elementFormDefault="qualified"> <xs:element name="note"> <xs:complexType> <xs:sequence><xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:string"/> <xs:element name="body" type="xs:string"/> </xs:sequence></xs:complexType></xs:element>xs:schema> Priyanka Pradhan
  • 54. A Reference to a DTD O <?xml version="1.0"?> <!DOCTYPE note SYSTEM "https://www.w3schools.com/xml/note.dtd"> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> Priyanka Pradhan
  • 55. A Reference to an XML Schema O <?xml version="1.0"?> <note xmlns="https://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.w3schools.com/xml/note.xsd" > <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> Priyanka Pradhan