Module 1: Overview of XML Documents - Pdf 69


Contents
Overview 1
Structuring Data 2
What is XML? 10
Creating XML Documents 19
Grammars and Namespaces 36
Demonstration: The LitWare Books
Application 42
Review 43

Module 1: Overview of
XML Documents Information in this document is subject to change without notice. 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. 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

Manufacturing Manager: John Williams
Group Product Manager: Steve Elston

Module 1: Overview of XML Documents iii 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

00 Minutes
iv Module 1: Overview of XML Documents 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.

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:
<?xml version="1.0"?>
<ticket>
<passenger>
<name>Sue Jackson</name>
</passenger>
<leg>
<flight carrier="Blue Yonder Airways" number="123" />
<frequent_flyer>112890FN</frequent_flyer>
<meal type="vegetarian" />
<departure date="2/1/00" time="1:00pm">
<airport>SEATAC</airport>
</departure>
<arrival date="2/1/00" time="3:00pm">

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 />
and 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).


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.

Slide Objective
To provide an overview of
the module topics and
objectives.
Lead-in
This module introduces the
need for XML in e-
commerce, and shows how
to create simple XML
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.
2 Module 1: Overview of XML Documents

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.
Slide Objective
To provide an overview of
the topics in this section.
Lead-in
This section explains the
problems inherent in
exchanging information
between different Web
applications, and how XML
overcomes these problems.
Module 1: Overview of XML Documents 3 Structured vs. Unstructured Data
!
Data without context is meaningless and open
to misinterpretation
!
Structured data allows other applications to understand

4 Module 1: Overview of XML Documents Problems with Information Processing
!
Creating and distributing valuable
document information
!
Generating multiple output formats
!
Integrating multiple sources of information
!
Managing conditional informationWhen 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
Searching Data
!
Search engines often yield irrelevant results
!
HTML-based search engines (AltaVista, Lycos)
$
Good for keyword search
$
Not appropriate for context-based search
!
Need for more intelligent search engines
$
Intelligence-based searches
$
Meaning-based searches
$
Context-based searchesAnyone who has carried out an Internet search knows that currently available
search engines often yield irrelevant results. For example, if you search the
Web today for all hotels in the city of Bath, you may get a list of all hotels that
have bathrooms (presumably quite a long list) while missing hotels that are near
the city but not actually in it.
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

Businesses need a way of organizing data that meets
these requirements:
$
Machine-readable and human-readable data
$
Defines the data content and structure
$
Emphasizes relationships
$
Separates structure from presentation
$
Open and extensible
!
XML fulfils these requirementsBusinesses 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.


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.
8 Module 1: Overview of XML Documents Describing Data with XML Tags
!
Documents consist of three components
Structure PresentationData
!
XML documents retain structural information about
the document contents
!
XML documents do not define presentation formatOne 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.

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...”
Module 1: Overview of XML Documents 9 !
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.
10 Module 1: Overview of XML Documents #
##
#

What is XML?

$
Standard Generalized Markup Language
$
ISO standard defined in 1986
!
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,

Browser can use the data intelligently
$
Reduces network traffic and server loadXML 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

</employee>
<employee>
<name>Jake</name>
<salary>25000</salary>
<region>Ohio</region>
</employee>
<TABLE>
<TR>
<TD>Name</TD><TD>Jake</TD>
</TR>
<TR>
<TD>Salary</TD><TD>25000</TD>
</TR>
<TR>
<TD>Region</TD><TD>Ohio</TD>
</TR>
</TABLE>
<TABLE>
<TR>
<TD>Name</TD><TD>Jake</TD>
</TR>
<TR>
<TD>Salary</TD><TD>25000</TD>
</TR>
<TR>
<TD>Region</TD><TD>Ohio</TD>
</TR>
</TABLE>
and differences between
XML and HTML.
Lead-in
Superficially, XML looks
very similar to HTML.
However, XML has a very
different purpose than
HTML.
14 Module 1: Overview of XML Documents For example, the following XML contains information about an employee
but does not dictate how to display the data:
<employee>
<name>Jake</name>
<salary>25000</salary>
<region>Ohio</region>
</employee>


Nhờ tải bản gốc
Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status