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.
eXtensible Markup Language                (XML)Serhii KartashovJuly 2012SoftServeIFDC IT Academy
AgendaIntroduction to XML   Basic rules     Parsing XML     XML Namespaces     XML Schemas   XSLT TransformationWhere is X...
AgendaIntroduction to XML   Basic rules     Parsing XML     XML Namespaces     XML Schemas   XSLT TransformationWhere is X...
Origin of XML                       SGML                       1986            HTML 1.0          XML 1.0              1992...
XML Data Model (a tree)1                       root2              title    item      item                        name     ...
AgendaIntroduction to XML   Basic rules     Parsing XML     XML Namespaces     XML Schemas   XSLT TransformationWhere is X...
Basic rules•   All XML Elements Must Have a Closing•   XML Tags are Case Sensitive•   XML Elements Must be Properly Nested...
AgendaIntroduction to XML   Basic rules     Parsing XML     XML Namespaces     XML Schemas   XSLT TransformationWhere is X...
Parsing XMLXML parser -- Reads in XML data, checks forsyntactic constraints, and makes data availableto an application. Th...
XML Parser Processing Model                  parser    XML-based       parser                interface   application
DOM APIs           DocumentBuilder               Factory                  Packages:                                       ...
SAX APIs           Packages:            org.xml.sax            org.xml.sax.ext            org.xml.sax.helpers          ...
AgendaIntroduction to XML   Basic rules     Parsing XML     XML Namespaces     XML Schemas   XSLT TransformationWhere is X...
Why namespaces?HTML:        <table>                   <tr>                           <td>Apples</td>                      ...
Namespaces handle conflicts between         element names.HTML:        <h:table xmlns:h="http://www.mysite.org/html>      ...
AgendaIntroduction to XML   Basic rules     Parsing XML     XML Namespaces     XML Schemas   XSLT TransformationWhere is X...
Defining language dialects• Two ways of doing so:   – XML Document Type Declaration (DTD)– Part of core XML     spec.   – ...
DTD<!ELEMENT root (title?, item*)><!ELEMENT title (#PCDATA)><!ELEMENT item (name, company, model, cost)><!ATTRIBUTE id (#P...
XML Schema<?xml version="1.0" encoding="ISO-8859-1" ?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element n...
XML Parser Processing Model With       Validation Schema                    parser    XML-based         parser            ...
AgendaIntroduction to XML   Basic rules     Parsing XML     XML Namespaces     XML Schemas   XSLT TransformationWhere is X...
XSLT TransformationXSLT (EXtensible Stylesheet LanguageTransformation):• <template>• <value-of>• <for-each>• <sort>• <if>•...
XML file<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="class.xsl"?><class>      <student>Jac...
XSL file<?xml version="1.0" ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">            <...
XSLT Transformation
AgendaIntroduction to XML   Basic rules     Parsing XML     XML Namespaces     XML Schemas   XSLT TransformationWhere is X...
Web Design and Applications• XML and CSS (example)@CHARSET "UTF-8";title{            display: block;            text-align...
XML Technology• XML Transformation• XML Schema• XSLT (eXtensible Stylesheet Language  Transformations)• MathML (Mathematic...
MathML (example)
Web of Services• HTTP (HyperText Transfer Protocol)• SOAP (Simple Object Access Protocol)• WSDL (Web Services Description ...
Web of Devices• Mobile Web• VXML (Voice XML)
Browsers and Authoring Tools•   Social networks•   Forums•   CMSs (Content Management System)•   RSS (Really Simple Syndic...
QuestionsandAnswers
Useful links• Introduction to XML   – http://www.itwriting.com/xmlintro.php   – The development history http://www.w3.org/...
Contacts• http://it-academy-sk.blogspot.com/                                       Thank you!
eXtensible Markup Language (XML)
Upcoming SlideShare
Loading in …5
×

eXtensible Markup Language (XML)

717 views

Published on

This presentation created for beginners what never hear about XML.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

eXtensible Markup Language (XML)

  1. 1. eXtensible Markup Language (XML)Serhii KartashovJuly 2012SoftServeIFDC IT Academy
  2. 2. AgendaIntroduction to XML Basic rules Parsing XML XML Namespaces XML Schemas XSLT TransformationWhere is XML applying? (examples)
  3. 3. AgendaIntroduction to XML Basic rules Parsing XML XML Namespaces XML Schemas XSLT TransformationWhere is XML applying? (examples)
  4. 4. Origin of XML SGML 1986 HTML 1.0 XML 1.0 1992 1998 HTML XHTML4.01 1999 1.0 2000 XHTML 2.0 2010
  5. 5. XML Data Model (a tree)1 root2 title item item name name company company3 model model cost cost
  6. 6. AgendaIntroduction to XML Basic rules Parsing XML XML Namespaces XML Schemas XSLT TransformationWhere is XML applying? (examples)
  7. 7. Basic rules• All XML Elements Must Have a Closing• XML Tags are Case Sensitive• XML Elements Must be Properly Nested• XML Attribute Values Must be Quoted• XML Documents Must Have a Root Element• Entity References• White-space is Preserved in XML
  8. 8. AgendaIntroduction to XML Basic rules Parsing XML XML Namespaces XML Schemas XSLT TransformationWhere is XML applying? (examples)
  9. 9. Parsing XMLXML parser -- Reads in XML data, checks forsyntactic constraints, and makes data availableto an application. There are three genericparser APIs – SAX Simple API to XML (event-based) – DOM Document Object Model (object/tree based)
  10. 10. XML Parser Processing Model parser XML-based parser interface application
  11. 11. DOM APIs DocumentBuilder Factory Packages:  org.w3c.dom  javax.xml.parsers Document Document (DocumentBuilderFactory, XML Builder (DOM) DocumentBuilder) READ  javax.xml.transform (TransformerFactory, Trans former, Source, Result) WRITE Transformer FactoryDocument Transformer (DOM) XML
  12. 12. SAX APIs Packages:  org.xml.sax  org.xml.sax.ext  org.xml.sax.helpers  javax.xml.parsers (SAXParserFactory, SAXParse r)
  13. 13. AgendaIntroduction to XML Basic rules Parsing XML XML Namespaces XML Schemas XSLT TransformationWhere is XML applying? (examples)
  14. 14. Why namespaces?HTML: <table> <tr> <td>Apples</td> <td>Bananas</td> </tr> We have the conflict </table> between two elements (table). And parserXML: doesn’t know how <table> handle this situation. <name>African Coffee Table</name> <width>80</width> <length>120</length> </table>
  15. 15. Namespaces handle conflicts between element names.HTML: <h:table xmlns:h="http://www.mysite.org/html> <h:tr> <h:td>Apples</h:td> <h:td>Bananas</h:td> We added name prefix to </h:tr> each element (table). And </h:table> declared they.XML: <x:table xmlns:x="http://www.mysite.org/xml> <x:name>African Coffee Table</x:name> <x:width>80</x:width> <x:length>120</x:length> </x:table>
  16. 16. AgendaIntroduction to XML Basic rules Parsing XML XML Namespaces XML Schemas XSLT TransformationWhere is XML applying? (examples)
  17. 17. Defining language dialects• Two ways of doing so: – XML Document Type Declaration (DTD)– Part of core XML spec. – XML Schema – allows for stronger constraints on XML documents.• Adding dialect specifications implies two classes of XML data: – Well-formed An XML document that is syntactically correct – Valid An XML document that is both well-formed and consistent with a specific DTD (or Schema)
  18. 18. DTD<!ELEMENT root (title?, item*)><!ELEMENT title (#PCDATA)><!ELEMENT item (name, company, model, cost)><!ATTRIBUTE id (#PCDATA)><!ELEMENT name (#PCDATA)><!ELEMENT company (#PCDATA)><!ELEMENT model (#PCDATA)><!ELEMENT cost (#PCDATA)>
  19. 19. XML Schema<?xml version="1.0" encoding="ISO-8859-1" ?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name=“root"> <xs:complexType> <xs:sequence> <xs:element name=“title" type="xs:string"/> <xs:element name=“item“ maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name=“name" type="xs:string"/> <xs:element name=“company" type="xs:string"/> <xs:element name="model" type="xs:string"/> <xs:element name="cost" type="xs:decimal"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name=“id" type="xs:positiveInteger " use="required"/> </xs:complexType></xs:element></xs:schema>
  20. 20. XML Parser Processing Model With Validation Schema parser XML-based parser interface application XML Schema
  21. 21. AgendaIntroduction to XML Basic rules Parsing XML XML Namespaces XML Schemas XSLT TransformationWhere is XML applying? (examples)
  22. 22. XSLT TransformationXSLT (EXtensible Stylesheet LanguageTransformation):• <template>• <value-of>• <for-each>• <sort>• <if>• <choose>
  23. 23. XML file<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="class.xsl"?><class> <student>Jack</student> <student>Harry</student> <student>Rebecca</student> <teacher>Mr. Bean</teacher></class>
  24. 24. XSL file<?xml version="1.0" ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="teacher"> <p><u><xsl:value-of select="."/></u></p> </xsl:template> <xsl:template match="student"> <p><b><xsl:value-of select="."/></b></p> </xsl:template> <xsl:template match="/"> <html> <body> <xsl:apply-templates/> </body> </html> </xsl:template></xsl:stylesheet>
  25. 25. XSLT Transformation
  26. 26. AgendaIntroduction to XML Basic rules Parsing XML XML Namespaces XML Schemas XSLT TransformationWhere is XML applying? (examples)
  27. 27. Web Design and Applications• XML and CSS (example)@CHARSET "UTF-8";title{ display: block; text-align: center; font-style: italic;}item:after{ font-size: 250%; content: attr(id);}item{ display: block; padding:20px; border-style: solid; font-size: 12px;}
  28. 28. XML Technology• XML Transformation• XML Schema• XSLT (eXtensible Stylesheet Language Transformations)• MathML (Mathematical Markup Language)
  29. 29. MathML (example)
  30. 30. Web of Services• HTTP (HyperText Transfer Protocol)• SOAP (Simple Object Access Protocol)• WSDL (Web Services Description Language)
  31. 31. Web of Devices• Mobile Web• VXML (Voice XML)
  32. 32. Browsers and Authoring Tools• Social networks• Forums• CMSs (Content Management System)• RSS (Really Simple Syndication)
  33. 33. QuestionsandAnswers
  34. 34. Useful links• Introduction to XML – http://www.itwriting.com/xmlintro.php – The development history http://www.w3.org/XML/hist2002• Basic rules – http://www.w3.org/TR/2006/REC-xml11-20060816/• XML Namespaces – http://www.w3.org/TR/REC-xml-names/• Defining language dialects – http://www.w3.org/TR/xhtml1/dtds.html – http://www.w3.org/TR/xmlschema-0/• Parsing XML – http://www.w3.org/DOM/DOMTR• XSLT Transformation – http://www.w3.org/TR/xslt
  35. 35. Contacts• http://it-academy-sk.blogspot.com/ Thank you!

×