1. Trang chủ
  2. » Công Nghệ Thông Tin

Module 1: Overview of XML Documents

50 439 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Module 1: Overview of XML Documents
Người hướng dẫn Steve Merrill, Sangeeta Nair (NIIT), Vijayalakshmi Narayanaswamy (NIIT), Andy Olsen (QA Training), Andy Longshaw (Content Masters), Janet Robinson, Scott Serna (Creative Assets), David Mahlmann, Dean Connolly (Art Source), Timothy Demmon (:timebomb Media), Jennifer Linn, Dennis Rae (Wasser), Miracle Davis, Marlene Lambert (Online Training Solutions, Inc), Julie Challenger, Jenny Boe, Eric Myers, John Williams, Steve Elston
Trường học Microsoft Corporation
Chuyên ngành XML
Thể loại hướng dẫn
Năm xuất bản 2000
Thành phố Redmond
Định dạng
Số trang 50
Dung lượng 1,06 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

The HTML document uses data binding to display the information.. Details.asp uses client-side DOM script to transform the book information, using TransformBookDetails.xsl, into a format

Trang 1

Demonstration: The LitWare Books

Application 42

Review 43

Module 1: Overview of XML Documents

Trang 2

to represent any real individual, company, product, or event, unless otherwise noted Complying with all applicable copyright laws is the responsibility of the user No part of this document may

be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Microsoft Corporation If, however, your only means of access is electronic, permission to print one copy is hereby granted

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

 2000 Microsoft Corporation All rights reserved

Microsoft, PowerPoint, Visual Interdev, and Windows are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A and/or other countries

The names of companies, products, people, characters, and/or data mentioned herein are fictitious and are in no way intended to represent any real individual, company, product, or event, unless otherwise noted

Other product and company names mentioned herein may be the trademarks of their respective owners

Program Manager: Steve Merrill

Instructional Designers: Sangeeta Nair (NIIT), Vijayalakshmi Narayanaswamy (NIIT)

Subject Matter Experts: Andy Olsen (QA Training), Andy Longshaw (Content Masters)

Content Lead: Janet Robinson

Graphic Artist: Scott Serna (Creative Assets)

Media Management: David Mahlmann

Media Production: Dean Connolly (Art Source), Timothy Demmon (:timebomb Media)

Editing Manager: Jennifer Linn

Editor: Dennis Rae (Wasser)

Production Manager: Miracle Davis

Print Coordinator: Marlene Lambert (Online Training Solutions, Inc)

Build Manager: Julie Challenger

Build Coordinator: Jenny Boe

Test Lead: Eric Myers

Manufacturing Manager: John Williams

Group Product Manager: Steve Elston

Trang 3

Instructor Notes

This module provides students with an introduction to XML The module describes some of the problems currently facing organizations that need to store data and interchange it between applications, and then shows the syntax for an XML document

By the end of this module, students should appreciate the problems that XML solves, and be comfortable with the syntax for elements, attributes, and namespaces in a static XML document Students should also be aware of the standardization process overseen by the World Wide Web Consortium (W3C), and be made aware of Microsoft’s position with regard to these standards After completing this module, students will be able to:

! List the uses for XML on a Web site

! List advantages and disadvantages of using XML

! Describe the structure of an XML document

! Create a simple XML document

! List some of the issues associated with designing XML documents

Materials and Preparation

This section provides you with the required materials and preparation tasks that you need to teach this module

Required Materials

To teach this module, you need the following materials:

! Microsoft PowerPoint® file 1905a_01.ppt

! Module 1, “Overview of XML Documents”

Preparation Tasks

To prepare for this module, you should:

! Read all of the materials for this module

! Study the LitWare Books lab solution Students complete this lab during the course The lab solution is introduced in this module to set the scene for the rest of the course

! Visit the W3C Web site at http://www.w3.org and the OASIS Web site at http://www.oasis-open.org/cover to familiarize yourself with the layout and scope of these Web sites

! Visit Microsoft’s XML Web site at http://msdn.microsoft.com/xml to familiarize yourself with its layout and scope

Presentation:

120 Minutes

Lab:

00 Minutes

Trang 4

Demonstration

This section provides demonstration procedures that will not fit in the margin notes or are not appropriate for the student notes

Demonstration: Creating and viewing an XML document

! To run this demonstration

1 In Notepad, open the file Employees.xml from the folder

\InetPub\WWWRoot\1905\DemoCode\Mod01

Describe the syntax of the document

2 Launch Microsoft Internet Explorer 5 and open Employees.xml Show that you can collapse and expand the nodes of the tree in Internet Explorer 5

3 Make some errors in Employees.xml, such as changing the capitalization of

an element or deleting a closing tag, and redisplay the file in Internet Explorer 5 to show how the browser handles documents that are not well formed

4 In Internet Explorer 5, open the file Macbeth.xml from the folder

\InetPub\WWWRoot\1905\DemoCode\Mod01

5 Describe the elements in the document and explain why XML is well suited for representing structured data such as the entire contents of Shakespeare’s

play Macbeth For example, with the data in XML, you could easily add

lighting instructions for a stage performance of the play

6 In Internet Explorer 5, open the file WeatherReport.xml from the folder

\InetPub\WWWRoot\1905\DemoCode\Mod01 and point out that the document uses a mixture of elements and attributes

Do not talk about the design issues around using attributes or child elements just yet

Demonstration: The LitWare Books application

In this demonstration, describe the functionality of the LitWare Books application and the technologies that are used for each step

! To run this demonstration

1 Launch Internet Explorer 5 and enter the URL for the LitWare Books solution Web site, http://localhost/LitwareSolution

In this application, the user looks for books, places selected books into a client-side XML shopping basket, and then posts the XML to the server to order the books

2 On the home page, enter Lars% in the query by author field, and then click Query

QueryInput.htm posts a query to the ASP page Query.asp, which executes

an ADO query and returns matching books as XML, with an attached XSL style sheet, QueryResult.xsl

Trang 5

3 Click one of the Details links

The link passes ISBN information to the ASP page Details.asp The server executes another ADO query and returns an HTML document containing an XML data island with the book details The HTML document uses data binding to display the information

4 Enter a number in the quantity text field, and then click Add to Basket

Details.asp uses client-side DOM script to transform the book information, using TransformBookDetails.xsl, into a format expected by the server, and then adds the transformed data to a client-side XML data island stored in default.htm

5 Click View Order

ViewOrder.htm uses client-side DOM script to traverse the client-side data island and build an HTML string describing the shopping basket contents

6 Click Go to Checkout Enter customer number 1, and then click Submit Order

Checkout.htm posts the XML shopping basket data to the ASP page CustomerOrder.asp The server validates the data with the schema CustomerOrderSchema.xml, enters the order information into the database, and then returns a confirmation message to the client

Other Activities

This section provides procedures for implementing interactive activities to present or review information, such as games or role-playing exercises

Practice: Creating an XML document

Have students work on their own to create a well-formed XML document describing an airline ticket Then display a couple of different documents and talk about the different elements and attributes used in each

The following is one solution to the practice exercise:

Trang 6

Module Strategy

Use the following strategies to present this module:

! Structuring Data The purpose of this section is to present a backdrop for XML Describe the problems currently facing information processing so that students appreciate the need for XML The key point to stress is that data is meaningless unless you know the context of the data, and XML offers a way of providing that context

of the data XML is not replacing HTML

Discuss the benefits to the server in delivering XML rather than HTML The server can send the same XML file to any browser, rather than generating a different version of HTML for each browser

Also discuss the benefits to the browser in retrieving XML The client can perform local filtering, reordering, changing display formats, and so on without involving the server

! Creating XML Documents This section introduces the basic syntax for XML elements and attributes and the difference between a well-formed and a valid XML document Discuss the overall format of an XML document Emphasize the XML declaration and the fact that a document can only have a single root element

Do not go into too much detail on DTDs yet — they are discussed in Module 2: Overview of XML Technologies

Don’t go into too much detail about Microsoft’s toolset for XML Many of these tools are covered later in the course

In the practice, students are asked to design their own XML documents After completion, compare various solutions to see how different they are Finally, describe some of the reasons for choosing between elements and attributes in an XML document Don’t allow students to get too bogged down in this discussion, as there are no tried and true guidelines available yet

! Grammars and Namespaces Discuss the benefits of having “standard” grammars for particular business sectors For some examples, you can visit http://www.oasis-open.org/coverand navigate to the XML Applications page, where a large number of existing grammars are described

Ask students what problems might arise if two companies decide to define their own grammars For example, there is the possibility of name clashes Describe namespaces as a way of resolving these clashes Discuss qualified namespaces first (that is, with a namespace prefix), then discuss default namespaces (that is, no namespace prefix)

Trang 7

# Overview

! Structuring Data

! What is XML?

! Creating XML Documents

! Grammars and Namespaces

! Demonstration: The LitWare Books Application

! Review

This module provides an overview of the Extensible Markup Language, or XML You will learn about the need for XML documents in e-commerce and Information Technology, and see how to create a simple XML document containing a few basic elements and attributes

XML is an evolving standard governed by the Worldwide Web Consortium (W3C) This module describes the current state of the technology and highlights some of the industry initiatives that are helping to take XML forward into the future

After completing this module, you will be able to:

! List the uses for XML on a Web site

! List advantages and disadvantages of using XML

! Describe the structure of an XML document

! Create a simple XML document

! List some of the issues associated with designing XML documents

documents The module

also looks at some of the

available tools and

discusses current trends in

the XML community

Delivery Tip

There are no labs in this

module, only practices

Trang 8

# Structuring Data

! Structured vs Unstructured Data

! Problems with Information Processing

! Searching Data

! The Need for XML

! Describing Data with XML Tags

The growth and power of the Web lies in its ability to let us communicate with anyone, anywhere This became possible only through standard technologies such as Internet Protocol (IP), Hypertext Transport Protocol (HTTP), and Hypertext Markup Language (HTML), all of which are platform-independent However, today we use the Web primarily as a medium to access and display information in the form of text and graphics The Internet must expand its role

to link applications across the entire Web in such a way that any application anywhere can communicate with any other application or set of data This is the key to making the Web the backbone for business-to-business and organization-to-organization communication

For example, the Internet should allow the exchange of electronic payment information, or of patient medical data and prescriptions between doctors and pharmacists

Today, HTML is widely used as the vehicle for exchanging information on the Web There is no doubt that HTML is very good as a presentation language, but

it is not suitable for representing data For example, you can easily format data

in an HTML table, but you cannot describe the individual components of the information To share information between applications, you must have a language that can describe data in a standard way so that any application, present or future, can understand and use this data correctly

In this section, you will learn about the problems inherent in handling unstructured data, and how XML helps you structure your data

between different Web

applications, and how XML

overcomes these problems

Trang 9

Structured vs Unstructured Data

! Data without context is meaningless and open

Typically, application programs that manipulate data contain business rules that define the context of the data However, when data is exchanged between applications, there is always the threat of its being misinterpreted

Such problems can be handled to a certain extent within an organization through the use of data dictionaries and other standards However, with the advent of the Internet, there is a growing need for information to be shared electronically between organizations

To facilitate an open exchange of data, you must first define the structure of the data in detail and then expose it to other applications The term “metadata” means data about data Metadata provides a context for data that is shared between applications, thus enabling these applications to interpret the data meaningfully

Slide Objective

To explain the need for

structured data

Lead-in

Much of the information we

use every day makes sense

only because we know the

context of its usage

Trang 10

Problems with Information Processing

! Creating and distributing valuable document information

! Generating multiple output formats

! Integrating multiple sources of information

! Managing conditional information

When it comes to processing and delivering information, most organizations and businesses typically face the following problems:

! Creating and distributing valuable document information Organizations that distribute information of great value include publishers

of technical, medical, legal, or business data, and manufacturers of complex products whose operating and service manuals are vital companions to the products themselves

These organizations invest heavily in the creation and distribution of information that their customers consider crucial As a result, the organizations gain maximum benefit from methods that increase the accuracy, timeliness, and flexibility of their information while reducing production and maintenance costs

! Generating multiple output formats There is a growing need for a format-independent method of generating multiple outputs such as printed documentation, update bulletins, CD-ROM distribution, online (Internet) delivery, on-demand printing, Help files, and machine-readable data

! Integrating information from multiple sources When information must be collected from multiple sources, the effort invested in integrating this information is substantially reduced if all sources use a common formatting method agreed upon within a common-interest community, rather than multiple varied formats

! Managing conditional information

If the information in a document varies depending on external factors, such

as service instructions that vary according to the weather, we need a way of identifying the information that is dependent on these external factors There must be a means of managing this conditional operation so that the

appropriate document contents are produced in all circumstances

businesses face many

challenges in dealing with

information

Delivery Tip

Separates content of data

from display of data

Trang 11

Searching Data

! Search engines often yield irrelevant results

! HTML-based search engines (AltaVista, Lycos)

! Need for more intelligent search engines

Worse still, such a search will turn up all kinds of other documents containing those two words, such as press releases from Bath-based companies holding meetings in hotels Unsatisfying results like these are not necessarily caused by

a bad search query or algorithm, but are more likely due to the limitations of HTML-based search engines

Popular HTML-based search engines such as AltaVista and Lycos rely on keyword or even content searches to isolate information, because all they have

to work with is the HTML However, when it comes to context-based searches, these search engines can be way off-target This is because HTML is simply a presentation language: Its function is not to describe the content of a page, but how that content will be displayed

What is needed is a language that provides a means of describing data in a more meaningful and contextual manner so that searches can be one of the following:

What quality of results have

you experienced when using

standard Internet search

engines?

Trang 12

The Need for XML

! Businesses need a way of organizing data that meets these requirements:

! XML fulfils these requirements

Businesses today face many problems when it comes to organizing data They need to meet the following requirements:

! Data needs to be readable by both computers and users

! Both the content and the structure of the data need to be defined

! The relationship between data needs to be emphasized

! The structure of the data needs to be separate from the presentation of the data

! The structure needs to be open and extensible

XML fulfills all of these requirements

XML defines the structure of data in an open and self-describing manner This allows data to be easily transferred over a network and consistently processed

by the receiver Because XML is used to describe information as well as to structure it, you can think of XML as a data-description language You can use XML to describe data components, records, and other data structures, for example, complex data structures such as purchase orders

XML is considered a markup language because it allows you to define data structure by using markup tags You can define your own tags that describe the data in whatever way you find useful This is unlike HTML, where the tags describe how the data should be presented rather than what the data is XML gives you complete control over the document structure, and the presence of tags makes it easier for other applications to ascertain the meaning of the data and process it accordingly

Slide Objective

To state the need for XML

Lead-in

Let’s summarize the need

for XML before we learn

how to create XML

documents

Trang 13

XML data is held in a simple, open format that is easily parsed by other applications The fact that XML documents contain text rather than binary data

is another key advantage Applications can parse an XML document, looking for specific tags of interest to those applications Unknown tags and their associated data can be freely ignored

To summarize, XML can be described as a framework for producing text documents, with embedded tags to define the structure of the data XML is extensible because the set of tags supported in XML is open-ended

Trang 14

Describing Data with XML Tags

! Documents consist of three components

Structure Presentation Data

! XML documents retain structural information about the document contents

! XML documents do not define presentation format

One of the reasons why XML has emerged so quickly as an exciting new technology is that it recognizes that documents are made up of three distinct components:

! Data For example, a word-processor document contains text, punctuation, and white space

! Structure For example, word-processor documents have a different structure than spreadsheets, which in turn have a different structure than presentation files The structure of a document defines the document type, the organization of its elements, and the allowed types and ordering of elements within the document

! Presentation How is the information presented to the user? What fonts are used? What colors are required for the foreground and the background?

The XML approach is to keep these three document components separate from each other, in contrast to the way documents traditionally have been handled Consider a word-processor document as an example:

! A word-processor document combines data content (words) with presentation information (fonts) in an almost inseparable manner When you create a word-processor document, you usually have a particular output medium in mind For example, you might adjust your table sizes and margins so that the document looks attractive on Letter-size paper But what happens if you need to print the document on A4-size paper?

Slide Objective

To describe how XML tags

can be used to add meaning

to data in a document

Lead-in

XML documents help retain

the real meaning of data

Delivery Tip

This slide is animated so

that it shows each part of

the illustration in stages

The slide initially shows only

the first bullet point

Click the numbers to reveal

the following parts of the

illustration:

1 The “Data” picture

2 The “Structure” picture

3 The “Presentation” picture

4 The second bullet point,

“XML documents retain the

structural ”

5 The third bullet point,

“XML documents do not

define presentation ”

Trang 15

! A word-processor document contains very little information about the structural content of a document It would be difficult to write an application

to automatically interpret the content of a document and extract semantic meaning from it

The XML approach considers the inherent structure of a document to be as important as the content itself Presentation information is kept separate from the content and structural information

Trang 16

Slide Objective

To provide an overview of

the topics in this section

Lead-in

This section introduces the

syntax for XML documents,

and compares XML with

HTML documents

Trang 17

History of XML and W3C

! XML is a simplified subset of SGML

! The XML standards are governed by the World Wide Web Consortium (W3C)

XML is based on the Standard Generalized Markup Language (SGML), which was defined in 1986 by the International Standards Organization (ISO) as standard ISO 8879 SGML has been used since then across a wide range of industry sectors and in many different formats, one of which is HTML

The objectives of those who designed SGML were simple: Confronted with an increasing number of so-called “markup languages” for electronic texts, each more or less bound to a particular kind of processing or even to a particular software package, they sought to define a single language in which all such schemes could be re-expressed so that the essential information represented by such texts could be transferred from one program or application to another The intention is to allow the clear indication of parts of a document (for instance, subheadings) in such a way that they can be processed automatically, for example, for checking that two subheadings of the same rank do not occur consecutively without intervening subsection body text, or for the creation of tables of contents Further applications might include the annotation of a document to enable statistical analysis of names, dates, or other elements SGML is a very powerful standard for markup languages, but is rather complex

to use Its complexity has prevented it from being used as widely as one might hope XML is a subset of SGML XML simplifies SGML significantly, retaining its good points but making it easier to learn and use by the wider developer community

XML is in the process of standardization by the World Wide Web Consortium (W3C) W3C is a vendor consortium responsible for inviting, creating, setting, and broadcasting standards for use on the World Wide Web and elsewhere For more information about the XML standard, see http://www.w3c.org and http://www.xml.org

Trang 18

XML and the Web

! XML can be used for HTTP transactions

! Benefits of generating XML at the Web server

! Benefits of receiving XML at the browser

XML can be used to define a standard data format for HTTP-based transactions between Web browsers and Web servers XML can also lighten the load on Web servers

The traditional Web model makes servers work very hard to communicate streams full of HTML back to the client browser This load on the server inevitably degrades performance, and consequently the browser spends much of its time waiting for the Web server to do its work and return the HTML

One solution to this problem might be to use a bigger server, but this solution addresses only the symptom of the problem, not the cause XML can be used to address the real issue by lightening the load on the server in the first place

! The Web server delivers XML documents rather than raw HTML to the browser The server can send the same XML document to all browsers, because the data is the same in each case This is in contrast to the situation when HTML is returned; in this situation, the server must ascertain what type of browser is involved and then generate a suitable stream of HTML for that type of browser

! The Web server can attach a style sheet to the XML data in order to transform the XML document into an appropriate format of HTML when it

is received at the browser This transformation occurs at the browser, so it does not impose any run-time overhead on the server

In addition to XML lightening the load on the server, there are also benefits to

be found at the browser if it receives XML data The browser can manipulate XML data in an intelligent manner, because XML data contains meaningful tags that can be accessed and manipulated in client-side script

This reduces the number of times the browser has to communicate with the server in order to process data or retrieve a different view of the data Much of this work can now be achieved by using client-side script

Trang 19

XML vs HTML

! HTML only describes how to display data

! XML defines the meaning of data

XML describes data In this respect, XML is very different from HTML

! HTML documents contain tags that provide the browser with information

on how the data should be displayed The set of tags allowed in an HTML document is well defined, and is fixed You cannot define new types of elements in HTML

For example, the following HTML displays data in a two-column table However, it does not dictate the type of data in the table

Slide Objective

To introduce the similarities

and differences between

XML and HTML

Lead-in

Superficially, XML looks

very similar to HTML

However, XML has a very

different purpose than

HTML

Trang 20

For example, the following XML contains information about an employee but does not dictate how to display the data:

Trang 21

Advantages and Disadvantages of XML

XML makes it easier to exchange information between applications within the same organization or between different organizations XML is also useful as a means of integrating diverse sources of information and presenting a uniform interface to this data

However, XML is not a general solution for all problems Like all technologies,

it has its own set of advantages and disadvantages

Advantages

! Extensible You can add your own tags to an XML document

! Interoperable XML does not depend on the operating system, language, or data source of applications that use it

! Self-describing data The intention with XML is that the data is self-describing, so that its structure is easily identified in future applications

Disadvantages

! Defines structure but limited semantics XML documents define the structure of the data but do not describe how to manipulate that data For example, you can design an XML document so that it has an <address> element, but there is no facility in XML to specify what sort of address should be supplied For example, the XML document might have an <address> element holding a person’s home address or email address

Slide Objective

To weigh the advantages

and disadvantages of XML

Lead-in

XML is not a solution for

every known problem Let’s

take a look at some of its

strong points and limitations

Trang 22

! Some aspects of XML are not yet standard XML is a relatively immature technology, and the XML standard is still evolving in certain key areas For example, the way in which XML documents are validated by using XML schemas has not yet been finalized

of XML to use in their applications

Trang 23

Uses of XML

! Automation of business processes

! Information distribution

! Knowledge management

! Application and data integration

XML has many applications, some of which are described here

Automation of business processes

The highly structured nature of XML means that it can work well as a exchange mechanism in loosely coupled systems This typically refers to the business-to-business area that Electronic Data Interchange (EDI) has occupied for a long time Using the Internet as a transport medium, XML can provide the functionality of EDI for a fraction of the cost

data-For more information about how XML can be used with EDI, see the Web site http://www.xmledi.org

Information distribution

Information distribution plays an important role in the competitiveness of many organizations In a typical business scenario, information needs to be distributed internally to employees, externally to business partners and clients, and more widely to the general public

The Web provides a convenient infrastructure for disseminating this information However, HTML is not well suited for information distribution because it does not retain the true meaning of the data This makes localized processing of the data difficult

XML overcomes the limitations of HTML Coupled with the use of XSL style sheets to describe how the data should be displayed, XML documents allow for true information distribution within and outside an organization

Knowledge management

Organizations have a tremendous amount of accumulated knowledge locked up

in the heads of their employees How can this knowledge be tapped and used to the organization’s advantage?

Trang 24

Many companies use knowledge-management systems to catalog vital areas of knowledge, and to make this information available to other employees This helps others gain from the experience of their colleagues, to identify and solve recognized problems more quickly

One of the difficulties in adopting a knowledge-management system is how to model that knowledge There is also the question of how to make maximum use

of existing documents within the organization Once the information has been captured, another issue arises: How can you make this information available and searchable?

XML addresses all these issues It provides the scope for you to define an XML document structure that makes sense for your organization XML is also good

at integrating existing documentation Finally, the tagged nature of XML makes

it suitable for searching for data in context

Application and data integration

Most organizations use off-the-shelf packages for many of their business processes Integrating these applications to further improve automation within

an organization has traditionally been a costly and time-consuming exercise XML makes it easier to integrate applications because it allows a basic messaging framework between applications Data can be input into an application in XML, and the results of the application can be represented as XML

Many applications already support XML import/export facilities XML seems poised to become the standard means of integrating systems in the future

Trang 25

! Demonstration: Creating and Viewing an XML Document

! Practice: Creating an XML Document

! Mapping a Data Specification

In this section, you will learn about the syntax of XML documents and how to create a well-formed XML document

Slide Objective

To provide an overview of

the topics in this section

Lead-in

In this section, you will learn

how to create a well-formed

XML document

Ngày đăng: 22/10/2013, 16:15

TỪ KHÓA LIÊN QUAN