930 likes | 1.04k Views
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.
E N D
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
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
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>).
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
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 . . .
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>
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>
PART_OF and HAS_PART Example HAS_PART flat kitchen PART_OF flat Examples HAS_PART kitchen PART_OF
XML <FLAT> kitchen </FLAT> Examples
Role of an Object to be place for making food in flat kitchen flat Examples to be place for making food in kitchen
XML <FLAT> <PLACE FOR MAKING FOOD> kitchen </PLACE FOR MAKING FOOD> </FLAT> Examples
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
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
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
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
Multi-Contextual Role of Object University of Jyvaskyla University of Kharkov to be Head of AI Department Vagan to be a lecturer Examples
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
XML (2) <VAGAN> <ROLE place = “UNIVERSITY OF KHARKOV”> Head of Department </ROLE> <ROLE place = “UNIVERSITY OF JYVASKYLA” > Lecturer </ROLE> </VAGAN> Examples
Multilevel Context Roles Ukraine ... citizen Kharkov University ... employer Examples AI Department ... Head Vagan
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
Contents • XML Specification • Document Type Definitions • Cascading Style Sheets • Querying XML
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 (“ ”)
Simple XML Element (no attributes) closing tag opening tag content of the element <position>professor</position> name of the element name of the element
Simple XML Element <position>professor</position> is equivalent to <position> professor </position> is different with <diagnosis> professor </diagnosis>
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
XML Element with Two Attributes <position place=“university” type=“teaching”> professor </position>
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>
Do Not Forget to Put Quotations … place=“university”... quotations are obligatory around the value of an attribute
Nominal vs. Numerical Attributes <price currency=“Euro”> 49.90 </price> <constant value=“3.14”> </constant >
Empty Element opening and closing tags are merged together <position/> name of the element is equivalent to <position></position>
Empty Element with Attribute <picture location=“/images/blueball.gif”/> is equivalent to <picture location=“/images/blueball.gif”></picture>
Tags Must be Nested Correctly <department> <head> vagan </head> </department> <department> <head> vagan </department> </head>
Case Matters <department> Artificial Intelligence </department> <Department> Artificial Intelligence </department> is not the same as <Department> Artificial Intelligence </Department>
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>
Writing five special symbols • To write the five special symbols: • Type & for ampersand (&) • Type < for the less than sign (<) • Type > for the greater than sign (>) • Type " to create a double quote (“) • Type &apos to create an apostrophe (‘)
Declaring the XML Version • At the very beginning of the document type: <?xml • Then type: version=“1.0” • Type: ?> <?xml version=“1.0” ?>
Declaring the XML VersionObligatory and Optional Attributes obligatory <?xmlversion=“number” [encoding=“encoding”] [standalone=“yes|no”] ?> optional optional
Encoding Attribute <?xml version=“1.0” encoding=“US-ASCII” ?>
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.
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
Writing comments • To write comments: • Type <!-- • Write the desired comments • Type --> <!-- This is a comment -->
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.
Namespaces Attribute - XML namespace Value - namespace identifier (URL) element <CS_Faculty xmlns= ‘http://www.academic.com’> … </CS_Faculty> area of validity of the namespace
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 >
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
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”>
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>
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.