xml

22
XML XML XML XML What XML is and what it means to me as a Computer Scientist By: Derek Edwards CS 376 March 10, 2003

Upload: margaret-castillo

Post on 30-Dec-2015

21 views

Category:

Documents


2 download

DESCRIPTION

What XML is and what it means to me as a Computer Scientist. By: Derek Edwards CS 376 March 10, 2003. XML. Overview. What is XML XML & HTML What does XML do Uses of XML XML & HTML Example XML Syntax Displaying XML Data Binding. XML stands for:. X tensible M arkup L anguage. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: XML

XMLXML

XMLXML

What XML is and what it means

to me as aComputer Scientist

By: Derek EdwardsCS 376

March 10, 2003

Page 2: XML

XMLXML

OverviewOverview

• What is XML• XML & HTML• What does XML do• Uses of XML• XML & HTML Example• XML Syntax• Displaying XML• Data Binding

Page 3: XML

XMLXML

What is XML?What is XML?

• XML stands for:

Xtensible

Markup

Language

Page 4: XML

XMLXML

What is XML?What is XML?

• Very similar to HTML• Designed to describe data• No predefined tags like in HTML• Uses a Document Type Definition

(DTD) or an XML Schema to describe data

Page 5: XML

XMLXML

XML & HTMLXML & HTML

• XML describes data

• HTML displays data

Page 6: XML

XMLXML

What does XML do?What does XML do?

• Nothing.• XML is just a structure that stores

data

Page 7: XML

XMLXML

Uses of XMLUses of XML

• Shares Data– Data is stored in a plain text format.– Lets different applications access

the same information

Page 8: XML

XMLXML

Uses of XMLUses of XML

• Stores data– Used widely in database systems

and file systems to store data– Applications can then be written to

retrieve the stored data– Another application can then display

the text in a certain way

Page 9: XML

XMLXML

Uses of XMLUses of XML

• Creates new languages– WML (wireless markup language) is

written in XML

Page 10: XML

XMLXML

Simple HTML fileSimple HTML file

<html><head>

<title>note</title></head><body>

<p>To: John<p>From: Frank<p>Subject: Reminder<p>Message: Don’t forget the money you owe me

</body></html>

Click here for online file

Page 11: XML

XMLXML

Same file in XMLSame file in XML

<?xml version=“1.0” encoding=“ISO-8859-1”?><note><to>John</to><from>Frank</from><subject>Reminder</subject><msg>Don’t forget the money you owe me </msg></note>

Click here for online file

Page 12: XML

XMLXML

XML File Line by LineXML File Line by Line

<?xml version=“1.0” encoding=“ISO-8859-1”?><note><to>John</to><from>Frank</from><subject>Reminder</subject><msg>Don’t forget the money you owe me </msg></note>_______________________________________________

• XML declaration line, defines version and the character type

• Same as: <html> · · · · · </html>

Page 13: XML

XMLXML

XML File Line by LineXML File Line by Line

<?xml version=“1.0” encoding=“ISO-8859-1”?><note><to>John</to><from>Frank</from><subject>Reminder</subject><msg>Don’t forget the money you owe me </msg></note>_______________________________________________

• Describes the root element in the file• “This document is a note”• Same as: <body> · · · · · </body>

Page 14: XML

XMLXML

XML File Line by LineXML File Line by Line

<?xml version=“1.0” encoding=“ISO-8859-1”?><note><to>John</to><from>Frank</from><subject>Reminder</subject><msg>Don’t forget the money you owe me </msg></note>_______________________________________________

• The child elements in the file• Same as: <p> · · · · · </p>

Page 15: XML

XMLXML

XML SyntaxXML Syntax

• All XML tags must have opening and closing tags

• All tags are case sensitive

HTML<p>This is paragraph 1…<P>This is paragraph 2...XML<p>This is paragraph 1...</p><P>This is paragraph 2...</P>

Page 16: XML

XMLXML

XML SyntaxXML Syntax

• All XML tags must be nested properly

HTML<b><I>This is bold & italic</b></I>XML<b><I>This is bold & italic</I></b>

Page 17: XML

XMLXML

XML SyntaxXML Syntax

• Only one root element allowed<note><to>John</to><from>Frank</from><subject>Reminder</subject><msg>Don’t forget the money you owe me </msg></note><note> · ·</note>

Page 18: XML

XMLXML

Another XML ExampleAnother XML Example

<CATALOG> <CD>

<TITLE>Empire Burlesque</TITLE>

<ARTIST>Bob Dylan</ARTIST>

<COUNTRY>USA</COUNTRY>

<COMPANY>Columbia</COMPANY>

<PRICE>10.90</PRICE>

<YEAR>1985</YEAR>

</CD>

<CD>Click for cd.xml

Page 19: XML

XMLXML

Displaying XMLDisplaying XML

• Can be displayed using a Cascading Stylesheet

• Preferred method is to use Extensible Stylesheet Language (XSL)

Click for online CSS fileClick for CD database with CSS file

Page 20: XML

XMLXML

Data Binding in XMLData Binding in XML

• “Data Islands” can be bound to HTML elements (like HTML Tables)

<html><body>

<xml id="cdcat" src="cd.xml"></xml><table border="1" datasrc="#cdcat"><tr>

<td><span datafld="ARTIST"></span></td><td><span datafld="TITLE"></span></td>

</tr></table>

</body></html>Click for online version

Page 21: XML

XMLXML

Displaying XML AgainDisplaying XML Again

• Endless ways to display XML• CD Database Example using <THEAD> and

<TFOOT> tags• Another rendering of the CD Database• CD Database using form elements and

JavaScript• Simple application for the CD Database

Using <THEAD> and <TFOOT>Full Rendering in TableUsing Form ButtonsSimple Application

Page 22: XML

XMLXML

XMLXML

• Very versatile• Code is completely customizable• Display is completely customizable• Becoming widely used• Becoming more and more important• Must have at least an understanding about it