1 / 28

XML - PowerPoint PPT Presentation

  • Uploaded on

XML. eXtensible Markup Language. Introduction and Motivation. Dr. Praveen Madiraju Modified from Dr.Sagiv’s slides. XML vs. HTML. HTML is a HyperText Markup language Designed for a specific application, namely, presenting and linking hypertext documents

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'XML' - wayne

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript


eXtensible Markup Language

Introduction and motivation

Introduction and Motivation

Dr. Praveen Madiraju

Modified from Dr.Sagiv’s slides

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

An address book as an xml document
An Address Book asan XML document



<name> Donald Duck</name>

<tel> 414-222-1234 </tel>

<email> donald@yahoo.com </email>



<name> Miki Mouse</name>

<tel> 123-456-7890 </tel>




Main features of xml
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>

Main features of xml cont d
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)

Xml is the standard for data exchange
XML is the Standard forData 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

Xml is not alone
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

The two facets of xml
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)

Xml can describe the structure of a document
XML can Describethe Structure of a Document

  • <book year="1994">

    <title>TCP/IP Illustrated</title>








Xml syntax

XML Syntax

W3Schools Resources on XML Syntax

The structure of xml
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)

A useful abbreviation
A Useful Abbreviation

Abbreviating elements with empty contents:

  • <br/> for <br></br>

  • <hrwidth=“10”/> for <hrwidth=“10”></hr>

    For example:


    <personid = “lisa”>

    <name> LisaSimpson </name>

    <motheridref = “marge”/>

    <fatheridref = “homer”/>




Note that a tag may have a set of attributes, each consisting of a name and a value

Xml text
XML Text

XML has only one “basic” type – text

It is bounded by tags, e.g.,

<title>TheBig 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

Xml structure
XML Structure

  • Nesting tags can be used to express various structures, e.g., a tuple (record):


<name> Lisa Simpson</name>

<tel> 02-828-1234 </tel>

<tel> 054-470-777 </tel>

<email> lisa@cs.huji.ac.il </email>


Xml structure cont d
XML Structure (cont’d)

  • We can represent a list by using the same tag repeatedly:


<person>… </person>





Xml structure cont d1
XML Structure (cont’d)



<name> Donald Duck</name>

<tel> 04-828-1345 </tel>

<email> donald@cs.technion.ac.il </email>



<name> Miki Mouse</name>

<tel> 03-426-1142 </tel>






a sub-element of


not an element


The segment of an XML document between an opening and a corresponding closing tag is called an element


<name>Bart Simpson</name>

<tel>02 – 444 7777</tel>

<tel>051 – 011 022</tel>



An xml document is a tree






An XML Document is a Tree

Bart Simpson

051 – 011 022

02 – 444 7777


Leaves are either empty or contain PCDATA

Mixed content
Mixed Content

An element may contain a mixture of sub-elements and PCDATA


<name>British Airways</name>






The header tag
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

Processing instructions
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>


<!-- Comment 2 -->

<!-- Comment 3 -->

Using cdata

We want to see

the text as is,

even though

it includes tags


<HEAD1> Entering a Kennel Club Member


<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:


<EXAMPLE><![CDATA[<NAME common="freddy" breed"=springer-spaniel">SirFredrick of Ledyard's End</NAME>]]>


A complete xml document
A Complete XML Document


Well formed xml documents
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

    • Attribute values must be quoted.

An XML document must be well formed

Representing relational databases
Representing relational databases

A relational database for school:

student: course:



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>

Xml representation
XML representation


<id> 001 </id> <cno> 331 </cno>



<id> 001 </id> <cno> 350 </cno>



<id> 002 </id> <cno> 331 </cno>