1 / 92

Introduction to XML

Integration & Interoperability. Tools. Data (XML). Web Services. Introduction to XML. Based on tutorials of B. Cormia, D. Suciu, H. Boley, S. Decker, M. Sintek, E. R. Harold and others.

gerda
Download Presentation

Introduction to XML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Integration & Interoperability Tools Data (XML) WebServices Introduction to XML Based on tutorials of B. Cormia, D. Suciu, H. Boley, S. Decker, M. Sintek, E. R. Harold and others

  2. Such Format, which Describes the Content of a Web Document Rather than the Way to Display it, is among the Basic Needs of the Intelligent Web Applications

  3. Introduction • XML is a text-based markup language that is fast becoming the standard for data interchange on the Web. • As HTML, XML uses tags. • But unlike HTML, XML tags identify the data, rather than specifying how to display it. • Where an HTML tag says something like "display this data in bold font" (<b>...</b>), an XML tag acts like a field name in your program. It puts a label on a piece of data that identifies it (for example: <message>...</message>).

  4. HTML vs. XML HTML tags: presentation, generic document structure <h1> Bibliography </h1> <p> <i> Foundations of DBs</i>, Abiteboul, Hull, Vianu <br> Addison-Wesley, 1995 <p> <i> Logics for DBs and ISs </i>, Chomicki, Saake,eds. <br> Kluwer, 1998 <biobliography> <book> <title> Foundations of DBs </title> <author> Abiteboul </author> <author> Hull </author> <author> Vianu </author> <publisher> Addison-Wesley </publisher> .... .</book> <book> ... <editor> Chomicki </editor>... </book> ... </bibliography> XML tags: content, "semantic", (DTD-) specific

  5. External Presentations from XML XML Markup: <address> <name>Xaver M. Linde</name> <street>Wikingerufer 7</street> <town>10555 Berlin</town> </address> XML XML stylesheets are, e.g., usable to generate different presentations External Presentations: Xaver M. Linde Wikingerufer 7 10555 Berlin Xaver M. Linde Wikingerufer 7 10555 Berlin . . .

  6. XML to XML Transformations XML Markup 1: <address> <name>Xaver M. Linde</name> <street>Wikingerufer 7</street> <town>10555 Berlin</town> </address> XML stylesheets are also usable to transform XML representations XML XML Markup 2: <address> <name>Xaver M. Linde</name> <place> <street>Wikingerufer 7</street> <town>10555 Berlin</town> </place> </address>

  7. XML Queries XML Markup: subelements element <address> <name>Xaver M. Linde</name> <street>Wikingerufer 7</street> <town>10555 Berlin</town> </address> s XML Query (XML-QL): WHERE <address> <name>Xaver M. Linde</name> <street>$s</street> <town>$t</town> </address> CONSTRUCT <binding> <s>$s</s> <t>$t</t> </binding> XML XML queries can select subelements of XML elements <binding> <s>Wikingerufer 7</s> <t>10555 Berlin</t> </binding>

  8. PART_OF and HAS_PART Example HAS_PART flat kitchen PART_OF flat Examples HAS_PART kitchen PART_OF

  9. XML <FLAT> kitchen </FLAT> Examples

  10. Role of an Object to be place for making food in flat kitchen flat Examples to be place for making food in kitchen

  11. XML <FLAT> <PLACE FOR MAKING FOOD> kitchen </PLACE FOR MAKING FOOD> </FLAT> Examples

  12. Multi-Roles Object University of Kharkov to be Head of Exchange Programs to be Member of Council Examples to be Head of Research Lab. to be Head of Department Vagan to be a lecturer

  13. XML (1) <UNIVERSITY OF KHARKOV> <MEMBER OF COUNCIL> Vagan </MEMBER OF COUNCIL> <HEAD OF EXCHANGE PROGRAM> Vagan </HEAD OF EXCHANGE PROGRAM> <HEAD OF DEPARTMENT> Vagan </HEAD OF DEPARTMENT> <HEAD OF RESEARCH LAB> Vagan </ HEAD OF RESEARCH LAB> <LECTURER> Vagan </LECTURER> </UNIVERSITY OF KHARKOV> Examples

  14. XML (2) <VAGAN> <ROLES IN UNIVERSITY OF KHARKOV> <ROLE 1> Member of Council </ROLE 1> <ROLE 2> Head of Exchange Program </ROLE 2> <ROLE 3> Head of Department </ROLE 3> <ROLE 4> Head of Research Lab </ROLE 4> <ROLE 5> Lecturer </ROLE 5> </ROLES IN UNIVERSITY OF KHARKOV> </VAGAN> Examples

  15. XML (3) <UNIVERSITY OF KHARKOV> <ROLE type = “MEMBER OF COUNCIL”> Vagan </ROLE> <ROLE type = “HEAD OF EXCHANGE PROGRAM”> Vagan </ROLE> <ROLE type = “HEAD OF DEPARTMENT”> Vagan </ROLE> <ROLE type = “HEAD OF RESEARCH LAB”> Vagan </ROLE> <ROLE type = “LECTURER”> Vagan </ROLE> </UNIVERSITY OF KHARKOV> Examples

  16. Multi-Contextual Role of Object University of Jyvaskyla University of Kharkov to be Head of AI Department Vagan to be a lecturer Examples

  17. XML (1) <VAGAN> <ROLE IN UNIVERSITY OF KHARKOV> Head of Department </ROLE IN UNIVERSITY OF KHARKOV> <ROLE IN UNIVERSITY OF JYVASKYLA> Lecturer </ROLE IN UNIVERSITY OF JYVASKYLA > </VAGAN> Examples

  18. XML (2) <VAGAN> <ROLE place = “UNIVERSITY OF KHARKOV”> Head of Department </ROLE> <ROLE place = “UNIVERSITY OF JYVASKYLA” > Lecturer </ROLE> </VAGAN> Examples

  19. Multilevel Context Roles Ukraine ... citizen Kharkov University ... employer Examples AI Department ... Head Vagan

  20. XML Not enough <COUNTRY> <NAME> Ukraine </NAME> <LEADING UNIVERSITY> <NAME> Kharkov University </NAME> <BEST DEPARTMENT> <NAME> AI Department </NAME> <HEAD> <NAME> Vagan </NAME> </HEAD> </BEST DEPARTMENT> </LEADING UNIVERSITY> </COUNTRY> Examples

  21. Contents • XML Specification • Document Type Definitions • Cascading Style Sheets • Querying XML

  22. XML Specification

  23. Elements, Attributes, and Values • XML uses the same building blocks as HTML, elements, attributes, and values • Elements contain attributes • Attributes contain values • Values contained in quotations (“ ”)

  24. Simple XML Element (no attributes) closing tag opening tag content of the element <position>professor</position> name of the element name of the element

  25. Simple XML Element <position>professor</position> is equivalent to <position> professor </position> is different with <diagnosis> professor </diagnosis>

  26. XML Element with Attribute content of the element opening tag closing tag <position place=“university”>professor</position> name of the element name of the element value of the attribute attribute of the element

  27. XML Element with Two Attributes <position place=“university” type=“teaching”> professor </position>

  28. XML Element with Two Attributes <position place=“university” type=“teaching”> professor </position> is similar but not equivalent to <position> <name>professor</name> <place>university</place> <type>teaching</type> </position>

  29. Do Not Forget to Put Quotations … place=“university”... quotations are obligatory around the value of an attribute

  30. Nominal vs. Numerical Attributes <price currency=“Euro”> 49.90 </price> <constant value=“3.14”> </constant >

  31. Empty Element opening and closing tags are merged together <position/> name of the element is equivalent to <position></position>

  32. Empty Element with Attribute <picture location=“/images/blueball.gif”/> is equivalent to <picture location=“/images/blueball.gif”></picture>

  33. Tags Must be Nested Correctly <department> <head> vagan </head> </department> <department> <head> vagan </department> </head>

  34. Case Matters <department> Artificial Intelligence </department> <Department> Artificial Intelligence </department> is not the same as <Department> Artificial Intelligence </Department>

  35. A Root Element is Required <CS_Faculty> <department> Artificial Intelligence </department> <department> Information Systems </department> </CS_Faculty> <department> Artificial Intelligence </department> <department> Information Systems </department>

  36. Writing five special symbols • To write the five special symbols: • Type &amp for ampersand (&) • Type &lt for the less than sign (<) • Type &gt for the greater than sign (>) • Type &quot to create a double quote (“) • Type &apos to create an apostrophe (‘)

  37. Declaring the XML Version • At the very beginning of the document type: <?xml • Then type: version=“1.0” • Type: ?> <?xml version=“1.0” ?>

  38. Declaring the XML VersionObligatory and Optional Attributes obligatory <?xmlversion=“number” [encoding=“encoding”] [standalone=“yes|no”] ?> optional optional

  39. Encoding Attribute <?xml version=“1.0” encoding=“US-ASCII” ?>

  40. Encoding Attribute Values US-ASCII US-ASCII is a 7-bit encoding scheme that covers the English-language alphabet. UTF-8 UTF-8 is an 8-bit encoding scheme. Characters from the English-language alphabet are all encoded using an 8-bit bytes. Characters for other languages are encoding using 2, 3 or even 4 bytes. UTF-8 therefore produces compact documents for the English language, but very large documents for other languages. UTF-16 UTF-16 is a 16-bit encoding scheme. It is large enough to encode all the characters from all the alphabets in the world, with the exception of ideogram-based languages like Chinese. All characters in UTF-16 are encoded using 2 bytes. An English-language document that uses UTF-16 will be twice as large as the same document encoded using UTF-8. Documents written in other languages, however, will be far smaller using UTF-16.

  41. Standalone Attribute DTD (Document Type Definition) is a file which describes the elements and attributes that may appear in the XML document and used to check its syntactical structure The optional standalone attribute in XML declaration specifies whether a DTD is required to parse the document. The value must be “yes” or “no”. <?xml version=“1.0” standalone=“yes” ?> An outside DTD is not needed <?xml version=“1.0” standalone=“no” ?> An outside DTD is needed to correctly interpret the XML document

  42. Writing comments • To write comments: • Type <!-- • Write the desired comments • Type --> <!-- This is a comment -->

  43. Namespaces • Namespaces are a recent addition to the XML specification. The use of namespaces is not mandatory in XML, but it's often wise. • Namespaces were created to ensure uniqueness among XML elements.

  44. Namespaces Attribute - XML namespace Value - namespace identifier (URL) element <CS_Faculty xmlns= ‘http://www.academic.com’> … </CS_Faculty> area of validity of the namespace

  45. Namespace Prefix Namespace prefix <stockxmlns:edi='http://ecommerce.org/schema'> <!-- the 'price' element's namespace is http://ecommerce.org/schema --> < edi :price units='Euro'>32.18</edi:price> ... </ stock >

  46. Document Type Definitions

  47. Document type definitions • A DTD specifies how elements inside an XML document should relate to each other • It also provides grammar rules for the document and each of the elements • A document that fits to the XML specifications and rules outlined by its DTD is considered to be “valid” • (Not to be confused with a well-formed document, which adheres to XML syntax rules

  48. Declaring DTD in XML Document Denotes that DTD resides in a separate local file root element in XML file file with DTD keyword <!DOCTYPE CS_Faculty SYSTEM “faculty.dtd”>

  49. Declaring DTD in XML Document <?xml version=“1.0” standalone=“no” ?> <!DOCTYPE CS_Faculty SYSTEM “faculty.dtd”> <!-- Here begins the XML data --> <CS_Faculty> <department> Artificial Intelligence </department> <department> Information Systems </department> </CS_Faculty>

  50. Declaring an internal DTD • At the top of the XML document, after the XML declaration, type: <! DOCTYPEroot[ where root corresponds to the name of the root element in the document that the DTD will be applied to. Type:]>to complete the DTD.

More Related