introduction to xml
DESCRIPTION
This introduction is part of the DH101 course. Check dh101.chTRANSCRIPT
[STANDARD]
#DH101
XML
#DH101
What is XML and what is it good for ?
#DH101
XML stands for eXtensibile Markup Language
#DH101
To write in XMLyou write text with tags :
<atag> my text </atag>
#DH101
This can be done in any text editor.
#DH101
XML is a W3C recommandation.
#DH101
4 characteristics
#DH101
1. XML is used to describe data, not to display them. XML does nothing. It describes.
#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.
#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.
#DH101
4. XML is designed to be self-descriptive and “easily” readable. It is used to write “pivotal” descriptions in production chains.
#DH101
Genealogy of XML
#DH101
In the 50s, the !rst computers could not communicate with one another, if they were from di#erent brands.
#DH101
In the 60s, IBM creates GML (Generalized Markup Language) to enable data exchanges and make the data structure explicit.
#DH101
This is a great success. It becomes a standard : SGML(Standard Generalized Markup Language).The US fed gov. adopts it.
#DH101
In the 90s, Tim Berners-Lee at CERN creates the HTML language using a subset of SGML.
#DH101
HTML get specialized in displaying data but does not impose a standard way for describing data.
#DH101
A group of researchers imagines another language to do this.The !rst version of XML is ready in 1998.
#DH101
XML vs HTML
#DH101
XML is a markup language like HTML.
#DH101
XML is not a replacement of HTML. The two languages have di#erent goals.
#DH101
XML is for the transport and the description of structured data.
HTML is for the display and layout of data.
#DH101
XML does nothing.It just describes.
#DH101
XML is like a database in plain text.
#DH101
Structure of an XML !le
<TAG>Text</TAG>
XML Element
Opening tag Closing tagContent
<BOOK><TITLE>Da Vinci Code</TITLE><AUTHOR>Dan Brown</AUTHOR><YEAR>2003</YEAR></BOOK>
#DH101
With XML, you can create your own tags.
<BOOK><TITLE>Da Vinci Code</TITLE><AUTHOR>Dan Brown</AUTHOR><YEAR>2003</YEAR><STARS>4</STARS></BOOK>
#DH101
An XML !le starts with the version of XML used to describe the data and the text encoding format.
<?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
#DH101
An XML document is organized like a tree.
<BOOK> <FRONT> <TITLE>... </TITLE> <AUTHOR>...</AUTHOR> </FRONT> <BODY> <PART> <CHAPTER>...</CHAPTER> </PART> </BODY></BOOK>
#DH101
DTD
#DH101
A well-formed XML document follows the general rules of XML syntax.
#DH101
A valid XML document follows the speci!c rules written in a DTD (Document Type Description)
<!DOCTYPE BOOK[<!ELEMENT BOOK (TITLE,AUTHOR,YEAR)><!ELEMENT TITLE (#PCDATA)><!ELEMENT AUTHOR (#PCDATA)><!ELEMENT YEAR (#PCDATA)>]>
#DH101
To use a DTD is not mandatory.
#DH101
A DTD permits to agree on common XML dialect.
#DH101
Some software permit to check whether an XML !le is valid compared to a given DTD.
#DH101
Displaying XML
#DH101
The way an XML !le is displayed can be speci!ed in a CSS stylesheet.
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;}
<?xml-stylesheet type="text/css" href="book.css"?>
#DH101
A document can also be transformed using an XSLT script. This is now the recommended method
#DH101
XML >>
#DH101
XML permits to separate form from content by identifying structures reccurent to several documents.
XML
XML InDesignXSL-FO/PDF
XHTML
ePub
TXT
XML TEI / Doc Book
IndesignPaper / PDF ebook
websiteTabletWebappReaderSmartphone
MP3 player
Computer systems
SourceTransformation
EngineTarget Target
XSLT
#DH101
>> XML
Word
Database
Scanned document
Sensors
...
XML