Tải bản đầy đủ (.pdf) (22 trang)

Tài liệu Module 1: Introduction to XML in the .NET Framework doc

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (882.54 KB, 22 trang )








Contents
Overview 1
Course at a Glance 2
Lesson: Common Business Problems 3
Lesson: XML in the .NET Framework 7
Review 14

Module 1:
Introduction to XML in
the .NET Framework




Information in this document, including URL and other Internet Web site references, is subject to
change without notice. Unless otherwise noted, the example companies, organizations, products,
domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious,
and no association with any real company, organization, product, domain name, e-mail address,
logo, person, place or event is intended or should be inferred. Complying with all applicable
copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part
of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted
in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or
for any purpose, without the express written permission of Microsoft Corporation.


Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual
property rights covering subject matter in this document. Except as expressly provided in any
written license agreement from Microsoft, the furnishing of this document does not give you any
license to these patents, trademarks, copyrights, or other intellectual property.

©2002 Microsoft Corporation. All rights reserved.

Microsoft, MS-DOS, Windows, Windows NT, Win32, Active Directory, ActiveX, BizTalk,
IntelliSense, JScript, Microsoft Press, MSDN, PowerPoint, SQL Server, Visual Basic, Visual C#,
and Visual Studio are either registered trademarks or trademarks of Microsoft Corporation in the
United States and/or other countries.

The names of actual companies and products mentioned herein may be the trademarks of their
respective owners.



Module 1: Introduction to XML in the .NET Framework iii


Instructor Notes
After completing this module, students will be able to:
 Explain how Extensible Markup Language (XML) in the Microsoft® .NET
Framework helps provide solutions to common business problems.
 Discuss how Microsoft’s implementation of World Wide Web Consortium
(W3C) standards for XML provides a framework for XML solutions to
business problems.
 Diagram XML support in the .NET Framework.

To teach this module, you need the following materials:

 Microsoft PowerPoint® file 2663A_01.ppt
 2663A_ataglance.htm

To prepare to effectively teach this module:
 Read all of the materials for this module.
 Practice using the interactive Flash animation.

This module contains an interactive Flash animation that shows the relationship
of trading partners with regard to XML and other data they share. The
animation contains a slider that you use to scroll horizontally left or right. In
addition, it contains buttons you click to display text that explains business
problems and XML solutions. This animation is discussed in detail in the
following section.
Presentation:
30 minutes
Required materials
Preparation tasks
About the interactive
Flash animation
iv Module 1: Introduction to XML in the .NET Framework


How to Teach This Module
This section contains information that will help you to teach this module.
Course at a Glance
This topic provides an overview of Course 2663. There is a link at the bottom
of the slide that you can click to display an .htm file in Microsoft
Internet Explorer. This file provides a brief overview of the course, the
programming categories and tasks covered in the course, and the major XML
base classes in the .NET Framework.

Lesson: Common Business Problems
This section describes the instructional methods for teaching each topic in this
lesson.
Use this animation to provide an overview of the course. This interactive
animation begins with a brief display of the entire process. Click the ZOOM IN
button in the lower right corner of the display. The animation then zooms in on
the featured company, Northwind Traders, and the button changes to read
OVERVIEW. You can move between the overview and the zoomed-in view at
any time. At the bottom of the display is a slider that makes each portion of the
process active. You can click the more buttons next to each application or
component to display explanations of that application or component.
You move the slider one step to the right to see how Northwind Traders uses
Web applications in transactions with its customers. Move the slider further to
the right to see how Northwind Traders customers interact with the Web
applications and also interact directly with Northwind Traders. Explain that the
Web applications provide a user interface for Northwind Traders customers.
You move the slider to the left to see how Northwind Traders uses the XML
Web services that it maintains for its suppliers. Move the slider further to the
left to see how the suppliers interact with the XML Web services. The XML
Web services allow applications to interact with each other, so there is no user
interface.
Notice a series of boxes that are labeled Manipulate, Transform, Query, and
so on. Each box indicates that a module of the course covers the interactions
closest to the box.
This topic provides a brief overview of the common business problems faced by
businesses, particularly those that do business over the Internet.
Note that this topic does not discuss solutions to the problems. It states the
problem in a way that sets the stage for the remaining modules in the course.
Multimedia:
Overview of Common

Business Problems
Common Business
Problems
Module 1: Introduction to XML in the .NET Framework v


Lesson: XML in the .NET Framework
This section describes the instructional methods for teaching each topic in this
lesson.
This topic explains the W3C standards that form the basis of XML support in
the .NET Framework and lists the Uniform Resource Locator (URL) for each
standard’s specification. This topic sets up the rest of the course. The lessons
and modules that follow show the use of .NET Framework classes that support
these standards.
This topic shows the .NET Framework namespaces and base classes that
implement the W3C standards. This is a good time to check the class’s
understanding of namespaces and provide a brief overview if necessary.
This topic describes how to use the classes that derive from XML base classes
in the .NET Framework. The base and derived classes that this topic describes
are featured in the rest of this course. This might be a good time to check how
much your students know about Document Type Definitions (DTDs) and
various types of schemas.
This topic compares and contrasts Microsoft XML Core Services
(MSXML) 4.0 and .NET Framework classes. The point to stress is that
MSXML 4.0 is for use in Component Object Model (COM) and Document
Object Model (DOM) environments and .NET Framework classes are for use in
.NET managed environments. Explain that each has its uses.
This topic explains how you use XML to help deal with security concerns.
Explain that XML alone cannot guarantee security and should be a part of a
company-wide security solution.

Review
There are several multiple-choice review questions at the end of the chapter.
Review these questions with your students before proceeding to the lab.
Customization Information
This section identifies the lab setup requirements for a module and the
configuration changes that occur on student computers during the labs. This
information is provided to assist you in replicating or customizing
Microsoft Official Curriculum (MOC) courseware.
Lab Setup
This module contains no labs.
Lab Results
This module contains no labs.
What Are the W3C
Standards in the .NET
Framework?
Microsoft
Implementations of W3C
XML Standards
Overview of XML
Classes in the .NET
Framework
MSXML 4.0 vs. .NET
XML and Security in the
.NET Framework

Module 1: Introduction to XML in the .NET Framework 1


Overview
 Course at a Glance

 Common Business Problems
 XML in the .NET Framework

*****************************
ILLEGAL FOR NON-TRAINER USE******************************
This module introduces Extensible Markup Language (XML) in the Microsoft
®
.NET Framework. XML is a standards-driven technology that is ideal for
applications that use the Internet. Microsoft’s implementation of World Wide
Web Consortium (W3C) standards ensures that applications you develop with
XML in .NET will successfully communicate with other W3C-compatible
applications.
After completing this module, you will be able to:
 Explain how using XML provides solutions to common business problems.
 Discuss how Microsoft’s implementation of W3C standards for XML
provides a framework for XML solutions to business problems.
 Diagram XML support in the .NET Framework.

Introduction
Objectives
2 Module 1: Introduction to XML in the .NET Framework


Course at a Glance
 Course 2663 covers essential XML operations:
 Reading XML (Modules 2 and 3)
 Writing XML (Module 4)
 Querying XML (Module 5)
 Manipulating XML (Module 6)
 Transforming XML (Module 7)

 Transmitting XML (Module 8)
 Overview of XML Web services
 Overview of the .NET platform
Course at a glance

*****************************
ILLEGAL FOR NON-TRAINER USE******************************
In an Internet environment, data can come from many sources and in many
formats. XML Web services and other applications that you develop by using
the .NET Framework help solve the problems of working with data in many
formats from many sources. Each module in this course deals with a different
aspect of creating XML-based applications by using the .NET Framework.
The .NET Framework is a platform for building XML Web services. You
invoke services by using industry standard protocols, such as Simple Object
Access Protocol (SOAP); Universal Description, Discovery, and Integration
(UDDI) Service; and XML. You build XML Web services with classes and
namespaces that are defined by W3C standards. XML Web services provide a
means to share data and to structure and manipulate data.
The .NET platform includes a comprehensive family of products, built on XML
and Internet industry standards. The platform provides for each aspect of
developing, managing, using, and experiencing XML Web services.
XML Web services allow applications to communicate and share data over the
Internet, regardless of operating system or programming language. Microsoft is
building the .NET platform today in the following five areas:
 .NET experiences
 Tools
 Servers
 XML Web services
 Clients


Introduction
Overview of XML Web
services
Overview of the .NET
platform
Module 1: Introduction to XML in the .NET Framework 3


Lesson: Common Business Problems
 Multimedia: Common Business Problems
 Common Business Problems

*****************************
ILLEGAL FOR NON-TRAINER USE******************************
This lesson introduces common business problems that you can solve by using
XML in the .NET Framework when you develop applications. XML provides a
uniform method for describing and exchanging structured data.
After completing this lesson, you will be able to:
• List common data-related business problems.

Introduction
Lesson ob
j
ectives
4 Module 1: Introduction to XML in the .NET Framework


Multimedia: Common Business Problems
 This interactive animation shows how XML
can help solve common problems

encountered by businesses that exchange
data

*****************************
ILLEGAL FOR NON-TRAINER USE******************************
This interactive animation shows problems often encountered by businesses
that share data, particularly those that do business over the Internet.
The animation begins with a brief display of the entire process. Click the
ZOOM IN button in the lower right corner of the display. The animation then
zooms in on the featured company, Northwind Traders, and the button changes
to read OVERVIEW.
You can move between the overview and the zoomed-in view at any time. At
the bottom of the display is a slider that makes each portion of the process
active to show interactions between Northwind Traders and its suppliers (to the
left) and its customers (to the right). You can click the more buttons next to
each application or component to display explanations of that application or
component.
Introduction
Module 1: Introduction to XML in the .NET Framework 5


Common Business Problems
 Integrating disparate applications
 Translating between data formats
 Searching for and querying data
 Manipulating data

*****************************
ILLEGAL FOR NON-TRAINER USE******************************
Doing business over the Internet brings many companies with many different

systems together. Although the idea of doing business over the Internet is
relatively recent, many companies have a lot of time and money invested in
systems they have been using for a long time. Integrating data with your
business’s existing systems and with those of your trading partners is one of the
biggest problems facing programmers today.
For companies to share data, it must be available to many applications on
different operating systems. For applications to exchange data, the data must be
structured so that different applications can use it. Some data is stored in
hierarchical systems, including XML documents. Other data is stored in
relational databases, such as Microsoft SQL Server

. Still other data is stored
in an unstructured way, such as in flat files.
One of the biggest problems that businesses face, particularly those that use the
Internet, is that applications use many different types of data. These problems
include the following:
 Different XML formats
XML files can be in a variety of grammars, such as a grammar that uses
only elements or one that uses both elements and attributes. Businesses can
solve this type of data transformation problem by using templates that
provide standardization.
 Generating XML from data in another format
Business data exists in many different formats, including EDIFACT, ANSI
X12, XML, comma-separated value (CSV) files, tab-separated files, and
many more. Business can solve data-generation problems by providing a
standard structure for the data that all the applications can use.
Introduction
Integrating disparate
applications
Translating between

data formats
6 Module 1: Introduction to XML in the .NET Framework


 Validating data structures
One of the key advantages of using XML in applications is that it provides a
means for applications to share data. However, because data can come from
so many different sources, there must be a way to make certain that the data
is valid. Businesses can solve this type of problem by using validating tools,
such as schemas, that are standard across applications and data types.

When data comes from a variety of sources and in a variety of formats, it can be
difficult to find the precise data items that an application requires. The issues
include the following:
 Searching for specific items in data
Applications not only use data in different formats, but also in different
structures. Some data is stored in hierarchical structures, some in relational
structures, and some in no structure at all, but merely as text. You need to
have a way to navigate the structure, or lack of structure, of the data
container.
 Summarizing, combining, and correlating data
After you locate the data you want, you want to act on it. For example, you
may want to prepare reports or generate lists for shipping or accounting.
You can merge, or combine, data from multiple sources into a single,
consistent format that you can process, edit, or manipulate to solve specific
business problems. The format that .NET was designed to work with is
XML.

With XML in the .NET Framework, you can filter data to minimize information
overload so that you can focus on the data that is relevant to the business

problem at hand.
To manipulate data, there must a structure to provide context. After you
manipulate the data, you must likewise have a structure in which to display it.
Manipulation issues include the following:
 Transforming data from XML into another format
You might need to transform data in one XML grammar into another if the
elements and attributes of the application you work with differ from the
XML structure of the data you consume. If you work with a Web
application, you might need to transform data in structured XML documents
into Hypertext Markup Language (HTML) documents that you can display
on a Web site. You might also need to print out the data; for example in
Adobe Acrobat Portable Document Format (PDF) files.
 Changing the structure of a document
You might need to add elements or nodes to a document in XML format, or
add or delete elements or attributes.

Searching for and
querying data
Manipulatin
g
data
Module 1: Introduction to XML in the .NET Framework 7


Lesson: XML in the .NET Framework
 What Are the W3C Standards in the .NET Framework?
 Microsoft Implementations of W3C XML Standards
 Overview of XML Classes in the .NET Framework
 MSXML 4.0 vs .NET
 XML and Security in the .NET Framework


*****************************
ILLEGAL FOR NON-TRAINER USE******************************
This lesson discusses the XML standards developed by the W3C and
Microsoft’s implementations of these standards.
After completing this lesson, you will be able to:
 List the W3C standards in the .NET Framework.
 Compare and contrast the use of Microsoft XML Core Services and the
.NET Framework.
 Discuss the Microsoft implementations of XML.

Introduction
Lesson ob
j
ectives
8 Module 1: Introduction to XML in the .NET Framework


What Are the W3C Standards in the .NET Framework?
XSLT
1
XSD
1
XPath
1
DOM
1
XML 1.0 +
Namespaces
W

o
r
l
d

W
i
d
e

W
e
b

C
o
n
so
r
t
i
u
m

(
W
3
C
)


s
t
a
n
d
a
r
d
s
E
x
t
e
n
s
i
b
l
e

M
a
r
k
u
p

L
a
n

g
u
a
g
e
X
M
L

1
.
0

+

N
a
m
e
s
p
a
c
e
s
D
o
c
u
m

e
n
t

O
b
j
e
c
t

M
o
d
e
l

L
e
v
e
l

1

a
n
d

L

e
v
e
l

2

C
o
r
e
X
M
L

P
a
t
h

L
a
n
g
u
a
g
e

1

.
0
X
M
L

S
c
h
e
m
a

D
e
f
i
n
i
t
i
o
n

L
a
n
g
u
a

g
e

1
.
0
X
S
L
T

T
r
a
n
s
f
o
r
m
a
t
i
o
n
s

1
.
0


S
y
s
t
e
m
.
X
m
l
S
y
s
t
e
m
.
X
m
l
S
y
s
t
e
m
.
X
m

l
.
X
P
a
t
h
S
y
s
t
e
m
.
X
m
l
.
S
c
h
e
m
a
S
y
s
t
e
m

.
X
m
l
.
X
s
l
.
N
E
T

F
r
a
m
e
w
o
r
k

N
a
m
e
s
p
a

c
e
s
XmlReader
XmlWriter
.
N
E
T
F
r
a
m
e
w
o
r
k
C
l
a
s
s
e
s
XslTransform
XsltArgumentList
XmlSchema
XmlSchemaCollection
XPathDocument

XPathExpression
XPathNavigator
XmlDocument
XmlNodeList
S
y
s
t
e
m
.
X
m
l
S
y
s
t
e
m
.
X
m
l
S
y
s
t
e
m

.
X
m
l
.
X
P
a
t
h
S
y
s
t
e
m
.
X
m
l
.
S
c
h
e
m
a
S
y
s

t
e
m
.
X
m
l
.
X
s
l
.
N
E
T

F
r
a
m
e
w
o
r
k

N
a
m
e

s
p
a
c
e
s
1
1
3
3
2
2

*****************************
ILLEGAL FOR NON-TRAINER USE******************************
You can use XML across different platforms with different applications. This is
possible due to standards established by the W3C. XML in the .NET
Framework supports the standards that take advantage of the interoperability
made possible by standardization.
The W3C has created a specification for an XML information set. This
specification provides a set of definitions for use in other specifications that
refer to information contained in an XML document. An XML document
consists of some number of information sets.
An XML document contains an information set if it is well-formed and satisfies
certain namespace constraints defined in the XML Information Set
specification. Information sets contain information items that describe the
structure of an XML document. Many of the W3C XML standards are derived
from the definitions in the XML Information Set specification.
The XML 1.0 specification defines what makes a data object an XML
document, the logical and physical structures of an XML data document, and

other characteristics. The specification is at
The Namespaces in XML specification defines an XML namespace and how to
use namespaces when creating an XML grammar, sometimes called a
vocabulary, that consists of elements and attributes. The specification is at

The XML Path Language (XPath) 1.0 specification defines common syntax and
semantics for functionality to address parts of an XML document. It also
provides basic facilities for manipulation of strings, numbers, and Booleans.
The specification is at
The XSL Transformations (XSLT) 1.0 specification defines the syntax and
semantics of XSLT, a language for transforming XML documents into other
XML documents. A transformation expressed in XSLT is called a style sheet.
The specification is at
Introduction
The XML information set
XML 1.0 + namespaces
XML Path Language
(XPath) 1.0
XSL Transformations
(
XSLT
)
1.0
Module 1: Introduction to XML in the .NET Framework 9


The Document Object Model (DOM) specifications for Level 1 and Level 2
Core define an interface that allows you to programmatically access and update
the style, content, and structure of documents. Information about the
specifications is at

XML Schemas provide a means for describing the structure, content, and
semantics of an XML document. Schemas express shared vocabularies.
Information about schemas is at
Document Object Model
(DOM) Level 1 and
Level 2 Core
XML Schema Definition
Lan
g
ua
g
e
(
XSD
)

10 Module 1: Introduction to XML in the .NET Framework


Microsoft Implementations of W3C XML Standards
System.XmlDOM Level 1
System.Xml.SchemasXML Schema Object
Model (SOM)
System.Xml
System.Xml.Schemas
XML Schemas
System.XmlDOM Level 2 Core
System.Xml.XslXSLT
System.Xml
System.Xml.XPath

XPath
System.XmlXML 1.0 and
Namespaces in XML
.
NET Framework namespace
NET Framework namespace
W3C XML standard
W3C XML standard

*****************************
ILLEGAL FOR NON-TRAINER USE******************************
The .NET Framework supports the W3C standards by providing namespaces
and base classes that conform to the standards. The following table describes
.NET Framework support for the standards.
The following table shows Microsoft implementations of W3C standards in the
.NET Framework.

.NET Framework namespaces are groups of functionality in the .NET
Framework and are not the same as the XML Standard namespaces.


W3C XML standard
.NET Framework
namespace

.NET Framework class

XML 1.0 and Namespaces
in XML
System.Xml Not applicable

XPath System.Xml
System.Xml.XPath
XPath base class
XSLT System.Xml.Xsl XslTransform base class
DOM Level 1 and
DOM Level 2 Core
System.Xml XmlDocument class
XML Schemas System.Xml
System.Xml.Schemas
XmlSchema
XML Schema Object
Model (SOM)
System.Xml.Schemas XmlSchema

Introduction
Microsoft
implementations of
W3C standards
Note
Module 1: Introduction to XML in the .NET Framework 11


Overview of XML Classes in the .NET Framework
 Abstract base classes
 XmlReader – key derived classes:
XmlTextReader
XmlNodeReader
XmlValidatingReader
 XmlWriter – key derived class:
XmlTextWriter

 XmlNavigator
 XmlResolver

*****************************
ILLEGAL FOR NON-TRAINER USE******************************
The abstract base classes in the .NET Framework are the basis of data exchange
functionality.
The following table describes some of the base classes in the .NET Framework.
Abstract base class Use Derived classes

XmlReader Use with a streaming model for
forward-only, read-only cursor
for XML documents and to
validate against schema, DTD,
XDR, and XSD.
XmlTextReader
XmlNodeReader
XmlValidatingReader
XmlWriter Use to produce an XML
document stream that conforms
to W3C XML namespace
recommendations.
XmlTextWriter
XmlNavigator Use for document navigation
when you do not need to load the
entire document into memory.
XmlPathNavigator
XmlResolver Use to resolve external XML
resources named by a Uniform
Resource Identifier (URI).

XmlUrlResolver

Introduction
XML classes in the .NET
Framework
12 Module 1: Introduction to XML in the .NET Framework


Comparison of MSMXL 4.0 and .NET












DOM Level 1






SAX













(Read-Only)
SOM












XML Schemas







DOM Level 2 Core












XSLT












XPath













XML 1.0 and
XML Namespaces
.NET managed environments
.NET managed environments
COM environments
COM environments
Usage
Usage
.NET Framework XML ClassesMSXML

*****************************
ILLEGAL FOR NON-TRAINER USE******************************
Microsoft provides two ways for programmers to work with XML:
 Microsoft XML Core Services (MSXML) 4.0, which was formerly known
as the XML Parser
 .NET Framework XML classes

MSXML 4.0 replaces the MSXML parser. The MSXML 4.0 functionality
differs from .NET Framework classes in that it is aimed at an environment that

uses Component Object Model (COM) objects, does not use managed code, and
has built-in support for Simple API for XML (SAX). MSXML 4.0 includes the
following services:
 DOM
 XSD
 The Schema Object Model (SOM), an additional set of APIs for accessing
XML schema documents programmatically
 XSLT 1.0
 XPath 1.0
 SAX, a programmatic alternative to DOM-based processing

The .NET Framework XML classes perform many of the same functions as
MSXML 4.0. However, the classes are specifically aimed at a managed
environment, specifically .NET XML Web services.
Introduction
MSXML 4.0
.NET Framework XML
classes
Module 1: Introduction to XML in the .NET Framework 13


XML and Security in the .NET Framework
 XML object model for encoding security objects
 Support for XML signatures
 System.Security.Cryptography.Xml namespace
 Follows W3C XML signature
 Encrypting XML Web service transmissions
 System.Web.Services.Protocols.SoapExtension
 Custom SOAP headers and user-defined
SessionStateModule object

 Passing authentication credentials

*****************************
ILLEGAL FOR NON-TRAINER USE******************************
XML is the basis of data storage and transmission in the .NET Framework. In a
sense, all security considerations in the .NET Framework are XML security
considerations. Access to XML Web services can be restricted to authorized
clients, much in the same way that access to Web sites can be restricted to
authorized users.
The SecurityElement class represents the XML model for encoding security
objects. This class is intended for use within a security system only, and not for
use as a general XML object class.
The W3C is developing a specification for XML digital signatures. The
System.Security.Cryptography.Xml namespace contains an XML model for use
with the .NET Framework security system, including support for XML
signatures. This model allows XML objects to be signed with a digital
signature. Cryptography protects data from being viewed or modified and
provides secure channels of communication.
.NET-based applications use SOAP as the primary message format for
communicating with XML Web services. The .NET Framework class library
provides SOAP extensions to run with an XML Web service method. The
namespace consists of the classes that define the protocols for transmitting data.
There might be times when an XML document is secured, and therefore, you
cannot access it without passing the appropriate credentials. The
XmlTextReader class allows you to pass credentials by using the
CredentialCache class in the System.Net namespace.
Introduction
XML object model for
encoding security
objects

Support for XML
signatures
Encrypting XML Web
service transmissions
Passing authentication
credentials
14 Module 1: Introduction to XML in the .NET Framework


Review
 What common business problems does XML address?
 What W3C XML standards does the .NET Framework
support?
 What security considerations does XML in the .NET
Framework address?

*****************************
ILLEGAL FOR NON-TRAINER USE******************************
1. Which of the following business problems does XML in the .NET
Framework address?
a. Manipulating data
b. Transforming data
c. Validating an XML document
d. All of the above
The correct answer is d.


2. Choose all of the W3C standards that the .NET Framework supports.
a. XML Schema Definition (XSD) 1.0
b. XML Path Language (XPath) 1.0

c. XML Linking Language (XLink)
d. XSL Transformations (XSLT) 1.0
The correct answer is a, b, and d.


Module 1: Introduction to XML in the .NET Framework 15


3. To access authentication credentials, which of the following classes in the
System.XML namespace should you use with the XmlTextReader class?
a. XmlResolver
b. CredentialCache
c. XmlValidatingReader
d. XmlTextReader
The correct answer is b.






THIS PAGE INTENTIONALLY LEFT BLANK

×