Presentation is loading. Please wait.

Presentation is loading. Please wait.

 2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 1 Chapter 20 – Extensible Markup Language (XML) Outline 20.1 Introduction 20.2 Structuring.

Similar presentations


Presentation on theme: " 2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 1 Chapter 20 – Extensible Markup Language (XML) Outline 20.1 Introduction 20.2 Structuring."— Presentation transcript:

1  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 1 Chapter 20 – Extensible Markup Language (XML) Outline 20.1 Introduction 20.2 Structuring Data 20.3 XML Namespaces 20.4 Document Type Definitions (DTDs) and Schemas 20.4.1 Document Type Definitions 20.4.2 W3C XML Schema Documents 20.5 XML Vocabularies 20.5.1 MathML 20.5.2 Chemical Markup Language (CML) 20.5.3 MusicXML 20.5.4 RSS 20.5.5 Other Markup Languages 20.6 Document Object Model (DOM) 20.7 DOM Methods 20.8 Simple API for XML (SAX) 20.9 Extensible Stylesheet Language (XSL) 20.10 Simple Object Access Protocol (SOAP) 20.11 Web Services 20.12 Water XML-Based Programming Language 20.13 Web Resources

2  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 2 Objectives In this lesson, you will learn: –To understand XML. –To be able to mark up data using XML. –To become familiar with the types of markup languages created with XML. –To understand the relationships among DTDs, Schemas and XML. –To understand the fundamentals of DOM-based and SAX-based parsing. –To understand the concept of an XML namespace. –To be able to create simple XSL documents. –To become familiar with Web services and related technologies.

3  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 3 20.1 Introduction XML (Extensible Markup Language) –Derived from Standard Generalized Markup Language (SGML) –Open technology for electronic data exchange and storage –Create other markup languages to describe data in structured manner –XML documents Contain only data, not formatting instructions Highly portable Typically ends with.xml file extension, any text editor can view and edit. It is both human readable and machine readable Processing an XML document requires an XML parser Support Document Object Model or Simple API XML Document Type Definition (DTD, schema) –XML document can reference another that defines proper structure –XML-based markup languages XML vocabularies

4  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 4 20.2 Structuring Data XML declaration –version Attribute Indicates the XML version to which the document conforms Root element –Element that encompasses every other elements Container element –Any element contains other elements Child elements –Elements inside a container element Empty element flag –Does not contain any text DTD documents –End with.dtd extension

5  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline article.xml (1 of 1)

6  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 6

7  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 7 Container element Child elements

8  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline letter.xml (1 of 2)

9  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline letter.xml (2 of 2)

10  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 10

11  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 11

12  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 12 20.3 XML Namespaces XML –Allows document authors to create custom elements –Can result in Naming collisions –XML namespace Collection of element and attribute names Uniform resource identifier (URI) –Uniquely identifies the namespace –A string of text for differentiating names Any name except for reserved namespace xml Directory –Root element and contains other elements

13  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline namespace.xml (1 of 1)

14  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline defaultnamespace.xml (1 of 1)

15  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 15 20.4 Document Type Definitions (DTDs) and Schemas Two types of documents for specifying XML document structure –Document Type Definition (DTDs) –Schemas

16  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 16 20.4.1 Document Type Definitions Enables XML parser to verify whether XML document is valid Allow independent user groups to check structure and exchange data in standardized format Expresses set of rules for structure using EBNF grammar ELEMENT type declaration –Defines rules ATTLIST attribute-list declaration –Defines an attribute

17  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline letter.dtd (1 of 1)

18  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 18 20.4.2 W3C XML Schema Documents Schemas –Specify XML document structure –Do not use EBNF grammar –Use XML syntax –Can be manipulated like other XML documents –Require validating parsers –XML schemas Schema vocabulary the W3C created Recommendation Schema valid –XML document that conforms to a schema document –Use.xsd extension

19  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 19 20.4.2 W3C XML Schema Documents Root element schema –Contains elements that define the XML document structure –targetNamespace Namespace of XML vocabulary the schema defines –element tag Defines element to be included in XML document structure –name and type attributes Specify element’s name and data type respectively –Built-in simple types date, int, double, time, etc

20  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 20 20.4.2 W3C XML Schema Documents Two categories of data types –Simple types Cannot contain attributes or child elements –Complex types May contain attributes and child elements complexType –Define complex type Simple content –Cannot have child elements Complex content –May have child elements

21  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline book.xml (1 of 1)

22  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline book.xsd (1 of 1)

23  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 23

24  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 24 XSD Schema Validator

25  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 25 XSV Schema Validator

26  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline computer.xsd (1 of 2)

27  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline computer.xsd (2 of 2)

28  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline laptop.xml (1 of 1)

29  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 29 20.5 XML Vocabularies XML allows us to create our own tags to describe precisely. People and organizations have created many different kinds of XML for structuring data, some of these are: –MathML (Mathematical Markup Language) –SVG (Scalable Vector Graphics) –WML (Wireless Markup Language) –XBRL (Extensible Business Reporting Language) –XUL (Extensible User Interface Language) –PDML (Product Data Markup Language)

30  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 30 20.5 XML Vocabularies W3C XML Schema XSL (Extensible Stylesheet Language)

31  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 31 20.5.1 MathML Describe mathematical notations and expressions MathML markup –Content markup Provides tags that embody mathematical concepts Allows programmers to write mathematical notation specific to different areas of mathematics Distinguishes between different uses of same symbol –Presentation markup Directed towards formatting and displaying mathematical notation http://www.w3.org/Math/Software/

32  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline mathml1.html (1 of 2)

33  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline mathml1.html (2 of 2) MathML displayed in the Amaya browser. [Courtesy of World Wide Web Consortium (W3C).]

34  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline mathml2.html (1 of 2)

35  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline mathml2.html (2 of 2) MathML displayed in the Amaya browser. [Courtesy of World Wide Web Consortium (W3C).]

36  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline mathml3.html (1 of 3)

37  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline mathml3.html (2 of 3)

38  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline mathml3.html (3 of 3) Integral symbol Delta symbol MathML displayed in the Amaya browser. [Courtesy of World Wide Web Consortium (W3C).]

39  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 39 20.5.2 Chemical Markup Language (CML) XML vocabulary for representing molecular and chemical information

40  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline ammonia.xml (1 of 2)

41  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline ammonia.xml 2 of 2 (Courtesy of the Jmol Project.)

42  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 42 20.5.3 MusicXML Music distribution Simplifies exchange of musical scores over Internet Developed by Recordare Mark up all type of music DTD –Less powerful than Schema –Simpler to program Relies heavily on elements rather than attributes

43  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 43 20.5.3 MusicXML Fig. 20.15MusicXML markup rendered by Finale 2003 (Courtesy of MakeMusic! Inc.).

44  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 44 20.5.4 RSS RDF Site summary Popular and simple XML format designed to share headlines and Web content between Web sites RSS file –RSS feed –Container rss element Denotes the RSS version –Container channel elements Descriptive tags Item elements –Describe the news or information –title element –description element –link element

45  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline deitel.rss (1 of 2)

46  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline deitel.rss (2 of 2)

47  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 47 20.5.5 Other Markup Languages

48  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 48 20.6 Document Object Model (DOM) Document Object Model (DOM) tree –Nodes –Parent node Ancestor nodes –Child node Descendant nodes Sibling nodes –One single root node Contains all other nodes in document Application Programming Interface (API)

49  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 49 20.6 Document Object Model (DOM) firstName lastName contents summary author date title article children of the article root node siblings root element Fig. 20.18Tree structure for article.xml.

50  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 50 20.7 DOM Methods nodeName –Name of an element, attribute, or so on NodeList –List of nodes –Can be accessed like an array using method item Property length –Returns number of children in root element nextSibling –Returns node’s next sibling nodeValue –Retrieves value of text node parentNode –Returns node’s parent node

51  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline DOMExample.html (1 of 3)

52  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline DOMExample.html (2 of 3)

53  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline DOMExample.html (3 of 3)

54  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 54

55  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 55 20.7 DOM Methods

56  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 56 20.7 DOM Methods

57  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 57 20.7 DOM Methods

58  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 58 20.7 DOM Methods

59  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 59 20.7 DOM Methods

60  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 60 20.8 Simple API for XML (SAX) Developed by members of XML-DEV mailing list Parse XML documents using event-based model Provide different APIs for accessing XML document information Invoke listener methods Passes data to application from XML document Better performance and less memory overhead than DOM- based parsers

61  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 61 20.9 Extensible Stylesheet Language (XSL) Specify how programs should render XML document data –XSL-FO (XSL Formatted Objects) Vocabulary for specifying formatting –XSLT (XSL Transformation) Source tree Result tree –Xpath Locate parts of the source tree document that match templates defined in the XSL stylesheet

62  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 62 20.9 Extensible Stylesheet Language (XSL)

63  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline games.xml (1 of 2)

64  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline games.xml (2 of 2)

65  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline games.xsl (1 of 3)

66  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline games.xsl (2 of 3)

67  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline games.xsl (3 of 3)

68  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline sorting.html (1 of 2)

69  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline sorting.html (2 of 2)

70  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline sorting.xsl (1 of 4)

71  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline sorting.xsl (2 of 4)

72  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline sorting.xsl (3 of 4)

73  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline sorting.xsl (4 of 4)

74  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 74 20.10 Simple Object Access Protocol (SOAP) Developed by IBM, Lotus Development Corporation, Microsoft, DevelopMentor, and Userland Software XML-based protocol Allows applications to communicate over Internet SOAP message –Envelope A structure describes a method call –Body Request –Remote Procedure Call (RPC) Response –HTTP response document contains results from other method call http://www.w3.org/TR/soap12-part0/

75  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 75 20.11 Web Services Standards –XML –SOAP –Web Services Description Language (WSDL) –Universal Description, Discovery and Integration (UDDI) –Modular programming Modularization –Less error prone and promotes software reuse

76  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 76 20.11 Web Services

77  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 77 20.12 Water XML-Based Programming Language Simplifies XML and Web services programming Represents all objects and data as XML

78  2003 Prentice Hall, Inc. All rights reserved. Outline  2003 Prentice Hall, Inc. All rights reserved. Outline concatenate.h2o 1 of 1

79  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 79

80  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 80 20.13 Web Resources www.w3.org/xml www.xml.org www.w3.org/style/XSL www.w3.org/TR xml.apache.org www.xmlbooks.com www.xmlsoftware.com www.xml-zone.com wdvl.internet.com/Authoring/Languages/XML www.xml.com msdn.microsoft.com/xml/default.asp www.oasis-open.org/cover/xml.html www.gca.org/whats_xml/default.htm www.xmlinfo.com www.ibm.com/developer/xml developer.netscape.com/tech/xml/index.html www.projectcool.com/developer/xmlz

81  2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 81 20.13 Web Resources www.ucc.ie/xml www.xml-cml.org backend.userland.com/rss www.w3.org/2002/ws www.oasis-open.org www.clearmethods.com www.textuality.com/xml www.zvon.org


Download ppt " 2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 1 Chapter 20 – Extensible Markup Language (XML) Outline 20.1 Introduction 20.2 Structuring."

Similar presentations


Ads by Google