SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler offline
Integrative Programming andTechnology
08/12/2015 1Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
How does an XML processor check your xml document?
There are two main checks that XML processors make:
1. Checking that your document is well-formed ( Syntax rule)
2. Checking that it's valid (syntax-check your XML either in XML DTD or
XSD)
DTD- DocumentType Definition
XSD-XMLSchema Definition
Why need XMLValidator
 Use our XML validator to syntax-check your XML.
 Errors in XML documents will stop your XML applications unlike HTML
browser
08/12/2015 2Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
 An XML document with correct syntax is called "Well Formed".
 An XML document validated against a DTD is "Well Formed" and "Valid".
 The purpose of a DTD is to define the structure of an XML document and
a list of legal elements.
How you add a DTD to our XML document
1. DTDs can be separate documents (or )
2. They can be built into an XML document
using a special element named <!DOCTYPE>.
08/12/2015 3Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
An XML Document with a DTD (example4.xml)
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="css1.css"?>
<!DOCTYPE document
[ <!ELEMENT document (heading, message)> <!ELEMENT
heading (#PCDATA)> <!ELEMENT message (#PCDATA)>
]>
<document>
<heading> Hello From XML </heading> <message>This is an
XML document! </message>
</document>
08/12/2015 4Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
Valid XML Document with DTD (example.5.xml)
 The DOCTYPE declaration is a reference to an external DTD file "Note.dtd“
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE note SYSTEM "Note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
 Note.dtd
<!DOCTYPE note
[
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
08/12/2015 5Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
The DTD above is interpreted like this:
 !DOCTYPE note defines that the root element of the document is note
 !ELEMENT note defines that the note element contains four elements:
"to, from, heading, body"
 !ELEMENT to defines the to element to be of type "#PCDATA"
 !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“
Note
#PCDATA means parse-able text data.
When NOT to Use a Document Definition?
 When you are working with small XML files, creating document definitions
may be a waste of time.
08/12/2015 6Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
 Another way of validatingXML documents: using XML schemas.
 The XML Schema language is also referred to as XML Schema Definition
(XSD), describes the structure of an XML document.
 defines the legal building blocks (elements and attributes) of an XML
document like DTD.
 defines which elements are child elements
 defines the number and order 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
08/12/2015 7Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
XML Schemas will be used in most Web applications as a replacement for
DTDs.
Here are some reasons:
 XML Schemas are extensible to future additions
 XML Schemas are richer and more powerful than DTDs
 XML Schemas are written in XML
 XML Schemas support data types and namespaces
Creating XML Schemas by Using XML Schema-CreationTools
 HiT Software
 xmlArchitect
 XMLspy
 XML Ray
 MicrosoftVisual Studio .NET
08/12/2015 8Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
XSD Simple Element
 The syntax for defining a simple element
 Default and FixedValues for Simple Elements
XSD Attributes
 The syntax for defining an attribute
 Default and FixedValues for Attributes
 Optional and Required Attributes
XSD Complex Elements
 How to Define a Complex Element using XML Scheme
 XSD Empty Elements
XSD Indicators
Order indicators are:
 All
 Choice
 Sequence
08/12/2015 9Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
XSD Simple Element
 A simple element is an XML element that can contain only text.
 It cannot contain any other elements or attributes.
 XML Schema has a lot of built-in data types.The most common types are:
1. xs:string
2. xs:decimal
3. xs:integer
4. xs:boolean
5. xs:date
6. xs:time
The syntax for defining a simple element is:
<xs:element name="xxx" type="yyy"/>
Example
<lastname>Refsnes</lastname>
<age>36</age>
<dateborn>1970-03-27</dateborn>
<xs:element name="lastname" type="xs:string"/>
<xs:element name="age" type="xs:integer"/>
<xs:element name="dateborn" type="xs:date"/>
08/12/2015 10Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
Default and FixedValues for Simple Elements
Simple elements may have a default value or a fixed value specified.
1. A default value is automatically assigned to the element when no
other value is specified.
<xs:element name="color" type="xs:string" default="red"/>
2. A fixed value is also automatically assigned to the element, and
you cannot specify another value.
<xs:element name="color" type="xs:string" fixed="red"/>
08/12/2015 11Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
XSD Attributes
 Simple elements cannot have attributes.
 If an element has attributes, it is considered to be of a complex type. But the
attribute itself is always declared as a simple type.
The syntax for defining an attribute is:
<xs : attribute name="xxx" type="yyy"/>
Example
<lastname lang="EN">Smith</lastname>
<xs:attribute name="lang" type="xs:string"/>
Default and FixedValues for Attributes
Attributes may have a default value or a fixed value specified.
<xs:attribute name="lang" type="xs:string" default="EN"/>
<xs:attribute name="lang" type="xs:string" fixed="EN"/>
Optional and Required Attributes
Attributes are optional by default.To specify that the attribute is required, use
the "use" attribute:
<xs:attribute name="lang" type="xs:string" use="required"/>
08/12/2015 12Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
XSD Complex Elements
 A complex element is an XML element that contains other elements and/or attributes.
 There are four kinds of complex elements:
Example:
1. A complex XML element, "product", which is empty:
<product pid="1345"/>
2. A complex XML element, "employee", which contains only other elements:
<employee>
<firstname>John</firstname>
<lastname>Smith</lastname>
</employee>
3. A complex XML element, "food", which contains only text:
<food type="dessert">Ice cream</food>
4. A complex XML element, "description", which contains both elements and text:
<description>
It happened on <date lang=“EN">03.03.99</date>
</description>
08/12/2015 13Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
How to Define a Complex Element using XML Scheme
 Complex XML element, "employee", which contains only other elements:
<employee>
<firstname>John</firstname>
<lastname>Smith</lastname>
</employee>
 The "employee" element can be declared directly by naming the element:
<xs:element name="employee">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
 An empty complex element cannot have contents, only attributes.
<product prodid="1345" />
 It is possible to declare the "product" element more compactly:
<xs:element name="product">
<xs:complexType>
<xs:attribute name="prodid" type="xs:positiveInteger"/>
</xs:complexType>
</xs:element>
08/12/2015 14Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
 XSD Indicators
 How elements are to be used in documents with indicators.
 Order indicators are used to define the order of the elements.They are:
1. All
2. Choice
3. Sequence
All Indicator:
 The <all> indicator specifies that the child elements can appear in any order, and that each child
element must occur only once:
<xs:element name="person">
<xs:complexType>
<xs:all>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:all>
</xs:complexType>
</xs:element>
08/12/2015 15Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
Choice Indicator:
 The <choice> indicator specifies that either one child element or another can occur:
<xs:element name="person">
<xs:complexType>
<xs:choice>
<xs:element name="employee" type="employee"/>
<xs:element name="member" type="member"/>
</xs:choice>
</xs:complexType>
</xs:element>
Sequence Indicator:
 The <sequence> indicator specifies that the child elements mustappear in a specific order:
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
08/12/2015 16Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
XML Example (“note.xml”)
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XSD Example (“note.xsd”)
<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>
08/12/2015 17Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
Example (shiporder.xml):
<?xml version="1.0" encoding="ISO-8859-1"?>
<shiporder orderid="889923">
<orderperson>John Smith</orderperson>
<shipto>
<name>Ola Nordmann</name>
<address>Langgt 23</address>
<city>4000 Stavanger</city>
<country>Norway</country>
</shipto>
</shiporder>
08/12/2015 18Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
Example "shiporder.xsd":
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="shiporder">
<xs:complexType>
<xs:sequence>
<xs:element name="orderperson" type="xs:string"/>
<xs:element name="shipto">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="orderid" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>
08/12/2015 19Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
 All modern browsers have a built-in XML parser.
 An XML parser converts an XML document into an XML DOM object -
which can then be manipulated with JavaScript.
Parse an XML Document
 The following code fragment parses an XML document into an XML DOM
object:
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","books.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
08/12/2015 20Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
XML DOM
 The XML DOM defines a standard way for accessing and manipulating
XML documents.
 The XML DOM views an XML document as a tree-structure.
 All elements can be accessed through the DOM tree.
 Their content (text and attributes) can be modified or deleted, and
new elements can be created.
 The elements, their text, and their attributes are all known as nodes.
The HTML DOM
 The HTML DOM defines a standard way for accessing and manipulating
HTML documents.
 All HTML elements can be accessed through the HTML DOM.
08/12/2015 21Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
Load an XML File - Cross-browser
 parses an XML document ("note.xml") into an XML DOM object and then extracts some information from it with a JavaScript:
Example
<html>
<body>
<span id="to"></span>
<span id="from"></span>
<span id="message"></span>
<script>
if (window.XMLHttpRequest)
{ // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{ // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","note.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.getElementById("to").innerHTML= xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
document.getElementById("from").innerHTML= xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
document.getElementById("message").innerHTML= xmlDoc.getElementsByTagName("message")[0].childNodes[0].nodeValue;
</script>
</body>
</html>
08/12/2015 22Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Dtd
DtdDtd
Dtd
 
Introduction to xml
Introduction to xmlIntroduction to xml
Introduction to xml
 
Ict 302
Ict 302Ict 302
Ict 302
 
10. XML in DBMS
10. XML in DBMS10. XML in DBMS
10. XML in DBMS
 
XSLT
XSLTXSLT
XSLT
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
Object oriented database concepts
Object oriented database conceptsObject oriented database concepts
Object oriented database concepts
 
CS8651 Internet Programming - Basics of HTML, HTML5, CSS
CS8651   Internet Programming - Basics of HTML, HTML5, CSSCS8651   Internet Programming - Basics of HTML, HTML5, CSS
CS8651 Internet Programming - Basics of HTML, HTML5, CSS
 
Internetworking.49
Internetworking.49Internetworking.49
Internetworking.49
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
 
Sgml
SgmlSgml
Sgml
 
Sequence diagram
Sequence diagramSequence diagram
Sequence diagram
 
Xml parsers
Xml parsersXml parsers
Xml parsers
 
Architectural modeling chapter 5 of omd
Architectural modeling chapter 5 of omdArchitectural modeling chapter 5 of omd
Architectural modeling chapter 5 of omd
 
XML Introduction
XML IntroductionXML Introduction
XML Introduction
 
XML-Extensible Markup Language
XML-Extensible Markup Language XML-Extensible Markup Language
XML-Extensible Markup Language
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
 
Ooad
OoadOoad
Ooad
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
Directory Introduction
Directory IntroductionDirectory Introduction
Directory Introduction
 

Semelhante a IPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriya

Semelhante a IPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriya (20)

Xml schema
Xml schemaXml schema
Xml schema
 
Xml intro1
Xml intro1Xml intro1
Xml intro1
 
XML Schema.pdf
XML Schema.pdfXML Schema.pdf
XML Schema.pdf
 
Oracle soa xml faq
Oracle soa xml faqOracle soa xml faq
Oracle soa xml faq
 
Introduction to xml schema
Introduction to xml schemaIntroduction to xml schema
Introduction to xml schema
 
Xml Presentation-1
Xml Presentation-1Xml Presentation-1
Xml Presentation-1
 
Xml11
Xml11Xml11
Xml11
 
Xml
XmlXml
Xml
 
Xsd examples
Xsd examplesXsd examples
Xsd examples
 
XML notes.pptx
XML notes.pptxXML notes.pptx
XML notes.pptx
 
Web Technologies Unit 2 Print.pdf
Web Technologies Unit 2 Print.pdfWeb Technologies Unit 2 Print.pdf
Web Technologies Unit 2 Print.pdf
 
XML.ppt
XML.pptXML.ppt
XML.ppt
 
Xml viva questions
Xml viva questionsXml viva questions
Xml viva questions
 
Xml
XmlXml
Xml
 
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
M.FLORENCE DAYANA WEB DESIGN -Unit 5   XMLM.FLORENCE DAYANA WEB DESIGN -Unit 5   XML
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
 
Xml 1
Xml 1Xml 1
Xml 1
 
Xsd
XsdXsd
Xsd
 
Xsd
XsdXsd
Xsd
 
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
 
XML1.pptx
XML1.pptxXML1.pptx
XML1.pptx
 

Mais de VijiPriya Jeyamani

Dr. J. VijiPriya - Information and Communication Technology Chapter 8 The Int...
Dr. J. VijiPriya - Information and Communication Technology Chapter 8 The Int...Dr. J. VijiPriya - Information and Communication Technology Chapter 8 The Int...
Dr. J. VijiPriya - Information and Communication Technology Chapter 8 The Int...VijiPriya Jeyamani
 
Dr. J. VijiPriya - Information Communication and Technology Chapter 7 Data Co...
Dr. J. VijiPriya - Information Communication and Technology Chapter 7 Data Co...Dr. J. VijiPriya - Information Communication and Technology Chapter 7 Data Co...
Dr. J. VijiPriya - Information Communication and Technology Chapter 7 Data Co...VijiPriya Jeyamani
 
Dr. J. VijiPriya Information and Communication Technology Chapter 5,6
Dr. J. VijiPriya  Information and Communication Technology Chapter 5,6Dr. J. VijiPriya  Information and Communication Technology Chapter 5,6
Dr. J. VijiPriya Information and Communication Technology Chapter 5,6VijiPriya Jeyamani
 
Human Computer Interaction Chapter 2 Interaction and Interaction Design Basi...
Human Computer Interaction Chapter 2  Interaction and Interaction Design Basi...Human Computer Interaction Chapter 2  Interaction and Interaction Design Basi...
Human Computer Interaction Chapter 2 Interaction and Interaction Design Basi...VijiPriya Jeyamani
 
Human Computer Interaction Chapter 3 HCI in the Software Process and Design ...
Human Computer Interaction Chapter 3 HCI in the Software Process and  Design ...Human Computer Interaction Chapter 3 HCI in the Software Process and  Design ...
Human Computer Interaction Chapter 3 HCI in the Software Process and Design ...VijiPriya Jeyamani
 
Human Computer Interaction Chapter 4 Implementation Support and Evaluation Te...
Human Computer Interaction Chapter 4 Implementation Support and Evaluation Te...Human Computer Interaction Chapter 4 Implementation Support and Evaluation Te...
Human Computer Interaction Chapter 4 Implementation Support and Evaluation Te...VijiPriya Jeyamani
 
Human Computer Interaction Chapter 5 Universal Design and User Support - Dr....
Human Computer Interaction Chapter 5 Universal Design and User Support -  Dr....Human Computer Interaction Chapter 5 Universal Design and User Support -  Dr....
Human Computer Interaction Chapter 5 Universal Design and User Support - Dr....VijiPriya Jeyamani
 
Expert System Lecture Notes Chapter 1,2,3,4,5 - Dr.J.VijiPriya
 Expert System Lecture Notes Chapter 1,2,3,4,5 - Dr.J.VijiPriya Expert System Lecture Notes Chapter 1,2,3,4,5 - Dr.J.VijiPriya
Expert System Lecture Notes Chapter 1,2,3,4,5 - Dr.J.VijiPriyaVijiPriya Jeyamani
 
CLISP Lab Manual - Dr.J.VijiPriya
CLISP Lab Manual - Dr.J.VijiPriyaCLISP Lab Manual - Dr.J.VijiPriya
CLISP Lab Manual - Dr.J.VijiPriyaVijiPriya Jeyamani
 
Information and Communication Technology Chapter 1,2 ,3 - Dr.J.VijiPriya
Information and Communication Technology Chapter 1,2 ,3 - Dr.J.VijiPriyaInformation and Communication Technology Chapter 1,2 ,3 - Dr.J.VijiPriya
Information and Communication Technology Chapter 1,2 ,3 - Dr.J.VijiPriyaVijiPriya Jeyamani
 

Mais de VijiPriya Jeyamani (10)

Dr. J. VijiPriya - Information and Communication Technology Chapter 8 The Int...
Dr. J. VijiPriya - Information and Communication Technology Chapter 8 The Int...Dr. J. VijiPriya - Information and Communication Technology Chapter 8 The Int...
Dr. J. VijiPriya - Information and Communication Technology Chapter 8 The Int...
 
Dr. J. VijiPriya - Information Communication and Technology Chapter 7 Data Co...
Dr. J. VijiPriya - Information Communication and Technology Chapter 7 Data Co...Dr. J. VijiPriya - Information Communication and Technology Chapter 7 Data Co...
Dr. J. VijiPriya - Information Communication and Technology Chapter 7 Data Co...
 
Dr. J. VijiPriya Information and Communication Technology Chapter 5,6
Dr. J. VijiPriya  Information and Communication Technology Chapter 5,6Dr. J. VijiPriya  Information and Communication Technology Chapter 5,6
Dr. J. VijiPriya Information and Communication Technology Chapter 5,6
 
Human Computer Interaction Chapter 2 Interaction and Interaction Design Basi...
Human Computer Interaction Chapter 2  Interaction and Interaction Design Basi...Human Computer Interaction Chapter 2  Interaction and Interaction Design Basi...
Human Computer Interaction Chapter 2 Interaction and Interaction Design Basi...
 
Human Computer Interaction Chapter 3 HCI in the Software Process and Design ...
Human Computer Interaction Chapter 3 HCI in the Software Process and  Design ...Human Computer Interaction Chapter 3 HCI in the Software Process and  Design ...
Human Computer Interaction Chapter 3 HCI in the Software Process and Design ...
 
Human Computer Interaction Chapter 4 Implementation Support and Evaluation Te...
Human Computer Interaction Chapter 4 Implementation Support and Evaluation Te...Human Computer Interaction Chapter 4 Implementation Support and Evaluation Te...
Human Computer Interaction Chapter 4 Implementation Support and Evaluation Te...
 
Human Computer Interaction Chapter 5 Universal Design and User Support - Dr....
Human Computer Interaction Chapter 5 Universal Design and User Support -  Dr....Human Computer Interaction Chapter 5 Universal Design and User Support -  Dr....
Human Computer Interaction Chapter 5 Universal Design and User Support - Dr....
 
Expert System Lecture Notes Chapter 1,2,3,4,5 - Dr.J.VijiPriya
 Expert System Lecture Notes Chapter 1,2,3,4,5 - Dr.J.VijiPriya Expert System Lecture Notes Chapter 1,2,3,4,5 - Dr.J.VijiPriya
Expert System Lecture Notes Chapter 1,2,3,4,5 - Dr.J.VijiPriya
 
CLISP Lab Manual - Dr.J.VijiPriya
CLISP Lab Manual - Dr.J.VijiPriyaCLISP Lab Manual - Dr.J.VijiPriya
CLISP Lab Manual - Dr.J.VijiPriya
 
Information and Communication Technology Chapter 1,2 ,3 - Dr.J.VijiPriya
Information and Communication Technology Chapter 1,2 ,3 - Dr.J.VijiPriyaInformation and Communication Technology Chapter 1,2 ,3 - Dr.J.VijiPriya
Information and Communication Technology Chapter 1,2 ,3 - Dr.J.VijiPriya
 

Último

UNIT4_ESD_wfffffggggggggggggith_ARM.pptx
UNIT4_ESD_wfffffggggggggggggith_ARM.pptxUNIT4_ESD_wfffffggggggggggggith_ARM.pptx
UNIT4_ESD_wfffffggggggggggggith_ARM.pptxrealme6igamerr
 
Vertical- Machining - Center - VMC -LMW-Machine-Tool-Division.pptx
Vertical- Machining - Center - VMC -LMW-Machine-Tool-Division.pptxVertical- Machining - Center - VMC -LMW-Machine-Tool-Division.pptx
Vertical- Machining - Center - VMC -LMW-Machine-Tool-Division.pptxLMW Machine Tool Division
 
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Sean Meyn
 
cloud computing notes for anna university syllabus
cloud computing notes for anna university syllabuscloud computing notes for anna university syllabus
cloud computing notes for anna university syllabusViolet Violet
 
GENERAL CONDITIONS FOR CONTRACTS OF CIVIL ENGINEERING WORKS
GENERAL CONDITIONS  FOR  CONTRACTS OF CIVIL ENGINEERING WORKS GENERAL CONDITIONS  FOR  CONTRACTS OF CIVIL ENGINEERING WORKS
GENERAL CONDITIONS FOR CONTRACTS OF CIVIL ENGINEERING WORKS Bahzad5
 
Graphics Primitives and CG Display Devices
Graphics Primitives and CG Display DevicesGraphics Primitives and CG Display Devices
Graphics Primitives and CG Display DevicesDIPIKA83
 
How to Write a Good Scientific Paper.pdf
How to Write a Good Scientific Paper.pdfHow to Write a Good Scientific Paper.pdf
How to Write a Good Scientific Paper.pdfRedhwan Qasem Shaddad
 
Engineering Mechanics Chapter 5 Equilibrium of a Rigid Body
Engineering Mechanics  Chapter 5  Equilibrium of a Rigid BodyEngineering Mechanics  Chapter 5  Equilibrium of a Rigid Body
Engineering Mechanics Chapter 5 Equilibrium of a Rigid BodyAhmadHajasad2
 
Power System electrical and electronics .pptx
Power System electrical and electronics .pptxPower System electrical and electronics .pptx
Power System electrical and electronics .pptxMUKULKUMAR210
 
IT3401-WEB ESSENTIALS PRESENTATIONS.pptx
IT3401-WEB ESSENTIALS PRESENTATIONS.pptxIT3401-WEB ESSENTIALS PRESENTATIONS.pptx
IT3401-WEB ESSENTIALS PRESENTATIONS.pptxSAJITHABANUS
 
Dev.bg DevOps March 2024 Monitoring & Logging
Dev.bg DevOps March 2024 Monitoring & LoggingDev.bg DevOps March 2024 Monitoring & Logging
Dev.bg DevOps March 2024 Monitoring & LoggingMarian Marinov
 
Renewable Energy & Entrepreneurship Workshop_21Feb2024.pdf
Renewable Energy & Entrepreneurship Workshop_21Feb2024.pdfRenewable Energy & Entrepreneurship Workshop_21Feb2024.pdf
Renewable Energy & Entrepreneurship Workshop_21Feb2024.pdfodunowoeminence2019
 
Multicomponent Spiral Wound Membrane Separation Model.pdf
Multicomponent Spiral Wound Membrane Separation Model.pdfMulticomponent Spiral Wound Membrane Separation Model.pdf
Multicomponent Spiral Wound Membrane Separation Model.pdfGiovanaGhasary1
 
EPE3163_Hydro power stations_Unit2_Lect2.pptx
EPE3163_Hydro power stations_Unit2_Lect2.pptxEPE3163_Hydro power stations_Unit2_Lect2.pptx
EPE3163_Hydro power stations_Unit2_Lect2.pptxJoseeMusabyimana
 
me3493 manufacturing technology unit 1 Part A
me3493 manufacturing technology unit 1 Part Ame3493 manufacturing technology unit 1 Part A
me3493 manufacturing technology unit 1 Part Akarthi keyan
 
Landsman converter for power factor improvement
Landsman converter for power factor improvementLandsman converter for power factor improvement
Landsman converter for power factor improvementVijayMuni2
 

Último (20)

Lecture 2 .pptx
Lecture 2                            .pptxLecture 2                            .pptx
Lecture 2 .pptx
 
UNIT4_ESD_wfffffggggggggggggith_ARM.pptx
UNIT4_ESD_wfffffggggggggggggith_ARM.pptxUNIT4_ESD_wfffffggggggggggggith_ARM.pptx
UNIT4_ESD_wfffffggggggggggggith_ARM.pptx
 
Vertical- Machining - Center - VMC -LMW-Machine-Tool-Division.pptx
Vertical- Machining - Center - VMC -LMW-Machine-Tool-Division.pptxVertical- Machining - Center - VMC -LMW-Machine-Tool-Division.pptx
Vertical- Machining - Center - VMC -LMW-Machine-Tool-Division.pptx
 
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
 
cloud computing notes for anna university syllabus
cloud computing notes for anna university syllabuscloud computing notes for anna university syllabus
cloud computing notes for anna university syllabus
 
GENERAL CONDITIONS FOR CONTRACTS OF CIVIL ENGINEERING WORKS
GENERAL CONDITIONS  FOR  CONTRACTS OF CIVIL ENGINEERING WORKS GENERAL CONDITIONS  FOR  CONTRACTS OF CIVIL ENGINEERING WORKS
GENERAL CONDITIONS FOR CONTRACTS OF CIVIL ENGINEERING WORKS
 
Graphics Primitives and CG Display Devices
Graphics Primitives and CG Display DevicesGraphics Primitives and CG Display Devices
Graphics Primitives and CG Display Devices
 
How to Write a Good Scientific Paper.pdf
How to Write a Good Scientific Paper.pdfHow to Write a Good Scientific Paper.pdf
How to Write a Good Scientific Paper.pdf
 
Engineering Mechanics Chapter 5 Equilibrium of a Rigid Body
Engineering Mechanics  Chapter 5  Equilibrium of a Rigid BodyEngineering Mechanics  Chapter 5  Equilibrium of a Rigid Body
Engineering Mechanics Chapter 5 Equilibrium of a Rigid Body
 
Présentation IIRB 2024 Chloe Dufrane.pdf
Présentation IIRB 2024 Chloe Dufrane.pdfPrésentation IIRB 2024 Chloe Dufrane.pdf
Présentation IIRB 2024 Chloe Dufrane.pdf
 
Power System electrical and electronics .pptx
Power System electrical and electronics .pptxPower System electrical and electronics .pptx
Power System electrical and electronics .pptx
 
IT3401-WEB ESSENTIALS PRESENTATIONS.pptx
IT3401-WEB ESSENTIALS PRESENTATIONS.pptxIT3401-WEB ESSENTIALS PRESENTATIONS.pptx
IT3401-WEB ESSENTIALS PRESENTATIONS.pptx
 
Dev.bg DevOps March 2024 Monitoring & Logging
Dev.bg DevOps March 2024 Monitoring & LoggingDev.bg DevOps March 2024 Monitoring & Logging
Dev.bg DevOps March 2024 Monitoring & Logging
 
Renewable Energy & Entrepreneurship Workshop_21Feb2024.pdf
Renewable Energy & Entrepreneurship Workshop_21Feb2024.pdfRenewable Energy & Entrepreneurship Workshop_21Feb2024.pdf
Renewable Energy & Entrepreneurship Workshop_21Feb2024.pdf
 
Multicomponent Spiral Wound Membrane Separation Model.pdf
Multicomponent Spiral Wound Membrane Separation Model.pdfMulticomponent Spiral Wound Membrane Separation Model.pdf
Multicomponent Spiral Wound Membrane Separation Model.pdf
 
EPE3163_Hydro power stations_Unit2_Lect2.pptx
EPE3163_Hydro power stations_Unit2_Lect2.pptxEPE3163_Hydro power stations_Unit2_Lect2.pptx
EPE3163_Hydro power stations_Unit2_Lect2.pptx
 
me3493 manufacturing technology unit 1 Part A
me3493 manufacturing technology unit 1 Part Ame3493 manufacturing technology unit 1 Part A
me3493 manufacturing technology unit 1 Part A
 
計劃趕得上變化
計劃趕得上變化計劃趕得上變化
計劃趕得上變化
 
Landsman converter for power factor improvement
Landsman converter for power factor improvementLandsman converter for power factor improvement
Landsman converter for power factor improvement
 
Présentation IIRB 2024 Marine Cordonnier.pdf
Présentation IIRB 2024 Marine Cordonnier.pdfPrésentation IIRB 2024 Marine Cordonnier.pdf
Présentation IIRB 2024 Marine Cordonnier.pdf
 

IPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriya

  • 1. Integrative Programming andTechnology 08/12/2015 1Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 2. How does an XML processor check your xml document? There are two main checks that XML processors make: 1. Checking that your document is well-formed ( Syntax rule) 2. Checking that it's valid (syntax-check your XML either in XML DTD or XSD) DTD- DocumentType Definition XSD-XMLSchema Definition Why need XMLValidator  Use our XML validator to syntax-check your XML.  Errors in XML documents will stop your XML applications unlike HTML browser 08/12/2015 2Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 3.  An XML document with correct syntax is called "Well Formed".  An XML document validated against a DTD is "Well Formed" and "Valid".  The purpose of a DTD is to define the structure of an XML document and a list of legal elements. How you add a DTD to our XML document 1. DTDs can be separate documents (or ) 2. They can be built into an XML document using a special element named <!DOCTYPE>. 08/12/2015 3Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 4. An XML Document with a DTD (example4.xml) <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/css" href="css1.css"?> <!DOCTYPE document [ <!ELEMENT document (heading, message)> <!ELEMENT heading (#PCDATA)> <!ELEMENT message (#PCDATA)> ]> <document> <heading> Hello From XML </heading> <message>This is an XML document! </message> </document> 08/12/2015 4Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 5. Valid XML Document with DTD (example.5.xml)  The DOCTYPE declaration is a reference to an external DTD file "Note.dtd“ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE note SYSTEM "Note.dtd"> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>  Note.dtd <!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> ]> 08/12/2015 5Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 6. The DTD above is interpreted like this:  !DOCTYPE note defines that the root element of the document is note  !ELEMENT note defines that the note element contains four elements: "to, from, heading, body"  !ELEMENT to defines the to element to be of type "#PCDATA"  !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“ Note #PCDATA means parse-able text data. When NOT to Use a Document Definition?  When you are working with small XML files, creating document definitions may be a waste of time. 08/12/2015 6Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 7.  Another way of validatingXML documents: using XML schemas.  The XML Schema language is also referred to as XML Schema Definition (XSD), describes the structure of an XML document.  defines the legal building blocks (elements and attributes) of an XML document like DTD.  defines which elements are child elements  defines the number and order 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 08/12/2015 7Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 8. XML Schemas will be used in most Web applications as a replacement for DTDs. Here are some reasons:  XML Schemas are extensible to future additions  XML Schemas are richer and more powerful than DTDs  XML Schemas are written in XML  XML Schemas support data types and namespaces Creating XML Schemas by Using XML Schema-CreationTools  HiT Software  xmlArchitect  XMLspy  XML Ray  MicrosoftVisual Studio .NET 08/12/2015 8Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 9. XSD Simple Element  The syntax for defining a simple element  Default and FixedValues for Simple Elements XSD Attributes  The syntax for defining an attribute  Default and FixedValues for Attributes  Optional and Required Attributes XSD Complex Elements  How to Define a Complex Element using XML Scheme  XSD Empty Elements XSD Indicators Order indicators are:  All  Choice  Sequence 08/12/2015 9Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 10. XSD Simple Element  A simple element is an XML element that can contain only text.  It cannot contain any other elements or attributes.  XML Schema has a lot of built-in data types.The most common types are: 1. xs:string 2. xs:decimal 3. xs:integer 4. xs:boolean 5. xs:date 6. xs:time The syntax for defining a simple element is: <xs:element name="xxx" type="yyy"/> Example <lastname>Refsnes</lastname> <age>36</age> <dateborn>1970-03-27</dateborn> <xs:element name="lastname" type="xs:string"/> <xs:element name="age" type="xs:integer"/> <xs:element name="dateborn" type="xs:date"/> 08/12/2015 10Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 11. Default and FixedValues for Simple Elements Simple elements may have a default value or a fixed value specified. 1. A default value is automatically assigned to the element when no other value is specified. <xs:element name="color" type="xs:string" default="red"/> 2. A fixed value is also automatically assigned to the element, and you cannot specify another value. <xs:element name="color" type="xs:string" fixed="red"/> 08/12/2015 11Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 12. XSD Attributes  Simple elements cannot have attributes.  If an element has attributes, it is considered to be of a complex type. But the attribute itself is always declared as a simple type. The syntax for defining an attribute is: <xs : attribute name="xxx" type="yyy"/> Example <lastname lang="EN">Smith</lastname> <xs:attribute name="lang" type="xs:string"/> Default and FixedValues for Attributes Attributes may have a default value or a fixed value specified. <xs:attribute name="lang" type="xs:string" default="EN"/> <xs:attribute name="lang" type="xs:string" fixed="EN"/> Optional and Required Attributes Attributes are optional by default.To specify that the attribute is required, use the "use" attribute: <xs:attribute name="lang" type="xs:string" use="required"/> 08/12/2015 12Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 13. XSD Complex Elements  A complex element is an XML element that contains other elements and/or attributes.  There are four kinds of complex elements: Example: 1. A complex XML element, "product", which is empty: <product pid="1345"/> 2. A complex XML element, "employee", which contains only other elements: <employee> <firstname>John</firstname> <lastname>Smith</lastname> </employee> 3. A complex XML element, "food", which contains only text: <food type="dessert">Ice cream</food> 4. A complex XML element, "description", which contains both elements and text: <description> It happened on <date lang=“EN">03.03.99</date> </description> 08/12/2015 13Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 14. How to Define a Complex Element using XML Scheme  Complex XML element, "employee", which contains only other elements: <employee> <firstname>John</firstname> <lastname>Smith</lastname> </employee>  The "employee" element can be declared directly by naming the element: <xs:element name="employee"> <xs:complexType> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element>  An empty complex element cannot have contents, only attributes. <product prodid="1345" />  It is possible to declare the "product" element more compactly: <xs:element name="product"> <xs:complexType> <xs:attribute name="prodid" type="xs:positiveInteger"/> </xs:complexType> </xs:element> 08/12/2015 14Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 15.  XSD Indicators  How elements are to be used in documents with indicators.  Order indicators are used to define the order of the elements.They are: 1. All 2. Choice 3. Sequence All Indicator:  The <all> indicator specifies that the child elements can appear in any order, and that each child element must occur only once: <xs:element name="person"> <xs:complexType> <xs:all> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:all> </xs:complexType> </xs:element> 08/12/2015 15Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 16. Choice Indicator:  The <choice> indicator specifies that either one child element or another can occur: <xs:element name="person"> <xs:complexType> <xs:choice> <xs:element name="employee" type="employee"/> <xs:element name="member" type="member"/> </xs:choice> </xs:complexType> </xs:element> Sequence Indicator:  The <sequence> indicator specifies that the child elements mustappear in a specific order: <xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> 08/12/2015 16Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 17. XML Example (“note.xml”) <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> XSD Example (“note.xsd”) <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> 08/12/2015 17Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 18. Example (shiporder.xml): <?xml version="1.0" encoding="ISO-8859-1"?> <shiporder orderid="889923"> <orderperson>John Smith</orderperson> <shipto> <name>Ola Nordmann</name> <address>Langgt 23</address> <city>4000 Stavanger</city> <country>Norway</country> </shipto> </shiporder> 08/12/2015 18Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 19. Example "shiporder.xsd": <?xml version="1.0" encoding="ISO-8859-1" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="shiporder"> <xs:complexType> <xs:sequence> <xs:element name="orderperson" type="xs:string"/> <xs:element name="shipto"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="address" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="country" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="orderid" type="xs:string" use="required"/> </xs:complexType> </xs:element> </xs:schema> 08/12/2015 19Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 20.  All modern browsers have a built-in XML parser.  An XML parser converts an XML document into an XML DOM object - which can then be manipulated with JavaScript. Parse an XML Document  The following code fragment parses an XML document into an XML DOM object: if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","books.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; 08/12/2015 20Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 21. XML DOM  The XML DOM defines a standard way for accessing and manipulating XML documents.  The XML DOM views an XML document as a tree-structure.  All elements can be accessed through the DOM tree.  Their content (text and attributes) can be modified or deleted, and new elements can be created.  The elements, their text, and their attributes are all known as nodes. The HTML DOM  The HTML DOM defines a standard way for accessing and manipulating HTML documents.  All HTML elements can be accessed through the HTML DOM. 08/12/2015 21Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia
  • 22. Load an XML File - Cross-browser  parses an XML document ("note.xml") into an XML DOM object and then extracts some information from it with a JavaScript: Example <html> <body> <span id="to"></span> <span id="from"></span> <span id="message"></span> <script> if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","note.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; document.getElementById("to").innerHTML= xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue; document.getElementById("from").innerHTML= xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue; document.getElementById("message").innerHTML= xmlDoc.getElementsByTagName("message")[0].childNodes[0].nodeValue; </script> </body> </html> 08/12/2015 22Dr. J.VijiPriya,Assistant Professor, Hawassa University, Ethiopia