Presentation is loading. Please wait.

Presentation is loading. Please wait.

Web Services: Principles & Technology Slide 3.1 Chapter 3 Brief Overview of XML COMP 4302/6302.

Similar presentations


Presentation on theme: "Web Services: Principles & Technology Slide 3.1 Chapter 3 Brief Overview of XML COMP 4302/6302."— Presentation transcript:

1

2 Web Services: Principles & Technology Slide 3.1 Chapter 3 Brief Overview of XML COMP 4302/6302

3 Slide 3.2 Topics XML document structure XML document structure XML schemas reuseXML schemas reuse

4 Slide 3.3 Markup  A method of distinguishing text from instructions in typesetting systems.  Markup = instructions to computerized typesetting systems (Latex).  Special characters ( ) are used to show where a markup instruction starts and stops. Example: This is a very serious matter. This is a very serious matter. “Tags” are easily understandable by both the human reader and the machine.

5 Slide 3.4 XML Extensible Markup Language (XML) is not a set of tags itself but a meta-language that allows you to create and use tag sets in a standard way. Provides fixed rules about markup structures (elements, attributes, and entities) as well as their notations and functions.

6 Slide 3.5 Book Catalog in XML Web Services: Principles and Technology Mike P. Papazoglou 2007 Prentice Hall This document has XML tags. A human and a computer can now easily extract the publisher data. Question: Who provides/defines these tags?

7 Slide 3.6 XML structure Document type: XML documents are regarded as having types. –XML’s constituent parts and their structure formally define the type of a document. An XML document is composed of named containers and their contained data values. –containers are represented as declarations, elements, and attributes. An XML document is also known as an instance or XML document instance to signify that it represents one possible set of data for a particular markup language. Right Plastic Products 2002-09-15 158 Edward st. Brisbane QLD 4000 Example of an XML document instance.

8 Slide 3.7 Layout of a typical XML document

9 Slide 3.8 XML: Elements Elements are fundamental units of content comprising element name and element content. –An element is a sequence of characters that begins with a start tag and ends with an end tag and includes everything in between. Text for Chapter 1 What is content? The characters in between the tags constitute the content. The topmost element of the XML document is a single element known as the root element. Elements contained in other elements are referred to as nested elements. –The containing element is the parent element and the nested element is called the child element.

10 Slide 3.9 XML: Attributes Another way of putting data into an XML document is by adding attributes to start tags. –An attribute specification is a name–value pair that is associated with an element. –Attributes are used to better specify the content of an element on which they appear by adding information about a defined element. customer-type=”manufacturer” Right Plastic Products 2002-09-15 158 Edward st. Brisbane QLD 4000

11 Slide 3.10 One Special Attribute: XML Namespace Namespaces in XML provide a facility for Associating the elements and/or attributes in all or part of a document with a particular schema Avoiding name clashes Namespace declarations have a scope. –A namespace declaration is in scope for the element on which it is declared and of that element’s children. The namespace name and the local name of the element together form a globally unique name known as a qualified name (QName). <BillingInformation customer-type=”manufacturer” xmlns="http://www.plastics_supply.com/BillInfo"> Right Plastic Products 158 Edward St. Brisbane QLD 4000 2002-09-15 Uniform resource identifier (URI)

12 Slide 3.11 XML: structure An XML document must have a root tag. An XML document is an information unit that can be seen in two ways: –As a linear sequence of characters that contain characters data and markup. –As an abstract data structure that is a tree of nodes. Title 1 Section 1.1 …. Section 1.2 Title 2 Section 2.1 …. Linear sequence Book Chapter Section Para Tree Section

13 Slide 3.12 XML Quiz  Use all elements/attributes you deem necessary to develop an XML document instance to describe –a student record –a course description –a bank account –a local restaurant

14 Slide 3.13 XML Schema XML schema refers to a document that defines the content of and structure for expressing XML documents. Schemas provide support for additional meta-data characteristics such as structural relationships, cardinality, valid values, and data types. Each type of schema acts as a method of describing data characteristics and applying rules and constraints to a referencing XML document. An XML schema describes the elements and attributes that may be contained in a schema-conforming document and the ways that the elements may be arranged within a document structure.

15 Slide 3.14 File “Person.xml” File “Person.xsd” Sophie Jones 34 <xsd:element name="Last“ type="xsd:string"/> XML schema and instance document xmlns:xsd="http://www.w3.org/2001/XMLSchema" Standard schema namespace defined by the XML schema specification Define a named namespace QName: namespace:element

16 Slide 3.15 Elements and their content model One item of a purchase order with its details Needs to be specified in US$ Schema Components

17 Slide 3.16 Attributes and Attribute Groups Schema Components (continued)

18 Slide 3.17 Complex Types Schema Components (continued) Define a complex data type “PersonType” Define an element “Person” of type “PersonType” Schema reuse

19 Slide 3.18 Topics XML document structure XML document structure XML schemas reuseXML schemas reuse

20 Slide 3.19 Complex type extensions (inheritance) <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:PO="http://www.plastics_supply.com/PurchaseOrder" targetNamespace="http://www.plastics_supply.com/PurchaseOrder"> Declare the XML namespace of all new types explicitly created within this schema

21 Slide 3.20 Complex type restrictions “minOccurs” and “maxOccurs” define the minimum and maximum numbers of times this element can appear in the structure. No city info is needed if Postal Code is present.

22 Slide 3.21 Complex type polymorphism <xsd:element name="shippingAddress" type="PO:Address" minOccurs= "1" maxOccurs="1"/> <xsd:element name="billingAddress" type="PO:Address" minOccurs= "1" maxOccurs="1"/> </xsd:complexType Variant of the PurchaseOrder type that uses the base type Address for its billingAddress and shippingAddress elements. Since “shippingAddress” and “billingAddress” are of type “PO:Address”, they can be defined by an address type derived from “PO:Address” in a document instance.

23 Slide 3.22 Complex type polymorphism (Continued) Plastic Products 459 Wickham st. Fortitude Valley QLD 4006 Australia 158 Edward st. QLD 4000 Australia 2002-09-15 An instance document can now use any type derived from base type Address for its billingAddress and shippingAddress elements. PurchaseOrder type uses the derived AustralianAddress type as its billingAddress and the derived AustralianPostalAddress type as its shippingAddress elements. No city info is needed!

24 Slide 3.23 Including and importing schemas How to build/manage a large and complex schema? Modularization! Include To include other schema documents in a schema document that has the same namespace Example: Import To use schema modules that belong to different namespaces Example:


Download ppt "Web Services: Principles & Technology Slide 3.1 Chapter 3 Brief Overview of XML COMP 4302/6302."

Similar presentations


Ads by Google