CSC 322 Operating Systems Concepts Lecture - 31: b y Ahmed Mumtaz Mustehsan
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad
-
Upload
kieran-witt -
Category
Documents
-
view
39 -
download
2
description
Transcript of CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad
![Page 1: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/1.jpg)
CSC 330 E-CommerceCSC 330 E-CommerceTeacher
Ahmed Mumtaz MustehsanAhmed Mumtaz Mustehsan GM-IT CIIT IslamabadGM-IT CIIT Islamabad
Virtual Campus, CIITCIITCOMSATS Institute of Information Technology
T2-Lecture-5T2-Lecture-5
![Page 2: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/2.jpg)
eXtensable Markup Language (XML)eXtensable Markup Language (XML)Part - IIIPart - III
For Lecture Material/Slides Thanks to: www.w3schools.com
![Page 3: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/3.jpg)
ObjectivesObjectivesPart 1:
Review The basics of creating an XML documentPart 2:
Imposing Structure on XML Documents using Document Type Definition DTDPart 3:
Strengthening the data-modeling capabilities of XML Using XML Schemas
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-3
![Page 4: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/4.jpg)
Part 1: Part 1: Review The basics of creating an XML Review The basics of creating an XML
documentdocument
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-4
![Page 5: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/5.jpg)
Part 1: A review of XMLPart 1: A review of XMLAn Extensible Markup Language (XML) document
describes the structure of data.
XML and HTML have a similar syntax … both derived from SGML
XML has no mechanism to specify the format for presenting data to the user
An XML document resides in its own file with an ‘.xml’ extension
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-5
![Page 6: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/6.jpg)
Main Components of an XML DocumentMain Components of an XML Document
Elements: <hello>
Attributes: <item id=“33905”>
Entities: < (<)
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-6
![Page 7: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/7.jpg)
The Basic RulesThe Basic Rules
XML is case sensitiveAll start tags must have end tagsElements must be properly nestedXML declaration is the first statementEvery document must contain a root elementAttribute values must have quotation marksCertain characters are reserved for parsing
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-7
![Page 8: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/8.jpg)
XML is different from HTMLXML is different from HTML
HTML is a Hyper Text Markup language◦ Designed for a specific application, namely,
displaying, viewing, presenting and linking hypertext documents
XML describes structure (organization of data)
and content (“semantics” the interpretation of data)
XML is a subset of SGML (Standard Generalized SGML (Standard Generalized Markup Language) Markup Language)
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-8
![Page 9: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/9.jpg)
An Address Book as an XML documentAn Address Book as an XML document
<addresses><person>
<name> Ahmed Mumtaz</name><tel> 9251-2233-44 </tel><email> [email protected] </email>
</person><person>
<name> Malik Riaz khan</name><tel> 9251-123-4450 </tel><email>[email protected]</email>
</person></addresses>
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-9
![Page 10: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/10.jpg)
Important Features of XMLImportant Features of XML
No fixed set of tagsUser is allowed to introduce New tags
Already defined set of tags can also be used Namespaces facilitate uniform and coherent descriptions of dataFor example, a namespace for address books determines to use of :
<tel> or <phone> or <mobile>
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-10
![Page 11: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/11.jpg)
Features of XMLFeatures of XML (cont’d) (cont’d)XML supports internationalization through UnicodeWeb services (e.g., e-commerce) require
exchanging data between various applications that run on different platforms.
XML (with the support of namespaces) is the best option for data exchange on the Web.
XML is a data model ◦ Similar to the semi-structured-data-model
XML has follow the concept of DTD and the more impressive XML Schema
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-11
![Page 12: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/12.jpg)
XML familyXML family
Limited styling of XML can be done with CSS Document Type Definitions (DTDs) impose structure
on XML documentsXML Schemas strengthen the data-modeling
capabilities of XMLXPath is a language for accessing XML documentsXLink and XPointer support cross-referencesXSLT is a language for transforming XML documents
into other XML documents such as XHTML, for viewing XML files
XQuery is a language for querying XML documents
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-12
![Page 13: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/13.jpg)
DTD : (Document Type Definition)DTD : (Document Type Definition)
Imposing Structure onImposing Structure onXML DocumentsXML Documents
usingusing
![Page 14: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/14.jpg)
XML defines structure of the documentXML defines structure of the documentSome XML files only contain text documents with
tags that contain metadata and describe the structure Example:
<book year= “2011"><title> e-Commerce Business, Technology and Society </title>
<author><last>Laudon</last><first>Kenneth</first>
</author><publisher>PEARSON</publisher><price>78.99</price>
</book>
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-14
![Page 15: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/15.jpg)
Document Type DefinitionsDocument Type Definitions
Document Type Definitions (DTDs) impose structure on XML documents
There is some relationship between a DTD and a schema, but it is not close hence the need for additional “typing” systems exists.
The DTD is a syntactic specification
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-15
![Page 16: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/16.jpg)
Document Type DefinitionsDocument Type DefinitionsA description of legal, valid data further contributes
to the interoperability and efficiency of using XMLA single DTD ensures a common format for each
XML document that references it.An application can use a standard DTD to verify
that data that it receives from the outside world is valid.
An XML document that conforms to the rules within a DTD is said to be valid document.
If the XML document does not follow the rules contained within the DTD, a parser generates an error.
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-16
![Page 17: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/17.jpg)
MotivationMotivationA DTD adds syntactical requirements in addition to
the well-formed requirement.
It helps in eliminating errors when creating or editing XML documents.
It clarifies the intended semantics.
It simplifies the processing of XML documents
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-17
![Page 18: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/18.jpg)
An ExampleAn Example
In an address book, where can a phone number appear?
Under <person>, under <name> or under both?
If we have to check for all possibilities, processing takes longer and it may not be clear to whom a phone belongs to?
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-18
![Page 19: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/19.jpg)
Example: An Address BookExample: An Address Book
<person>
<name> Homer Simpson </name>
<greet> Dr. H. Simpson </greet>
<addr>1234 Springwater Road </addr>
<addr> Springfield USA, 98765 </addr>
<tel> (321) 786 2543 </tel>
<fax> (051) 786 2544 </fax>
<tel> (051) 786 2544 </tel>
<email> [email protected] </email>
</person>
Mixed telephones and faxes
As manyas needed
As many address lines as needed (in order)
At most one greeting
Exactly one name
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-19
![Page 20: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/20.jpg)
Specifying the StructureSpecifying the Structurename to specify a name element
greet? to specify an optional (0 or 1) greet elements
name, greet? to specify a name followed by an optional greet
addr* to specify 0 or more address lines
tel | fax a tel or a fax element
(tel | fax)* 0 or more repeats of tel or fax
email* 0 or more email elementsT2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com
1-20
![Page 21: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/21.jpg)
Specifying the Structure (cont’d)Specifying the Structure (cont’d)
So the whole structure of a person entry is specified by
name, greet?, addr*, (tel | fax)*, email*
This is known as a regular expression
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-21
![Page 22: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/22.jpg)
Element Type DefinitionElement Type Definition
for each element type E, a declaration of the form: <!ELEMENT E P> where P is a regular expression, i.e.,P ::= EMPTY | ANY | #PCDATA | E’ | P1, P2 | P1 | P2 | P? | P+ | P*
◦ E’: element type◦ P1 , P2: concatenation◦ P1 | P2: disjunction ◦ P?: optional◦ P+: one or more occurrences◦ P*: 0 or more occurrences
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-22
![Page 23: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/23.jpg)
Summary of Regular ExpressionsSummary of Regular Expressions
A The tag (i.e., element) A occurs
e1,e2 The expression e1 followed by e2
e* 0 or more occurrences of e
e? Optional: 0 or 1 occurrences
e+ 1 or more occurrences
e1 | e2 either e1 or e2
(e) grouping
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-23
![Page 24: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/24.jpg)
The Definition of an Element Consists of The Definition of an Element Consists of Exactly One of the FollowingExactly One of the Following
A regular expression (as defined earlier)EMPTY means that the element has no contentANY means that content can be any mixture of
PCDATA and elements defined in the DTDMixed content which is defined as described on the
next slide :(#PCDATA)
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-24
![Page 25: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/25.jpg)
The Definition of Mixed ContentThe Definition of Mixed Content
Mixed content is described by a repeatable OR group
(#PCDATA | element-name | …)*
Inside the group, no regular expressions ; just ement names
#PCDATA must be first followed by 0 or more element names, separated by |
* The group can be repeated 0 or more times
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-25
![Page 26: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/26.jpg)
Some Example DTD DeclarationsSome Example DTD DeclarationsExample 1: Elements with Data
<!ELEMENT Month (#PCDATA)> <!--DTD declaration of an element->
<!—Valid usage within XML file-->
<Month>April</Month> <Month>This is a month</Month>
<!—Invalid usage within XML file, Month can’t have children!-->
<Month> <January>Jan</January><March>March</March></Month>
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-26
![Page 27: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/27.jpg)
Some Example DTD DeclarationsSome Example DTD DeclarationsExample 3: Elements with Children ;To specify that an element must have a single child element, include the element name within the parenthesis.
<!ELEMENT House (Address)> <!—A house element has a single child address--><House> <!—Valid usage within XML file--> <Address> 5 Park Road Chak Shahzad, Islamabad </Address></House>
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-27
![Page 28: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/28.jpg)
Some Example DTD DeclarationsSome Example DTD DeclarationsExample-3: An element can have multiple children. A DTD describes multiple children using a sequence, or a list of elements separated by commas. The XML file must contain one of each element in the specified order.
<!--DTD declaration of an element--> <!ELEMENT address (person,street,city, zip)> <!ELEMENT person (#PCDATA)> <!ELEMENT street (#PCDATA)> <!ELEMENT city (#PCDATA)> <!ELEMENT zip (#PCDATA)> <!—Valid usage within XML file--> <address> <person> Tariq Rasheed </person> <street> 9th Eveneue.</street> <city> Federal Area, Islamabad </city> <zip> 44000 </zip> </address>
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-28
![Page 29: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/29.jpg)
Cautions concerning DTDsCautions concerning DTDs All element declarations begin with <! and end
with ><! ELEMENT Address >
The ELEMENT declaration is case sensitive The programmer must declare all elements within
an XML file Elements declared with the #PCDATA content
model can not have children When describing sequences, (e1,e2) the XML
document must contain exactly those elements in exactly that order.
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-29
![Page 30: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/30.jpg)
An Address-Book XML Document with an An Address-Book XML Document with an Internal DTD Internal DTD <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE addressbook [ <!ELEMENT addressbook (person*)> <!ELEMENT person (name, greet?, address*, (fax | tel)*, email*)> <!ELEMENT name (#PCDATA)> <!ELEMENT greet (#PCDATA)> <!ELEMENT address (#PCDATA)> <!ELEMENT tel (#PCDATA)> <!ELEMENT fax (#PCDATA)> <!ELEMENT email (#PCDATA)>]>
The name ofthe DTD is
addressbook
“Internal” means that the DTD and theXML Document are in the same file
The syntax of a DTD is not XML syntax
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-30
![Page 31: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/31.jpg)
The Address-Book XML DocumentThe Address-Book XML Document
<addressbook> <person> <name> Ahmed Mumtaz</name> <greet> Prof. Mumtaz</greet>
<email> [email protected] </email> </person></addressbook>
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-31
![Page 32: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/32.jpg)
XML documents are similar to database filesXML documents are similar to database files
Example:
A Relational database for school:
student: course:
enroll:
cno title credit
331 DB 3.0350 Web 3.0… … …
id name gpa
001 J oe 3.0002 Mary 4.0… … …
id cno
001 331001 350002 331… …
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-32
![Page 33: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/33.jpg)
XML Representation of school database
<school>
<student id=“001”>
<name> Joe </name> <gpa> 3.0 </gpa>
</student>
<student id=“002”>
<name> Mary </name> <gpa> 4.0 </gpa>
</student>
<course cno=“331”>
<title> DB </title> <credit> 3.0 </credit>
</course>
<course cno=“350”>
<title> Web </title> <credit> 3.0 </credit>
</course>T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com
1-33
![Page 34: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/34.jpg)
<enroll>
<id> 001 </id> <cno> 331 </cno>
</enroll>
<enroll>
<id> 001 </id> <cno> 350 </cno>
</enroll>
<enroll>
<id> 002 </id> <cno> 331 </cno>
</enroll>
</school>
XML Representation of school database
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-34
![Page 35: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/35.jpg)
Well-Formed XML DocumentsWell-Formed XML Documents
An XML document (with or without a DTD) is
well-formed if
◦ Tags are syntactically correct
◦ Every tag has an end tag
◦ Tags are properly nested
◦ There is a root tag
◦ A start tag does not have two occurrences of the
same attribute
An XML document must be well formed
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-35
![Page 36: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/36.jpg)
Strengthen the data-modeling Strengthen the data-modeling capabilities of XMLcapabilities of XML
UsingUsingXML SchemasXML Schemas
![Page 37: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/37.jpg)
What is an XML Schema?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 documentdefines attributes that can appear in a documentdefines which elements are child elementsdefines the order of child elementsdefines the number of child elementsdefines whether an element is empty or can include textdefines data types for elements and attributesdefines default and fixed values for elements and attributes
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-37
![Page 38: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/38.jpg)
XML Schemas are the Successors of DTDsXML Schemas are the Successors of DTDsIt is expected that XML Schemas will be used in most Web applications as a replacement for DTDs.
Here are some reasons:XML Schemas are extensible to future additionsXML Schemas are richer and more powerful than DTDsXML Schemas are written in XMLXML Schemas support data typesXML Schemas support namespaces
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-38
![Page 39: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/39.jpg)
XML SchemaXML Schema
XML Schema is an XML-based alternative to DTD:
Example:
<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>
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-39
![Page 40: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/40.jpg)
XML SchemaXML SchemaThe Schema in previous example is interpreted like this:
Explanation of the Example:<xs:element name="note"> defines the element called "note"<xs:complexType> the "note" element is a complex type<xs:sequence> the complex type is a sequence of elements<xs:element name="to" type="xs:string"> the element "to" is of type string (text)<xs:element name="from" type="xs:string"> the element "from" is of type string<xs:element name="heading" type="xs:string"> the element "heading" is of type string<xs:element name="body" type="xs:string"> the element "body" is of type string
Everything is wrapped in "Well Formed" XML.
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-40
![Page 41: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/41.jpg)
Why Use an XML Schema?Why Use an XML Schema?
With XML Schema, the XML files can carry a description of its own format.
With XML Schema, independent groups of people can agree on a standard for interchanging data.
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-41
![Page 42: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/42.jpg)
XML Schemas use XML SyntaxXML Schemas use XML Syntax
Another great strength about XML Schemas is that they are written in XML:You don't have to learn a new languageYou can use your XML editor to edit your Schema filesYou can use your XML parser to parse your Schema filesYou can manipulate your Schemas with the XML DOMYou can transform your Schemas with XSLT
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-42
![Page 43: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/43.jpg)
XML Schemas Support Data TypesXML Schemas Support Data Types
One of the greatest strength of XML Schemas is the support for data types:
It is easier to describe document content It is easier to define restrictions on data It is easier to validate the correctness of data It is easier to convert data between different data
types
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-43
![Page 44: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/44.jpg)
XML Schemas Support Data TypesXML Schemas Support Data Types
One of the greatest strength of XML Schemas is the support for data types:
It is easier to describe document content It is easier to define restrictions on data It is easier to validate the correctness of data It is easier to convert data between different data
types
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-44
![Page 45: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/45.jpg)
XML Schemas Secure Data CommunicationXML Schemas Secure Data CommunicationWhen sending data from a sender to a receiver, it is
essential that both parts have the same "expectations" about the content.
With XML Schemas, the sender can describe the data in a way that the receiver will understand.
A date like: "03-11-2004" will, in some countries, be interpreted as 3.November and in other countries as 11.March.
However, an XML element with a data type like this:<date type="date">2004-03-11</date>ensures a mutual understanding of the content,
because the XML data type "date" requires the format "YYYY-MM-DD".
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-45
![Page 46: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/46.jpg)
XML Schemas are ExtensibleXML Schemas are ExtensibleXML Schemas are extensible, because they are written in XML.
With an extensible Schema definition you can:Reuse your Schema in other SchemasCreate your own data types derived from the standard typesReference multiple schemas in the same document
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-46
![Page 47: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/47.jpg)
Well-Formed is not EnoughWell-Formed is not EnoughA well-formed XML document is a document that conforms to the XML syntax rules, like:it must begin with the XML declarationit must have one unique root elementstart-tags must have matching end-tagselements are case sensitiveall elements must be closedall elements must be properly nestedall attribute values must be quotedentities must be used for special characters
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com1-47
![Page 48: CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad](https://reader035.fdocuments.us/reader035/viewer/2022062221/56813488550346895d9b6bb7/html5/thumbnails/48.jpg)
The EndThe End
eXtensable Markup Language (XML)eXtensable Markup Language (XML)Part – IIIPart – III
Thank YouThank You
T2-Lecture-5 Ahmed Mumtaz Mustehsan www.w3schools.com
1-48