Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to XML

2,326 views

Published on

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

Published in: Education
  • Be the first to comment

  • Be the first to like this

Introduction to XML

  1. 1. [STANDARD]XML #DH101
  2. 2. What is XML and what is it goodfor ? #DH101
  3. 3. XML stands for eXtensibileMarkup Language #DH101
  4. 4. To write in XMLyou write text with tags :<atag> my text </atag> #DH101
  5. 5. This can be done in any texteditor. #DH101
  6. 6. XML is a W3C recommandation. #DH101
  7. 7. 4characteristics #DH101
  8. 8. 1. XML is used to describe data,not to display them. XML doesnothing. It describes. #DH101
  9. 9. 2. XML tags are not prede!ned.You can de!ne your own tags.This gives you a lot of freedomto describe the structure youwant to describe. #DH101
  10. 10. 3. When you are satis!ed withyour structure, you can !x ourXML language by writing a DTD(Document Type Description).Thus, XML permits both "uidityand then rigor. #DH101
  11. 11. 4. XML is designed to be self-descriptive and “easily”readable. It is used to write“pivotal” descriptions inproduction chains. #DH101
  12. 12. Genealogy of XML #DH101
  13. 13. In the 50s, the !rst computerscould not communicate with oneanother, if they were fromdi#erent brands. #DH101
  14. 14. In the 60s, IBM creates GML(Generalized Markup Language)to enable data exchanges andmake the data structure explicit. #DH101
  15. 15. This is a great success. Itbecomes a standard : SGML(Standard Generalized MarkupLanguage).The US fed gov. adopts it. #DH101
  16. 16. In the 90s, Tim Berners-Lee atCERN creates the HTMLlanguage using a subset ofSGML. #DH101
  17. 17. HTML get specialized indisplaying data but does notimpose a standard way fordescribing data. #DH101
  18. 18. A group of researchers imaginesanother language to do this.The !rst version of XML isready in 1998. #DH101
  19. 19. XML vs HTML #DH101
  20. 20. XML is a markup language likeHTML. #DH101
  21. 21. XML is not a replacement ofHTML. The two languages havedi#erent goals. #DH101
  22. 22. XML is for the transport and thedescription of structured data.HTML is for the display andlayout of data. #DH101
  23. 23. XML does nothing.It just describes. #DH101
  24. 24. XML is like a database in plaintext. #DH101
  25. 25. Structure ofan XML !le #DH101
  26. 26. XML Element <TAG>Text</TAG>Opening tag Content Closing tag
  27. 27. <BOOK><TITLE>Da Vinci Code</TITLE><AUTHOR>Dan Brown</AUTHOR><YEAR>2003</YEAR></BOOK>
  28. 28. With XML, you can create yourown tags. #DH101
  29. 29. <BOOK><TITLE>Da Vinci Code</TITLE><AUTHOR>Dan Brown</AUTHOR><YEAR>2003</YEAR><STARS>4</STARS></BOOK>
  30. 30. An XML !le starts with theversion of XML used to describethe data and the text encodingformat. #DH101
  31. 31. <?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 Europeancharacter set
  32. 32. An XML document is organizedlike a tree. #DH101
  33. 33. <BOOK> <FRONT> <TITLE>... </TITLE> <AUTHOR>...</AUTHOR> </FRONT> <BODY>  <PART>    <CHAPTER>...</CHAPTER>  </PART> </BODY></BOOK>
  34. 34. DTD #DH101
  35. 35. A well-formed XML documentfollows the general rules ofXML syntax. #DH101
  36. 36. A valid XML document followsthe speci!c rules written in aDTD (Document TypeDescription) #DH101
  37. 37. <!DOCTYPE BOOK[<!ELEMENT BOOK(TITLE,AUTHOR,YEAR)><!ELEMENT TITLE (#PCDATA)><!ELEMENT AUTHOR (#PCDATA)><!ELEMENT YEAR (#PCDATA)>]>
  38. 38. To use a DTD is not mandatory. #DH101
  39. 39. A DTD permits to agree oncommon XML dialect. #DH101
  40. 40. Some software permit to checkwhether an XML !le is validcompared to a given DTD. #DH101
  41. 41. Displaying XML #DH101
  42. 42. The way an XML !le is displayedcan be speci!ed in a CSSstylesheet. #DH101
  43. 43. 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;}
  44. 44. <?xml-stylesheet type="text/css" href="book.css"?>
  45. 45. A document can also betransformed using an XSLTscript. This is now therecommended method #DH101
  46. 46. XML >> #DH101
  47. 47. XML permits to separate formfrom content by identifyingstructures reccurent to severaldocuments. #DH101
  48. 48. Transformation Target TargetSource Engine XML InDesign Indesign XSLT XSL-FO/PDF Paper / PDF ebook XHTML website XML Tablet ePub Webapp Reader Smartphone TXT MP3 player XML TEI / Doc Book Computer systems
  49. 49. >> XML #DH101
  50. 50. Word Database XMLScanned document Sensors ...

×