introduction to xml

50
[STANDARD] #DH101 XML

Upload: frederic-kaplan

Post on 06-May-2015

1.295 views

Category:

Education


0 download

DESCRIPTION

This introduction is part of the DH101 course. Check dh101.ch

TRANSCRIPT

Page 1: Introduction to XML

[STANDARD]

#DH101

XML

Page 2: Introduction to XML

#DH101

What is XML and what is it good for ?

Page 3: Introduction to XML

#DH101

XML stands for eXtensibile Markup Language

Page 4: Introduction to XML

#DH101

To write in XMLyou write text with tags :

<atag> my text </atag>

Page 5: Introduction to XML

#DH101

This can be done in any text editor.

Page 6: Introduction to XML

#DH101

XML is a W3C recommandation.

Page 7: Introduction to XML

#DH101

4 characteristics

Page 8: Introduction to XML

#DH101

1. XML is used to describe data, not to display them. XML does nothing. It describes.

Page 9: Introduction to XML

#DH101

2. XML tags are not prede!ned.You can de!ne your own tags. This gives you a lot of freedom to describe the structure you want to describe.

Page 10: Introduction to XML

#DH101

3. When you are satis!ed with your structure, you can !x our XML language by writing a DTD (Document Type Description). Thus, XML permits both "uidity and then rigor.

Page 11: Introduction to XML

#DH101

4. XML is designed to be self-descriptive and “easily” readable. It is used to write “pivotal” descriptions in production chains.

Page 12: Introduction to XML

#DH101

Genealogy of XML

Page 13: Introduction to XML

#DH101

In the 50s, the !rst computers could not communicate with one another, if they were from di#erent brands.

Page 14: Introduction to XML

#DH101

In the 60s, IBM creates GML (Generalized Markup Language) to enable data exchanges and make the data structure explicit.

Page 15: Introduction to XML

#DH101

This is a great success. It becomes a standard : SGML(Standard Generalized Markup Language).The US fed gov. adopts it.

Page 16: Introduction to XML

#DH101

In the 90s, Tim Berners-Lee at CERN creates the HTML language using a subset of SGML.

Page 17: Introduction to XML

#DH101

HTML get specialized in displaying data but does not impose a standard way for describing data.

Page 18: Introduction to XML

#DH101

A group of researchers imagines another language to do this.The !rst version of XML is ready in 1998.

Page 19: Introduction to XML

#DH101

XML vs HTML

Page 20: Introduction to XML

#DH101

XML is a markup language like HTML.

Page 21: Introduction to XML

#DH101

XML is not a replacement of HTML. The two languages have di#erent goals.

Page 22: Introduction to XML

#DH101

XML is for the transport and the description of structured data.

HTML is for the display and layout of data.

Page 23: Introduction to XML

#DH101

XML does nothing.It just describes.

Page 24: Introduction to XML

#DH101

XML is like a database in plain text.

Page 25: Introduction to XML

#DH101

Structure of an XML !le

Page 26: Introduction to XML

<TAG>Text</TAG>

XML Element

Opening tag Closing tagContent

Page 27: Introduction to XML

<BOOK><TITLE>Da Vinci Code</TITLE><AUTHOR>Dan Brown</AUTHOR><YEAR>2003</YEAR></BOOK>

Page 28: Introduction to XML

#DH101

With XML, you can create your own tags.

Page 29: Introduction to XML

<BOOK><TITLE>Da Vinci Code</TITLE><AUTHOR>Dan Brown</AUTHOR><YEAR>2003</YEAR><STARS>4</STARS></BOOK>

Page 30: Introduction to XML

#DH101

An XML !le starts with the version of XML used to describe the data and the text encoding format.

Page 31: Introduction to XML

<?xml version="1.0" encoding="ISO-8859-1"?><BOOK><TITLE>Da Vinci Code</TITLE><AUTHOR>Dan Brown</AUTHOR><YEAR>2003</YEAR></BOOK>

ISO-8859-1 = Latin-1/West European character set

Page 32: Introduction to XML

#DH101

An XML document is organized like a tree.

Page 33: Introduction to XML

<BOOK> <FRONT> <TITLE>... </TITLE> <AUTHOR>...</AUTHOR> </FRONT> <BODY>  <PART>    <CHAPTER>...</CHAPTER>  </PART> </BODY></BOOK>

Page 34: Introduction to XML

#DH101

DTD

Page 35: Introduction to XML

#DH101

A well-formed XML document follows the general rules of XML syntax.

Page 36: Introduction to XML

#DH101

A valid XML document follows the speci!c rules written in a DTD (Document Type Description)

Page 37: Introduction to XML

<!DOCTYPE BOOK[<!ELEMENT BOOK (TITLE,AUTHOR,YEAR)><!ELEMENT TITLE (#PCDATA)><!ELEMENT AUTHOR (#PCDATA)><!ELEMENT YEAR (#PCDATA)>]>

Page 38: Introduction to XML

#DH101

To use a DTD is not mandatory.

Page 39: Introduction to XML

#DH101

A DTD permits to agree on common XML dialect.

Page 40: Introduction to XML

#DH101

Some software permit to check whether an XML !le is valid compared to a given DTD.

Page 41: Introduction to XML

#DH101

Displaying XML

Page 42: Introduction to XML

#DH101

The way an XML !le is displayed can be speci!ed in a CSS stylesheet.

Page 43: Introduction to XML

BOOK{display: block;margin-bottom: 30pt;margin-left: 0;}TITLE{display: block;color: #FF0000;font-size: 40pt;margin-left: 20pt;}AUTHOR{display: block;color: #0000FF;font-size: 30pt;margin-left: 20pt;}YEAR{display: block;color: #000000;font-size: 30pt;margin-left: 20pt;}

Page 44: Introduction to XML

<?xml-stylesheet type="text/css" href="book.css"?>

Page 45: Introduction to XML

#DH101

A document can also be transformed using an XSLT script. This is now the recommended method

Page 46: Introduction to XML

#DH101

XML >>

Page 47: Introduction to XML

#DH101

XML permits to separate form from content by identifying structures reccurent to several documents.

Page 48: Introduction to XML

XML

XML InDesignXSL-FO/PDF

XHTML

ePub

TXT

XML TEI / Doc Book

IndesignPaper / PDF ebook

websiteTabletWebappReaderSmartphone

MP3 player

Computer systems

SourceTransformation

EngineTarget Target

XSLT

Page 49: Introduction to XML

#DH101

>> XML

Page 50: Introduction to XML

Word

Database

Scanned document

Sensors

...

XML