Presentation is loading. Please wait.

Presentation is loading. Please wait.

CHAPTER NINE Accessing Data Using XML. McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 2 Introduction The eXtensible.

Similar presentations


Presentation on theme: "CHAPTER NINE Accessing Data Using XML. McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 2 Introduction The eXtensible."— Presentation transcript:

1 CHAPTER NINE Accessing Data Using XML

2 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 2 Introduction The eXtensible Markup Language (XML) is a language used to represent data in a form that does not rely on any particular proprietary technology. XML Schema provides a way of defining and validating XML documents. eXtensible Stylesheet Language (XSL) and eXtensible Stylesheet Language Transforms (XSLT) is another useful technology associated with XML.

3 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 3 Introduction (cont.) This capability enables you to take a single XML document and transform it into a variety of different versions for specific uses. A number of classes within Visual Basic.NET provide methods that work directly with XML. Microsoft’s.NET initiative uses XML as its foundation data technology.

4 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 4 Objectives Understand what XML is and how it is used within business-to-business transactions. Understand XML Schemas and XSL Transforms and how they are used within the context of XML. Read and process data that are stored in an XML document.

5 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 5 Objectives (cont.) Read data from a relational database and transform them into their equivalent XML. Transform one XML document into a new XML document using an XSLT document.

6 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 6 9.1 An XML Primer What is XML? –XML provides a technology-neutral way to represent data. –XML is rapidly becoming the data format “standard” for the exchange of data on the Internet. –Data content and data presentation are separate. –Data represent what is called a tree.

7 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 7 9.1 An XML Primer (cont.) XML Syntax –The language is case sensitive. –There is one and only one root node. –All elements have a start tag and an end tag. –Tags must be nested correctly. –Attributes must be quoted. An XML document is well formed if you follow the above rules.

8 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 8 9.1 An XML Primer (cont.) –Namespaces A namespace defines a point of reference. –Change the element tag by adding a prefix and a colon to the tag. –Ex. and. Can differentiate two tags within the same document. Syntax: xmlns:name = “uri” The uri (Uniform Resource Identifier) is a unique identifier.

9 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 9 9.1 An XML Primer (cont.) –Document Prolog Indicates that the document is XML as well as other things such as document type, entity definitions and other processing instructions.

10 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 10 9.1 An XML Primer (cont.) XML Schemas –Rules that define legal elements, tags, and content. –Used to determine the validity of a document. –Industry specific XML schemas are being developed.

11 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 11 9.1 An XML Primer (cont.) Styling XML –Extensible Stylesheet Language Transforms (XSLT) provide a way to transform one XML document to another XML document.

12 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 12 9.2 Creating XML Documents and XML Schemas Using Visual Basic.NET Creating an XML Schema –Add an XML Schema to a project by selecting Add New Item from the File menu. –Use tools from the Toolbox to create the schema. –Save the Schema definition.

13 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 13 9.2 Creating XML Documents and XML Schemas Using Visual Basic.NET (cont.) Creating an XML Document –Complete the examples listed below in your textbook: Example 9.1 Using Simple and Complex Data Types in XML Schemas. Example 9.2 Creating Nested Relationships in an XML Schema. Example 9.3 Creating Tables with Relationships in an XML Schema. Example 9.4 Transforming XML using XSLT.

14 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 14 9.3 Using ADO.NET with XML ADO.NET provides a number of useful classes and methods to work directly with XML documents. –Data are already in XML form. This section provides a number of examples that demonstrate XML capabilities of the ADO.NET framework.

15 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 15 9.3 Using ADO.NET with XML (cont.) Complete the following examples listed below in your textbook: –Example 9.5 Processing an XML Document. –Example 9.6 Converting Relational DB Data into XML. –Example 9.7 Using XML and XSLT to Transform Data from a Relational Database.

16 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 16 Chapter Summary XML provides a technology-neutral way to represent data. It has rapidly become the data representation standard of the Internet. XML Schema is special set of rules. The rules control the validity of the corresponding XML document. An XML document can be well formed and also valid.

17 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 17 Chapter Summary (cont.) A well formed document follows the basic rules of all XML documents. A document is valid if it is well formed and conforms to the XML Schema definition it is associated with. It is possible to have two or more identical tags with different meanings. The XML standard permits the use of a namespace to solve the problem.

18 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 18 Chapter Summary (cont.) Namespace is associated with a unique uniform resource identifier (uri) and tags associated with the namespace are uniquely prefixed. Also, namespaces are used to identify some predefined tags used by software such as XML parsers. Extensible Stylesheet Language Transforms (XSLT) provide a way transforming one XML document into a new XML document.

19 McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 19 Chapter Summary (cont.) Visual Basic. NET includes classes that define methods to work with XML and its related technologies.


Download ppt "CHAPTER NINE Accessing Data Using XML. McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. 9- 2 Introduction The eXtensible."

Similar presentations


Ads by Google