XML
-
Upload
bernard-ellison -
Category
Documents
-
view
51 -
download
0
description
Transcript of XML
XML Agenda
<?xml version=“1.0”?>
<presentation>
<agenda>
<item>The Problem of Data</item>
<item>What is XML?</item>
<item>Extensions of XML</item>
<item>Practical Applications</item>
</agenda>
</presentation>
The Problem of Data
How do you store or send data in your application?
Document Storage ex. Word, Excel, HTML, etc.
Configuration Files Remote Procedure Calls
The Problem of Data
Proprietary formats Reinventing the wheel
Rewrite (and debug) parsers Document format for others
What is XML?
Extensible Markup Language Derived from SGML
W3C Standard (1998) A standard format for all types of
computer documents Human readable format
Always text, never binary data
What is XML?
Data is strings of text and delimited by tags
XML doesn’t define the tags! Makes it a meta-markup language Flexibility
XML does define what the tags look like and how they can be organized
What is XML?
<?xml version=“1.0”?>
<!-- class information data -->
<classRoster course=“COT4810” section=“2”>
<teacher>Dutton</teacher>
<student>Wilson</student>
<student>Doe</student>
<testdate></testdate>
<testdate/>
</classRoster>
Tags
<?xml version=“1.0”?>
<!-- class information data -->
<classRoster course=“COT4810” section=“2”>
<teacher>Dutton</teacher>
<student>Wilson</student>
<student>Doe</student>
<testdate></testdate>
<testdate/>
</classRoster>
Start Tags
<?xml version=“1.0”?>
<!-- class information data -->
<classRoster course=“COT4810” section=“2”><teacher>Dutton</teacher><student>Wilson</student><student>Doe</student><testdate></testdate>
<testdate/></classRoster>
End Tags
<?xml version=“1.0”?>
<!-- class information data -->
<classRoster course=“COT4810” section=“2”>
<teacher>Dutton</teacher>
<student>Wilson</student>
<student>Doe</student>
<testdate></testdate>
<testdate/>
</classRoster>
Attributes
<?xml version=“1.0”?>
<!-- class information data -->
<classRoster course=“COT4810” section=“2”><teacher>Dutton</teacher>
<student>Wilson</student>
<student>Doe</student>
<testdate></testdate>
<testdate/>
</classRoster>
Processing Instructions
<?xml version=“1.0”?><!-- class information data -->
<classRoster course=“COT4810” section=“2”>
<teacher>Dutton</teacher>
<student>Wilson</student>
<student>Doe</student>
<testdate></testdate>
<testdate/>
</classRoster>
Comments
<?xml version=“1.0”?>
<!-- class information data --><classRoster course=“COT4810” section=“2”>
<teacher>Dutton</teacher>
<student>Wilson</student>
<student>Doe</student>
<testdate></testdate>
<testdate/>
</classRoster>
What is XML?
You define the tags to use XML Application
XML Application “Grammar” can be formally defined in: DTD (Document Type Definition) XML Schema
What can XML do?
Document Storage ex. Open Office
Books/Technical Documents Remote Procedure Calls Vector Graphics Slices, Dices, and makes Julian Fries!
What XML is Not Programming Language
Doesn’t do anything Network-Transport Protocol “XML is a structural and semantic
markup language, not a presentation language”(XML in a Nutshell p.4)
Not like HTML Database
XML can be stored in a database Database could save its data in XML
Using XML Lots of XML parsers available
Don’t have to write your own! Standards for Parsers
DOM – Document Object Model Creates XML Tree Reads in whole document before
processing Read/Write
SAX Processes XML as it is read Read-only
DOM – XML Tree<student> <name>Ryan Wilson</name> <major>Computer Science</major></student>
Root
student
Ryan Wilson
majorname
Computer Science
Extensions to XML
XSLT Extensible Stylesheet Language
Transformations Convert an XML document into
another document ex. XML document into a web
page
<book title=“LoTR: The Two Towers”>
<chapter title=“The Departure of Boromir”>
Aragorn sped up the hill…
</chapter>
<chapter title=“The Riders of Rohan”>
Dusk deepened. Mist lay behind them…
</chapter>
<chapter title=“The Uruk-Hai”>
Pippin lay in a dark and troubled dream…
</chapter>
</book>
<html>
<head>
<title>LoTR: The Two Towers</title>
</head>
<body>
<h1>Table of Contents</h1>
<ol>
<li>The Departure of Boromir</li>
<li>The Riders of Rohan</li>
<li>The Uruk-Hai</li>
</ol>
</body>
</html>
Extensions to XML
Presentation XML or “Making your XML Look Pretty”
CSSCascading Style Sheets Already used for web pages Describes how to display XML
XSL-FOXSL Formatting Objects Use XSLT to turn into XSL-FO
Practical Applicationsor “Why CS Students should care about XML”
Web publishing frameworks www.gentoo.org ex. Apache’s Cocoon
Configuration Files ex. Gconf
Remote Procedure Calls (RPC) XML-RPC SOAP –
Simple Object Access Protocol