Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML and Web Services CS409 Application Services Even Semester 2007.

Similar presentations


Presentation on theme: "XML and Web Services CS409 Application Services Even Semester 2007."— Presentation transcript:

1 XML and Web Services CS409 Application Services Even Semester 2007

2 2 XML Primer Extensible Markup Language was introduced in 1998. Similar to HTML, but contains an infinite set of elements and attributes. All key web services technology are based on XML.

3 3 Document-Centric XML Content is typically meant for human consumption. Used to mark up semi structured document. Mark up is used to present the information rather than to describe it.

4 4 Document-Centric XML (2) Example, a user guide: Skateboard Usage Requirements To use the SuperFast skateboard you have to have: A strong pair of legs. Reasonably long stretch of road surface. Impulse to impress others. If you have all of the above, you can proceed to: Getting Started

5 5 Data-Centric XML Content is typically meant for machine consumption. Used to mark up highly structured information. Includes many types of tags, organized in a highly-structured manner. Order and positioning of tags matter, relative to other tags.

6 6 Data-Centric XML (2) Example, a purchase order: The Soup Restaurant One Microsoft Way Redmond Washington 01567 Tall beer glass, plain style Table cloth

7 7 XML Standards for Web Services XML instances –Rules for creating syntactically correct XML. XML Schema –Enables detailed validation and specification of its data types. XML Namespaces –Mechanisms for combining multiple sources XML in a single document. XML processing –Creating, parsing, and manipulating XML from programming languages.

8 8 XML Instances Anatomy of instance: –Declaration –Comments –Elements –Attributes –CDATA section

9 9 XML Instance (2) Declaration –Describe the version of XML. –Defined the character encoding. Comments –Will be ignored by processing application. Example:

10 10 XML Instance (3) Elements –Everything between the pairing of start tag and end tag. –Content types Element-only content, consists entirely of nested elements. Mixed content, consists of nested elements and text. Empty content, start tag immediately followed by end tag.

11 11 XML Instance (4) Attributes –A name value pair for the element. –Must use equal sign (=) followed by quote value. –Attributes begin with xml: is reserved for XML specification. Example Tall beer glass, plain style

12 12 XML Instance (5) CDATA section –Mark a section of text as literal, so it won’t be parsed as tags and symbols. –The section will be treated as a string of characters. Example: <![CDATA [ Please don’t treat this as tags but just literal ]]>

13 13 XML Namespaces Created to solve recognition and collision problem in XML. Is an additional identifier for XML element within a document. Namespaces uses Uniform Resource Identifiers (URIs) as identifier.

14 14 XML Without Namespaces The Purchase Order The Soup Restaurant One Microsoft Way Redmond Washington 01567 Tall beer glass, plain style

15 15 XML With Namespaces <message from=“buyer@store.com” to=“seller@mystore.com” sent=“2006-02-01” xmlns=“http://www.xcommerce.com/ns/message”> The Purchase Order <po:po id=“43871” submitted=“2006-02-01” customerId=“73852” xmlns:po=“http://www.doddystore.com/ns/po”> The Soup Restaurant One Microsoft Way Redmond Washington 01567 Tall beer glass, plain style

16 16 XML Schemas A meta-language to describe –the structure of XML document. –the mapping of XML syntax to data type. Offer an automated an declarative mechanism to validate the contents of XML documents as they are parsed. The final specification is defined by the W3C in 2001.

17 17 Basic XML Schema Structure <xsd:schema xmlns=“http://www.doddystore.com/ns/po” xmlns:xsd=“http://www.w3.org/2001/XMLSchema” targetNamespace=“http://www.doddystore.com/ns/po” Purchase order schema for Doddy’s online store

18 18 Associating Schema to Document <po:po xmlns:po=“http://www.doddystore.com/ns/po” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://www.doddystore.com/ns/po http://www.doddystore.com/schema/po.xsd” id=“43871” submitted=“2006-02-01” customerId=“73852” The Soup Restaurant One Microsoft Way Redmond Washington 01567 Tall beer glass, plain style

19 19 XML Schemas Simple Type Sets of predefined basic data types. String, base64binary, hexBinary, integer, positiveInteger, negativeInteger, nonNegativeInteger, nonPositiveInteger, decimal, boolean, time, dateTime, duration, date, Name, Qname, anyURI, ID, IDREF.

20 20 XML Schemas Simple Type (2) Characteristics of simple type (facets): –Length, minLength, maxLength, pattern, enumeration, whiteSpace, minInclusive, maxInclusive, minExclusive, maxExclusive, totalDigits, fractionDigits. Example:

21 21 XML Schemas Complex Type Define complex content model, possibly have attributes and nested children. Example:

22 22 Processing XML XML Document Character Stream Serializer Parser Standardized XML APIs Application Fig 1. Basic XML Processing Architecture

23 23 Processing XML (2) Parsing models –Pull: application always ask the parser. –Push: parser sends notifications to the application. Simple API for XML (SAX) standard. –One-step: parser reads the whole XML doc and generates data structure. Document Object Model for XML (DOM) standard. –Hybrid: combinations of all three above.

24 24 SAX vs DOM DOM provides generic object model to represent XML document plus set of interfaces to manipulate it. SAX fires callback events into application as it parsed the XML document element by element. Both are supported by Java and Microsoft development communities.

25 25 SAX vs DOM (2) SAX uses less memory, more efficient for messaging. DOM consumes resources, but allows multiple passes through XML document (as if in-memory database or repository). Rule of thumb: –Need the document only to do one thing, use SAX. –Use the document as continuing source of data, use DOM.

26 26 XML Transformation Procedure to interpret contained information in XML document. Transformation activities: –Put data into XML document. –Extract data from XML document. –Transform XML document from one schema format to another.

27 27 XML Transformation (2) Standard specification : Extensible Stylesheet Language Transformation (XSLT). XSLT is part of XSL (used to transform XML into presentation formats). XSLT works with DOM and SAX.

28 28 XML Transformation (3) XML Path Language (XPath) –Expression language to link multiple XML documents. –Used to define search for locating specific element in XML document, calculation, string manipulations, and evaluating boolean expressions.

29 29 Sample XSLT Company Name: Street Address: Postal Code:

30 30 Sample XSLT (2) Transformation result in ASCII text format Company Name: The Soup Restaurant Street Address: One Microsoft Way Postal Code: 01567

31 31 Some XML Specifications XML 1.0: www.w3.org/TR/REC-xml/www.w3.org/TR/REC-xml/ XML Base: www.w3.org/TR/xmlbase/www.w3.org/TR/xmlbase/ XML Names: www.w3.org/TR/REC-xml-names/www.w3.org/TR/REC-xml-names/ XML Schema: www.w3.org/TR/xmlschema-1/ and www.w3.org/TR/xmlschema-2/www.w3.org/TR/xmlschema-1/www.w3.org/TR/xmlschema-2/ XML Path: www.w3.org/TR/xpathwww.w3.org/TR/xpath XML Transformation: www.w3.org/TR/xsltwww.w3.org/TR/xslt DOM: www.w3.org/TR/DOM-Level-2-Core/www.w3.org/TR/DOM-Level-2-Core/

32 Thank You Doddy Lukito dlukito@infinitechnology.com dlukito@alumni.carnegiemellon.edu


Download ppt "XML and Web Services CS409 Application Services Even Semester 2007."

Similar presentations


Ads by Google