SlideShare a Scribd company logo
1 of 28
1
XML
eXtensible Markup Language
2
Introduction and Motivation
Dr. Praveen Madiraju
Modified from Dr.Sagiv’s slides
3
XML vs. HTML
• HTML is a HyperText Markup language
– Designed for a specific application, namely,
presenting and linking hypertext
documents
• XML describes structure and content
(“semantics”)
– The presentation is defined separately
from the structure and the content
4
An Address Book as
an XML document
<addresses>
<person>
<name> Donald Duck</name>
<tel> 414-222-1234 </tel>
<email> donald@yahoo.com </email>
</person>
<person>
<name> Miki Mouse</name>
<tel> 123-456-7890 </tel>
<email>miki@yahoo.com</email>
</person>
</addresses>
5
Main Features of XML
• No fixed set of tags
– New tags can be added for new
applications
• An agreed upon set of tags can be used
in many applications
– Namespaces facilitate uniform and
coherent descriptions of data
• For example, a namespace for address books
determines whether to use <tel> or <phone>
6
Main Features of XML (cont’d)
• XML has the concept of a schema
– DTD and the more expressive XML
Schema
• XML is a data model
– Similar to the semistructured data model
• XML supports internationalization
(Unicode) and platform independence
(an XML file is just a character file)
7
XML is the Standard for
Data Exchange
• Web services (e.g., ecommerce) require
exchanging data between various
applications that run on different
platforms
• XML (augmented with namespaces) is
the preferred syntax for data exchange
on the Web
8
XML is not Alone
• XML Schemas strengthen the data-modeling
capabilities of XML (in comparison to XML with
only DTDs)
• XPath is a language for accessing parts of
XML documents
• XLink and XPointer support cross-references
• XSLT is a language for transforming XML
documents into other XML documents
(including XHTML, for displaying XML files)
– Limited styling of XML can be done with CSS alone
• XQuery is a lanaguage for querying XML
documents
9
The Two Facets of XML
• Some XML files are just text documents with
tags that denote their structure and include
some metadata (e.g., an attribute that gives
the name of the person who did the
proofreading)
– See an example on the next slide
– XML is a subset of SGML (Standard Generalized
Markup Language)
• Other XML documents are similar to
database files (e.g., an address book)
10
XML can Describe
the Structure of a Document
• <book year="1994">
<title>TCP/IP Illustrated</title>
<author>
<last>Stevens</last>
<first>W.</first>
</author>
<publisher>Addison-Wesley</publisher>
<price>65.95</price>
</book>
11
XML Syntax
W3Schools Resources on XML Syntax
12
The Structure of XML
• XML consists of tags and text
• Tags come in pairs <date> ... </date>
• They must be properly nested
– good
<date> ... <day> ... </day> ... </date>
– bad
<date> ... <day> ... </date>... </day>
(You can’t do <i> ... <b> ... </i> ...</b> in HTML)
13
A Useful Abbreviation
Abbreviating elements with empty contents:
• <br/> for <br></br>
• <hr width=“10”/> for <hr width=“10”></hr>
For example:
<family>
<person id = “lisa”>
<name> Lisa Simpson </name>
<mother idref = “marge”/>
<father idref = “homer”/>
</person>
...
</family>
Note that a tag
may have a set
of attributes,
each consisting
of a name and
a value
14
XML Text
XML has only one “basic” type – text
It is bounded by tags, e.g.,
<title> The Big Sleep </title>
<year> 1935 </ year> – 1935 is still text
• XML text is called PCDATA
– (for parsed character data)
• It uses a 16-bit encoding, e.g., &#x0152 for
the Hebrew letter Mem
15
XML Structure
• Nesting tags can be used to express
various structures, e.g., a tuple
(record):
<person>
<name> Lisa Simpson</name>
<tel> 02-828-1234 </tel>
<tel> 054-470-777 </tel>
<email> lisa@cs.huji.ac.il </email>
</person>
16
XML Structure (cont’d)
• We can represent a list by using the
same tag repeatedly:
<addresses>
<person> … </person>
<person> … </person>
<person> … </person>
<person> … </person>
…
</addresses>
17
XML Structure (cont’d)
<addresses>
<person>
<name> Donald Duck</name>
<tel> 04-828-1345 </tel>
<email> donald@cs.technion.ac.il </email>
</person>
<person>
<name> Miki Mouse</name>
<tel> 03-426-1142 </tel>
<email>miki@yahoo.com</email>
</person>
</addresses>
18
Terminology
The segment of an XML document
between an opening and a corresponding
closing tag is called an element
<person>
<name> Bart Simpson </name>
<tel> 02 – 444 7777 </tel>
<tel> 051 – 011 022 </tel>
<email> bart@tau.ac.il </email>
</person>
element element,
a sub-element of
not an element
19
An XML Document is a Tree
person
name email
tel tel
Bart Simpson
02 – 444 7777
051 – 011 022
bart@tau.ac.il
Leaves are either empty or contain PCDATA
20
Mixed Content
An element may contain a mixture of sub-
elements and PCDATA
<airline>
<name> British Airways </name>
<motto>
World’s <dubious> favorite</dubious>
airline
</motto>
</airline>
21
The Header Tag
• <?xml version="1.0" standalone="yes/no"
encoding="UTF-8"?>
– Standalone=“no” means that there is an
external DTD
– You can leave out the encoding attribute and
the processor will use the UTF-8 default
22
Processing Instructions
<?xml version="1.0"?>
<?xml-stylesheet href="doc.xsl" type="text/xsl"?>
<!DOCTYPE doc SYSTEM "doc.dtd">
<doc>Hello, world!<!-- Comment 1 --></doc>
<?pi-without-data?>
<!-- Comment 2 -->
<!-- Comment 3 -->
23
Using CDATA
<HEAD1>
Entering a Kennel Club Member
</HEAD1>
<DESCRIPTION>
Enter the member by the name on his or her papers. Use the
NAME tag. The NAME tag has two attributes. Common (all in
lowercase, please!) is the dog's call name. Breed (also in all
lowercase) is the dog's breed. Please see the breed reference
guide for acceptable breeds. Your entry should look something
like this:
</DESCRIPTION>
<EXAMPLE>
<![CDATA[<NAME common="freddy" breed"=springer-
spaniel">Sir Fredrick of Ledyard's End</NAME>]]>
</EXAMPLE>
We want to see
the text as is,
even though
it includes tags
24
A Complete XML Document
http://www.mscs.mu.edu/~praveen/Teachi
ng/fa05/AdvDb/Lectures/bib.xml
25
Well-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
26
Representing relational
databases
A relational database for school:
student: course:
enroll:
cno title credit
331 DB 3.0
350 Web 3.0
… … …
id name gpa
001 Joe 3.0
002 Mary 4.0
… … …
id cno
001 331
001 350
002 331
… …
27
XML representation
<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>
28
XML representation
<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>

More Related Content

Similar to xml.ppt (20)

Unit3wt
Unit3wtUnit3wt
Unit3wt
 
Unit3wt
Unit3wtUnit3wt
Unit3wt
 
Unit2_XML_S_SS_US Data_CS19414.pptx
Unit2_XML_S_SS_US Data_CS19414.pptxUnit2_XML_S_SS_US Data_CS19414.pptx
Unit2_XML_S_SS_US Data_CS19414.pptx
 
Xsd
XsdXsd
Xsd
 
Xsd
XsdXsd
Xsd
 
Web Information Systems XML
Web Information Systems XMLWeb Information Systems XML
Web Information Systems XML
 
Xml PPT
Xml PPTXml PPT
Xml PPT
 
Xml
XmlXml
Xml
 
XML
XMLXML
XML
 
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
 
xMLDataModel.pdf
xMLDataModel.pdfxMLDataModel.pdf
xMLDataModel.pdf
 
Introduction to xml schema
Introduction to xml schemaIntroduction to xml schema
Introduction to xml schema
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
 
01_XMLDataModel.pptx
01_XMLDataModel.pptx01_XMLDataModel.pptx
01_XMLDataModel.pptx
 
Xml unit1
Xml unit1Xml unit1
Xml unit1
 
Xml 215-presentation
Xml 215-presentationXml 215-presentation
Xml 215-presentation
 
Xml 215-presentation
Xml 215-presentationXml 215-presentation
Xml 215-presentation
 
02 xml schema
02 xml schema02 xml schema
02 xml schema
 
Xml iet 2015
Xml iet 2015Xml iet 2015
Xml iet 2015
 
Introduce to XML
Introduce to XMLIntroduce to XML
Introduce to XML
 

More from RajaGanesan14

More from RajaGanesan14 (11)

Commonnetwork.ppt
Commonnetwork.pptCommonnetwork.ppt
Commonnetwork.ppt
 
Networktypes.ppt
Networktypes.pptNetworktypes.ppt
Networktypes.ppt
 
Networkuses.ppt
Networkuses.pptNetworkuses.ppt
Networkuses.ppt
 
VOip.ppt
VOip.pptVOip.ppt
VOip.ppt
 
Computernet.ppt
Computernet.pptComputernet.ppt
Computernet.ppt
 
Computernetworksss.ppt
Computernetworksss.pptComputernetworksss.ppt
Computernetworksss.ppt
 
Computernetworks.ppt
Computernetworks.pptComputernetworks.ppt
Computernetworks.ppt
 
Gridcomputing.ppt
Gridcomputing.pptGridcomputing.ppt
Gridcomputing.ppt
 
Gridnetworks.ppt
Gridnetworks.pptGridnetworks.ppt
Gridnetworks.ppt
 
Cloudnetwork.ppt
Cloudnetwork.pptCloudnetwork.ppt
Cloudnetwork.ppt
 
Intro Ch 09A.ppt
Intro Ch 09A.pptIntro Ch 09A.ppt
Intro Ch 09A.ppt
 

Recently uploaded

MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 

Recently uploaded (20)

MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 

xml.ppt

  • 2. 2 Introduction and Motivation Dr. Praveen Madiraju Modified from Dr.Sagiv’s slides
  • 3. 3 XML vs. HTML • HTML is a HyperText Markup language – Designed for a specific application, namely, presenting and linking hypertext documents • XML describes structure and content (“semantics”) – The presentation is defined separately from the structure and the content
  • 4. 4 An Address Book as an XML document <addresses> <person> <name> Donald Duck</name> <tel> 414-222-1234 </tel> <email> donald@yahoo.com </email> </person> <person> <name> Miki Mouse</name> <tel> 123-456-7890 </tel> <email>miki@yahoo.com</email> </person> </addresses>
  • 5. 5 Main Features of XML • No fixed set of tags – New tags can be added for new applications • An agreed upon set of tags can be used in many applications – Namespaces facilitate uniform and coherent descriptions of data • For example, a namespace for address books determines whether to use <tel> or <phone>
  • 6. 6 Main Features of XML (cont’d) • XML has the concept of a schema – DTD and the more expressive XML Schema • XML is a data model – Similar to the semistructured data model • XML supports internationalization (Unicode) and platform independence (an XML file is just a character file)
  • 7. 7 XML is the Standard for Data Exchange • Web services (e.g., ecommerce) require exchanging data between various applications that run on different platforms • XML (augmented with namespaces) is the preferred syntax for data exchange on the Web
  • 8. 8 XML is not Alone • XML Schemas strengthen the data-modeling capabilities of XML (in comparison to XML with only DTDs) • XPath is a language for accessing parts of XML documents • XLink and XPointer support cross-references • XSLT is a language for transforming XML documents into other XML documents (including XHTML, for displaying XML files) – Limited styling of XML can be done with CSS alone • XQuery is a lanaguage for querying XML documents
  • 9. 9 The Two Facets of XML • Some XML files are just text documents with tags that denote their structure and include some metadata (e.g., an attribute that gives the name of the person who did the proofreading) – See an example on the next slide – XML is a subset of SGML (Standard Generalized Markup Language) • Other XML documents are similar to database files (e.g., an address book)
  • 10. 10 XML can Describe the Structure of a Document • <book year="1994"> <title>TCP/IP Illustrated</title> <author> <last>Stevens</last> <first>W.</first> </author> <publisher>Addison-Wesley</publisher> <price>65.95</price> </book>
  • 12. 12 The Structure of XML • XML consists of tags and text • Tags come in pairs <date> ... </date> • They must be properly nested – good <date> ... <day> ... </day> ... </date> – bad <date> ... <day> ... </date>... </day> (You can’t do <i> ... <b> ... </i> ...</b> in HTML)
  • 13. 13 A Useful Abbreviation Abbreviating elements with empty contents: • <br/> for <br></br> • <hr width=“10”/> for <hr width=“10”></hr> For example: <family> <person id = “lisa”> <name> Lisa Simpson </name> <mother idref = “marge”/> <father idref = “homer”/> </person> ... </family> Note that a tag may have a set of attributes, each consisting of a name and a value
  • 14. 14 XML Text XML has only one “basic” type – text It is bounded by tags, e.g., <title> The Big Sleep </title> <year> 1935 </ year> – 1935 is still text • XML text is called PCDATA – (for parsed character data) • It uses a 16-bit encoding, e.g., &#x0152 for the Hebrew letter Mem
  • 15. 15 XML Structure • Nesting tags can be used to express various structures, e.g., a tuple (record): <person> <name> Lisa Simpson</name> <tel> 02-828-1234 </tel> <tel> 054-470-777 </tel> <email> lisa@cs.huji.ac.il </email> </person>
  • 16. 16 XML Structure (cont’d) • We can represent a list by using the same tag repeatedly: <addresses> <person> … </person> <person> … </person> <person> … </person> <person> … </person> … </addresses>
  • 17. 17 XML Structure (cont’d) <addresses> <person> <name> Donald Duck</name> <tel> 04-828-1345 </tel> <email> donald@cs.technion.ac.il </email> </person> <person> <name> Miki Mouse</name> <tel> 03-426-1142 </tel> <email>miki@yahoo.com</email> </person> </addresses>
  • 18. 18 Terminology The segment of an XML document between an opening and a corresponding closing tag is called an element <person> <name> Bart Simpson </name> <tel> 02 – 444 7777 </tel> <tel> 051 – 011 022 </tel> <email> bart@tau.ac.il </email> </person> element element, a sub-element of not an element
  • 19. 19 An XML Document is a Tree person name email tel tel Bart Simpson 02 – 444 7777 051 – 011 022 bart@tau.ac.il Leaves are either empty or contain PCDATA
  • 20. 20 Mixed Content An element may contain a mixture of sub- elements and PCDATA <airline> <name> British Airways </name> <motto> World’s <dubious> favorite</dubious> airline </motto> </airline>
  • 21. 21 The Header Tag • <?xml version="1.0" standalone="yes/no" encoding="UTF-8"?> – Standalone=“no” means that there is an external DTD – You can leave out the encoding attribute and the processor will use the UTF-8 default
  • 22. 22 Processing Instructions <?xml version="1.0"?> <?xml-stylesheet href="doc.xsl" type="text/xsl"?> <!DOCTYPE doc SYSTEM "doc.dtd"> <doc>Hello, world!<!-- Comment 1 --></doc> <?pi-without-data?> <!-- Comment 2 --> <!-- Comment 3 -->
  • 23. 23 Using CDATA <HEAD1> Entering a Kennel Club Member </HEAD1> <DESCRIPTION> Enter the member by the name on his or her papers. Use the NAME tag. The NAME tag has two attributes. Common (all in lowercase, please!) is the dog's call name. Breed (also in all lowercase) is the dog's breed. Please see the breed reference guide for acceptable breeds. Your entry should look something like this: </DESCRIPTION> <EXAMPLE> <![CDATA[<NAME common="freddy" breed"=springer- spaniel">Sir Fredrick of Ledyard's End</NAME>]]> </EXAMPLE> We want to see the text as is, even though it includes tags
  • 24. 24 A Complete XML Document http://www.mscs.mu.edu/~praveen/Teachi ng/fa05/AdvDb/Lectures/bib.xml
  • 25. 25 Well-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
  • 26. 26 Representing relational databases A relational database for school: student: course: enroll: cno title credit 331 DB 3.0 350 Web 3.0 … … … id name gpa 001 Joe 3.0 002 Mary 4.0 … … … id cno 001 331 001 350 002 331 … …
  • 27. 27 XML representation <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>
  • 28. 28 XML representation <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>