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

Tài liệu Module 8: Exchanging Business Data ppt

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 (1.04 MB, 92 trang )






Contents
Overview 1
Exchanging Data 2
Manipulating XML 7
Lab 8.1: Building B2B Services 19
Using SQL Server 2000: Internet and
XML Support 24
Introducing BizTalk 38
Overview of BizTalk Server 2000 44
Lab 8.2: Creating Business Document
Specifications Using BizTalk Editor 52
Using BizTalk Server 2000 56
Lab 8.3: Creating Transformation Maps
Using BizTalk Mapper 63
Lab 8.4: Creating Business Document
Specifications Using BizTalk Orchestration
Designer 77
Review 86

Module 8: Exchanging
Business Data

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
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.

 2001 Microsoft Corporation. All rights reserved.

Microsoft, Active Directory, ActiveX, BizTalk Server, FoxPro, FrontPage, Hotmail, Jscript,
Outlook, PowerPoint, Visio, Visual Basic, Visual C#, Visual C++, Visual Studio, Windows, and
Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the
U.S.A. and/or other countries.

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


Module 8: Exchanging Business Data iii

Instructor Notes
This module focuses on data exchange formats and how to exchange data
between diverse systems. The module covers Extensible Markup Language
(XML) and explains it as the most ideal and universal format for exchanging
business data. The module also goes into details about how XML, as an
industry standard, is supported by Microsoft. Specific products covered here are
Microsoft
®

SQL Server

2000 and Microsoft BizTalk

Server 2000.
After completing this module, students will be able to:

Describe the common types of data exchanged as part of business-to-
business (B2B) solutions.

Identify the advantages of using XML as a data-interchange format.

Explain the purpose of XML schemas.

Describe how business documents can be converted between grammars by
using Extensible Stylesheet Language Transforms (XSLT).

Identify the features in SQL Server 2000 that make it Web enabled.

Identify the role of the Microsoft BizTalk Framework.

Describe the main parts of a BizTalk message.

Explain how to set up mappings between BizTalk document types.

Describe how BizTalk documents are sent, received, and routed.

Materials and Preparation
This section provides the 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 2260A_8.ppt

Module 8, “Exchanging Business Data”

Lab 8.1, “Building B2B Services”

Lab 8.2, “Creating Business Document Specifications Using BizTalk
Editor”

Lab 8.3, “Creating Transformation Maps Using BizTalk Mapper”

Lab 8.4, “Creating Business Document Specifications Using BizTalk
Orchestration Designer”

Preparation Tasks
To prepare for this module, you should:

Read all of the materials for this module.

Complete the labs.

Presentation:
80 Minutes

Labs:

95 Minutes
iv Module 8: Exchanging Business Data

Module Strategy
Use the following strategy to present this module:

Exchanging Data
Ensure that the students understand the basic concepts and issues that come
up with exchanging data between organizations. Outline the different
formats available for data exchange, and conclude that XML is the format
that will be used in modern B2B solutions.Stress the advantages of using
XML for this type of solution.
Cover the example of the Purchase Order as described in this section
because this will help the students design their own purchase order in Lab
8.2, “Creating Business Document Specifications Using BizTalk Editor.”

Manipulating XML
It is fundamental to this module that the students understand the different
mechanisms that are available to manipulate XML structures. The focus of
this section is manipulating XML on the server for B2B purposes. Describe
the mechanisms such as XSLT and the Document Object Model (DOM),
but keep the context in which you discuss these technologies in the B2B
area. Do not discuss using XSLT for display purposes because this is not
relevant here.

Lab 8.1, “Building B2B Services”
This lab prepares the foundation for a B2B procurement solution. It involves
creating Web sites and message queues and compiling Component Object
Model (COM) components. The students might find this lab easy to
complete because they may have carried out all or most of these tasks at

their workplace before.

Using SQL Server 2000: Internet and XML Support
Discuss SQL Server 2000 Internet and XML support features. Do not go
into any more detail about SQL Server 2000 than what is covered here. The
important features of SQL Server are XML support and the support for
accessing SQL Server by using the Hypertext Transfer Protocol (HTTP).
Both of these are new features of SQL Server 2000 and are major
contributions to its status as a Microsoft .NET-enabled Relational Database
Management System (RDBMS).

Introducing BizTalk
Describe the BizTalk initiatives. It is critical that the students understand the
concept of the BizTalk Framework and initiatives because they lay the
groundwork for understanding how businesses can exchange data in an
open, extensible manner. This section must be used to set the stage for
discussing the BizTalk-compliant exchange of data. Do not discuss BizTalk
Server 2000 or its functionality in any detail in this section. BizTalk
Server 2000 is covered in detail in the next section.

Overview of BizTalk Server 2000
Describe the constituent parts of BizTalk Server 2000 at a high level.
Introduce the services and components of BizTalk Server 2000. Do not go
into any more detail than what is provided in this section because some of
the components and services are discussed in more detail (and in a B2B
context) in the next section.
Module 8: Exchanging Business Data v


Lab 8.2, “Creating Business Document Specifications Using BizTalk

Editor”
In this lab, the students will use BizTalk Editor to complete a partially filled
document specification. You must tell the students that in the real world,
they would have to create the whole specification from scratch.
Building a specification from scratch would be very repetitive in terms of
lab instructions. Therefore, a partially filled specification has been provided.
The instructions are step by step, and the students should find them clear
and easy to follow. However, it is likely that this is the first time that many
of them are using BizTalk Editor.

Using BizTalk Server 2000
Discuss in detail the services and components of BizTalk Server 2000.
Begin with a discussion of the services provided, and then overview each of
its components. Taking your lead from the topics in this module, delve into
more depth about each of the components, such as BizTalk Editor, BizTalk
Mapper, and BizTalk Orchestration Designer.
Conclude this section with a discussion of BizTalk Orchestration and
integration with existing Electronic Data Interchange (EDI) systems.

Lab 8.3, “Creating Transformation Maps Using BizTalk Mapper”
In this lab, students will create XSLT maps by using BizTalk Mapper. They
will use the document specifications that they created in the previous lab.
The instructions are step by step, and the students should find them clear
and easy to follow. However, it is likely this is the first time that many of
them are using BizTalk Mapper.

Lab 8.4, “Creating Business Document Specifications Using BizTalk
Orchestration Designer”
In this lab, students will implement BizTalk Orchestration from the
perspective of the business analyst and the developer. They will use BizTalk

Orchestration Designer to synchronize all of the tasks that they have
undertaken in the previous three labs.
The instructions are step by step, and the students should find them clear
and easy to follow. However, it is likely that this is the first time that many
of them are using BizTalk Orchestration Designer.


Module 8: Exchanging Business Data 1

Overview

Exchanging Data

Manipulating XML

Using SQL Server 2000: Internet and XML Support

Introducing BizTalk

Overview of BizTalk Server 2000

Using BizTalk Server 2000

*****************************I
LLEGAL FOR
N
ON
-T
RAINER
U

SE
*****************************
To exchange business data between applications, you must carefully choose the
format of the data. Although a variety of formats exist, the Extensible Markup
Language (XML) has emerged as the most ideal and universal format for data
exchange.
In this module, you will learn how XML can be used to exchange information
and how XML documents can be manipulated, validated, and transformed.
Also, you will be introduced to the Microsoft
®
BizTalk

Framework, an
important development that defines the next generation of business-to-business
(B2B) solutions. You will learn about the role of and the need for the BizTalk
Framework and examine the structure of BizTalk messages and schemas.
Finally, you will learn about the functionality and tools provided with Microsoft
BizTalk Server 2000.
After completing this module, you will be able to:

Describe the common types of data exchanged as part of B2B solutions.

Identify the advantages of using XML as a data-interchange format.

Explain the purpose of XML schemas.

Describe how business documents can be converted from one grammar to
another by using Extensible Stylesheet Language Transforms (XSLT).

Identify the features in Microsoft SQL Server


2000 that make it Web
enabled.

Identify the role of the BizTalk Framework.

Describe the main parts of a BizTalk message.

Explain how to set up mappings between BizTalk document types.

Describe how BizTalk documents are sent, received, and routed.

Topic Objective
To provide an overview of
the module topics and
objectives.
Lead-in
To exchange business data
between applications,
thought must be given to the
format of the data.
2 Module 8: Exchanging Business Data





Exchanging Data

Types of Business Documents


Data-Exchange Formats

*****************************I
LLEGAL FOR
N
ON
-T
RAINER
U
SE
*****************************
Business data comes in a variety of formats. This section examines the types of
business data that can be exchanged between applications and discusses the
options for how this data can be represented.
Topic Objective
To introduce the topics in
this section.
Lead-in
Business data is available in
a variety of formats.
Module 8: Exchanging Business Data 3

Types of Business Documents

Examples of Document Types

Purchase orders

Invoices


Delivery notes

Requests for price quotes

The details in a purchase order can be grouped into:

Header information

Shipment details

Payment collections

Payment reminders

Product offers

List of items

Total cost of the order

*****************************I
LLEGAL FOR
N
ON
-T
RAINER
U
SE
*****************************

Many different types of documents are exchanged between applications and
organizations in e-business.
Examples of Document Types
Some of the document types that are used in e-business data exchange are as
follows:

Purchase orders

Invoices

Delivery notes

Requests for price quotes

Payment collections

Payment reminders

Product offers

Examining a Sample Document Type: Purchase Orders
A purchase order usually has header information at the beginning, which
specifies the following details:

Purchase order issue date

Buyer reference number

Supplier reference number


Details of the buyer, such as name and address

Tax details, such as tax percentage, location (for sales tax calculations), tax
code, taxable amount, and total tax payable

Order currency

Topic Objective
To discuss the various types
of business documents.
Lead-in
Many different types of
documents are exchanged
between applications and
organizations in e-business.
4 Module 8: Exchanging Business Data

A purchase order also contains shipment details, such as the following:

Delivery charge details

Whether partial shipment is allowed

Requested delivery date

Details of the ship-to party, such as the order contact name and address, and
the receiving contact name and address

Transport type, for example, “road” or “air”


The rest of the purchase order consists of the list of items being purchased. For
each item, the following details are typically provided:

Item number in the purchase order (1, 2, 3, and so on)

Supplier part number

Quantity required, including unit of measurement

Buyer's expected unit price

Final recipient for this order item

Requested delivery date

Any special handling required for this item, such as fragile, hazardous, and
so on

Finally, the total cost of the order is usually specified at the bottom of the
purchase order.
Module 8: Exchanging Business Data 5

Data-Exchange Formats

EDI

Custom Data Format

XML


Sample XML code
<items>
<item>
<description>Make widgets</description>
<details unit-cost="1.67" quantity="150"/>
</item>
<item>
<description>Fit widgets</description>
<details unit-cost="55.00" quantity="1"/>
</item>
</items>
<items>
<item>
<description>Make widgets</description>
<details unit-cost="1.67" quantity="150"/>
</item>
<item>
<description>Fit widgets</description>
<details unit-cost="55.00" quantity="1"/>
</item>
</items>

*****************************I
LLEGAL FOR
N
ON
-T
RAINER
U
SE

*****************************
Business information can be formatted in a number of ways in B2B solutions:

Electronic Data Interchange (EDI)

Custom data format

XML

EDI
Electronic Data Interchange emerged in the 1970s as an electronic standard for
the exchange of business information. There are several EDI standards that
define the format of messages for a typical business transaction. Perhaps the
most notable EDI standard is EDIFACT (EDI for Administration, Commerce,
and Transport), defined by the United Nations. For more information, see

EDI is used by companies for automated transactions with trading partners.
However, EDI has certain limitations:

EDI is expensive and relatively complex and has therefore been limited to
larger businesses and their partners.
Both the sender and receiver of EDI messages have to agree on the message
format and adopt a tailored software program to map between their two
types of datasets. Whenever a new sender or receiver is added, another
translation program is needed by the new trading partner to understand the
data formats used by the participants. The number of translation programs
required increases with the increase in the number of trading partners.

EDI handles business transactions only.
It does not address the wider business needs of e-commerce, such as

marketing, customer research, and customer loyalty programs.

Topic Objective
To discuss the various
formats available for data
exchange.
Lead-in
Business information can be
formatted in a number of
ways in B2B solutions.
6 Module 8: Exchanging Business Data

Custom Data Format
Organizations may agree upon a custom data format to be used when
exchanging information electronically. The custom data format might be based
on text files, with the use of commas or tabs to identify different pieces of
information. Alternatively, a binary message structure might be used for
increased data compression and processing speed.
Whether a text format or a binary format is used, the limitations of custom data
formats are clear. The sender and receiver of the information need to agree on
the structure of these custom data formats. If the format changes, the sender and
receiver must remain in rigid synchronization to ensure that they are both using
the latest message structure that has been agreed upon. Furthermore, because
the data format is a private agreement between two trading partners, it makes it
difficult for new trading partners to participate in information exchange.
Trading partners can interpret messages only if they are aware of the data
format being used, and therefore, they need to be notified whenever the format
changes. Each trading partner will need translation software to convert their in-
house data formats into the agreed-upon custom data format that is used when
exchanging information with other trading partners.

XML
XML is a text-based language that provides a universal format for describing
data. By using XML, you can retrieve data from legacy applications, relational
databases, object-oriented databases, or other applications in the business. The
data can then be represented in a universal format such as XML, which can be
transmitted to any other system. Because XML documents preserve the
meaning and the context of the data, any application can use this data in an
efficient and useful manner.
XML is the language that is best suited to e-business, and it will play a key role
in the adoption and expansion of online trading between businesses in the
future. Several key initiatives, standards, and toolsets have already been
established, thereby making it easier for companies to conduct document-based
transactions by using the Web.
<?xml version="1.0"?>
<purchase-order po-number="2260a">
<summary from="Trey Research" to="Fabrikam, Inc."
date-raised="01-03-01" />
<items>
<item>
<description>Make widgets</description>
<details unit-cost="1.67" quantity="150"/>
</item>
<item>
<description>Fit widgets</description>
<details unit-cost="55.00" quantity="1"/>
</item>
</items>
</purchase-order>

Example of an XML

document
Module 8: Exchanging Business Data 7





Manipulating XML

Handling Multiple XML Formats

Transforming XML on the Server

Defining XML Grammar

Validating XML Documents

Causes of Invalid XML Documents

*****************************I
LLEGAL FOR
N
ON
-T
RAINER
U
SE
*****************************
XML is an ideal format for e-business communication. Because XML is
descriptive in nature and uses open standards, it is easy for organizations to

exchange XML documents in response to business activities.
This section discusses how to manipulate XML documents and how to
transform XML documents into different formats. You will see how to create
schemas to specify the format of an XML document and how to use these
schemas to validate the content of an XML document.

Topic Objective
To introduce the topics in
this section.
Lead-in
XML is an ideal format for
e-business communication.
8 Module 8: Exchanging Business Data

Handling Multiple XML Formats

Issues with XML

The Need for Standards

Transforming XML Document Types

One XML format to another XML format

XML to EDI

*****************************I
LLEGAL FOR
N
ON

-T
RAINER
U
SE
*****************************
XML resolves many of the difficulties encountered when dealing with disparate
data, including:

XML documents can be routed between trading partners, with each of them
being able to extract, interpret, and augment the information in the
document.

Data can be collected in an XML format from various Web sites, integrated,
and then presented to the client in a uniform manner.
For example, you can create a Web site that provides information on the
most inexpensive cars available by gathering data from other Web sites.

Legacy systems can be integrated by generating the data in XML format.

Issues with XML
The use of XML raises its own issues:

Who defines the allowed elements and attributes in an XML document?

How do you describe your choice of element names and attribute names so
that other organizations know about the format of your XML documents?

How and where do you publish your document description to make it
readily available to other organizations?


Where do you look to find out about the XML data formats defined by
others?

Because XML is inherently an extensible markup language, different
organizations can (and often do) define their own XML data formats.
It is possible to define a Document Type Definition (DTD) or an XML Schema
to describe the allowed elements and attributes in an XML document. These
concepts are covered in Defining XML Grammar in this module.

Topic Objective
To discuss handling multiple
XML formats.
Lead-in
XML is an ideal format to
use for exchanging business
documents over the
Internet.
Module 8: Exchanging Business Data 9

The Need for Standards
It would be beneficial for all commercial organizations if a set of standard XML
data formats was defined and used consistently in e-business. For example,
there is no need for every company to define its own data formats for common
document types such as invoices, purchase orders, and shipping schedules.
The benefits of defining common data formats can be summarized as follows:

Organizations do not need to invest time and effort defining (and
maintaining) their own data formats.

There is greater consistency between applications because they use a

common data format.

The common data format can be published centrally, thereby relieving
organizations from this responsibility.


The BizTalk initiative includes a Schema Library, in which many
standard document types are held in a centralized repository. Organizations can
use these document types directly, or they can define their own schema and add
it to the library. The BizTalk initiative is discussed later in this module.

Transforming XML Document Types
Although a common set of standard document types is beneficial, it is by no
means essential. The self-describing nature of XML elements and attributes
makes it possible for an application to receive an XML document in any format.
All that is needed by the receiving application to parse the data is a description
of the data format being used so that the application knows how to handle the
data. Indeed, it is quite feasible and straightforward to aggregate XML data in a
variety of formats and transform the data into a new format. The next topic
discusses mechanisms for transforming XML data.
Note
10 Module 8: Exchanging Business Data

Transforming XML on the Server

Techniques for Transforming XML on the Server

XSLT

DOM


Use XSLT for filtering, sorting, and adding elements and
attributes

Use the DOM for complex processing and calculations
<employees>
<employee>
<name>Reid</name>
<salary>91000</salary>
</employee>

</employees>
<employees>
<employee>
<name>Reid</name>
<salary>91000</salary>
</employee>

</employees>
<staff>
<staff-member
name="Reid"
pay="91000"/>

</staff>
<staff>
<staff-member
name="Reid"
pay="91000"/>


</staff>

*****************************I
LLEGAL FOR
N
ON
-T
RAINER
U
SE
*****************************
Because each business uses different formats of XML for common business
documents, you might often need to transform an XML document into a
different format on the server. Such situations, in which XML transformation is
required, are as follows:

An XML document from a trading partner might have to be transformed
into another XML format for use in your system.

An XML document might contain sensitive information that must be
stripped out before passing the document on to a trading partner.

An XML document might need to be transformed into Hypertext Markup
Language (HTML) so that it can be displayed in a browser that does not
support XML.

Techniques for Transforming XML on the Server
You can transform XML data at the server by using the following techniques:

Extensible Stylesheet Language Transforms (XSLT)


Document Object Model (DOM)

As described in the rest of this topic, both techniques have their uses. They can
also be combined into one solution.
Topic Objective
To discuss the techniques
that can be used for
transforming XML on the
server.
Lead-in
Because each business
uses different formats of
XML for common business
documents, you might often
need to transform an XML
document into a different
format on the server.
Module 8: Exchanging Business Data 11

Transformations Using XSLT
An XSLT style sheet can be used to convert an XML document from one
grammar to an XML document in another grammar. By using an XSLT style
sheet, you can perform the following transformations on an XML document:

Filter out unwanted elements and attributes
For example, you can filter out elements such as <WholesalePrice> and
<NumberInStock> in an XML document.

Sort elements

For example, you can sort <Product> elements in increasing price order.
Alternatively, you can sort <Product> elements such that those having a
<Perishable> child element appear first.

Add new elements, attributes, and other XML content to a document
For example, a bookstore might receive an order for a book from one of its
customers. If the book is not in stock, the bookstore can issue an order to the
publisher. At this stage, the bookstore can add extra elements such as
<BookStoreID> and <DeliveryDate> to the XML document.

Transform an XML document into an entirely new format
For example, an organization might receive an XML document from one of
its customers, transform it into a completely new XML format, and then
pass the new-format XML document on to one of its suppliers.
Transformations Using the DOM
XSLT style sheets are powerful, but some transformations are better achieved
by using the DOM in server-side code or script. The DOM defines a
programming interface that allows you to write programs or script to read,
modify, extend, or delete data in an XML document. Some examples in which
using the DOM is more appropriate than using XSLT for transforming and
manipulating XML data are as follows:

Performing complex processing on XML data
It is often appropriate to apply the processing power of languages, such as
Microsoft Visual Basic
®
and VBScript, to manipulate XML data. The
manipulation can be achieved by using the DOM.

Performing calculations with XML data

It is often easier to perform calculations on your XML data values by using
the DOM rather than XSLT. For example, you might wish to calculate the
number of <Item> elements in a <PurchaseOrder>. These calculations can
be achieved easily by using the DOM.


Writing style sheets and using the DOM is quite complex. BizTalk
Server 2000 simplifies these tasks for you.

Note
12 Module 8: Exchanging Business Data

Defining XML Grammar

DTDs

XML Schemas
<!ELEMENT OrderItem (Quantity, UnitPrice) >
<!ATTLIST OrderItem ProductID CDATA #REQUIRED >
<!ELEMENT OrderItem (Quantity, UnitPrice) >
<!ATTLIST OrderItem ProductID CDATA #REQUIRED >
<Schema name="mySchema"
xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:dt="urn:schemas-microsoft-com:xml-datatypes">
<ElementType name="Quantity" content="textOnly"
model="closed" dt:type="int" />
<Schema name="mySchema"
xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:dt="urn:schemas-microsoft-com:xml-datatypes">
<ElementType name="Quantity" content="textOnly"

model="closed" dt:type="int" />

*****************************I
LLEGAL FOR
N
ON
-T
RAINER
U
SE
*****************************
One of the key goals of XML is to facilitate the open exchange of information
between applications and organizations. This is possible only if the structure
and the format of these XML documents is defined and published for others to
read and understand.
The two ways to define the expected grammar of an XML document are by
using:

A DTD

An XML schema

DTDs
DTDs are an established standard, specified by the World Wide Web
Consortium (W3C), for defining the elements and attributes that are allowed in
XML documents.
An example of a DTD is as follows:
<!ELEMENT Order (OrderItem+) >
<!ELEMENT OrderItem (Quantity, UnitPrice) >
<!ATTLIST OrderItem ProductID CDATA #REQUIRED >

<!ELEMENT Quantity (#PCDATA) >
<!ELEMENT UnitPrice (#PCDATA) >

The preceding DTD document defines the following rules:

The XML document has an element named <Order>, which contains one or
more <OrderItem> child elements.

Each <OrderItem> has one <Quantity> child element, followed by one
<UnitPrice> child element.

Each <OrderItem> also has an attribute named ProductID, which is
mandatory.
Topic Objective
To discuss defining the
grammar of an XML
document by using DTDs
and schemas.
Lead-in
There are two ways to
define the expected
grammar of an XML
document.
Module 8: Exchanging Business Data 13


The <Quantity> element (defined in <OrderItem>) is simple text.

The <UnitPrice> element (defined in <OrderItem>) is simple text.


Despite the apparent simplicity of DTDs and the fact that they are a mature
standard in W3C, they have several weaknesses, including:

DTDs do not allow data types to be specified for elements or attributes.

DTDs have a closed model.
An XML document specified by a DTD cannot grow to contain additional
information in the future because the extra information is not specified in
the DTD.

DTDs do not support XML namespaces.
Namespaces are required for demarcating XML documents from different
organizations and standards bodies.

DTDs apply to an entire XML document.
It is not possible to apply DTDs to individual XML elements or specific
portions of the document.

XML Schemas
XML schemas can be used to overcome all of the previously listed limitations
of DTDs.
Though W3C expects XML schemas to soon become the successors to DTDs,
XML schemas have not yet achieved the recommendation status in the W3C.
Microsoft offers an interim technology known as XML-Data Reduced (XDR),
and many of the XML documents exchanged in e-business today use this
technology to define the grammar of the XML documents.
14 Module 8: Exchanging Business Data

The following sample schema corresponds to the DTD example shown above.
This schema complies with the XDR schema syntax. Notice that the schema is

itself a well-formed XML document. The root element is <Schema>. The
<Schema> element must always be written exactly as shown in the following
sample code:
<?xml version="1.0"?>
<Schema name="mySchema"
xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:dt="urn:schemas-microsoft-com:xml-datatypes">

<ElementType name="Quantity" content="textOnly"
model="closed" dt:type="int" />
<ElementType name="UnitPrice" content="textOnly"
model="closed" dt:type="float" />
<AttributeType name="ProductID" dt:type="string" />

<ElementType name="OrderItem" content="eltOnly"
model="closed" order="seq">
<element type="Quantity" minOccurs="1" maxOccurs="1" />
<element type="UnitPrice" minOccurs="1" maxOccurs="1" />
<attribute type="ProductID" required="yes" />
</ElementType>

<ElementType name="Order" content="eltOnly" model="closed">
<element type="OrderItem" minOccurs="1" maxOccurs="*" />
</ElementType>

</Schema>

The preceding schema defines the following rules:

The XML document can contain <Quantity> elements, which consist of

only text (that is, no child elements).
<Quantity> elements have an integer data type.

The XML document can also contain <UnitPrice> elements, which consist
of only text.
<UnitPrice> elements have a float data type.

The XML document can contain multiple instances of the ProductID
attribute, which contains a string data type.

The <OrderItem> element can consist of one <Quantity> child element, one
<UnitPrice> child element, and a mandatory ProductID attribute.

The <Order> element can consist of one or more <OrderItem> elements and
no stand-alone textual content.

Schemas are undoubtedly much more verbose than DTDs, but they provide a
much richer and more rigorous definition of the content required in an XML
document. Schemas are soon expected to become the standard means of
defining XML grammars.
Module 8: Exchanging Business Data 15

Validating XML Documents

Well-Formed vs. Valid XML Documents

A well-formed document follows the basic syntax rules of
XML

A valid XML document is well formed and follows the

rules defined in the XML schema/DTD attached to the
document

Applying an XML Schema to an XML Document
<!-- My XML document, with an XML Schema applied -->
<myElement xmlns="x-schema: />…
</myElement>
<!-- My XML document, with an XML Schema applied -->
<myElement xmlns="x-schema: />…
</myElement>

*****************************I
LLEGAL FOR
N
ON
-T
RAINER
U
SE
*****************************
To use XML as the means of describing data, the XML document must at least
adhere to the basic syntax of XML. In addition, it is often the case that the
structure of the document must be validated against a set of rules that is specific
to the document type.
Well-Formed Documents
A well-formed XML document follows the basic syntax rules of XML. For
example, there must be a single root element, and each opening tag must have a
corresponding closing tag. Furthermore, XML is case sensitive, and therefore,
opening tags and closing tags must use the same case. Elements may be nested
within other elements, but this must be done in a conformed, non-overlapping

manner. In addition, all attribute values must be enclosed in quotes, and an
element cannot contain two or more attributes with the same name.
Valid Documents
A valid XML document is a well-formed document that has an XML schema or
DTD applied and follows the grammatical rules defined in this XML
schema/DTD. XML parsers can be classified as validating parsers or non-
validating parsers. A validating parser is capable of checking the validity of an
XML document, whereas a non-validating parser does not have this capability
and only checks the well-formed structure of the documents.
Topic Objective
To discuss document
validity.
Lead-in
There are two classes of
XML documents.
16 Module 8: Exchanging Business Data

Applying an XML Schema to an XML Document
To apply an XML schema to a static XML document, you must add a
namespace declaration to an element in your XML document, as shown in the
following example:
<!-- My XML document, with an XML Schema applied -->
<myElement xmlns="x-schema:

</myElement>

The namespace declaration indicates the Uniform Resource Locator (URL) of
the appropriate XML schema document. The URL is prefixed by “x-schema” to
indicate to the parser that the URL defines an XML schema.
When the document is loaded into a validating parser, the parser also loads the

XML schema so that validation can take place.
Usually, an XML schema is applied to the root element of the XML document
so that it defines the grammar for the entire document. However, it is also
possible to apply an XML schema to any element in an XML document to
define the grammar for a portion of that document.
Module 8: Exchanging Business Data 17

Causes of Invalid XML Documents

Invalid documents can arise because of:

Version skew

Malicious alteration of XML data

Misinterpretation of XML schema

*****************************I
LLEGAL FOR
N
ON
-T
RAINER
U
SE
*****************************
There are several situations that might give rise to an invalid XML document
being delivered to an application. Some of the possibilities include:

Version skew


Malicious alteration of XML data

Misinterpretation of XML schema

Version Skew
Versioning is an issue that affects many aspects of the Information Technology
(IT) industry, and XML is no exception. An application might build an XML
document according to a previous version of an XML schema, unaware that a
newer version exists. Therefore, the receiving application must ensure that the
correct XML schema is applied to the document and validate the document
against this grammar.
Malicious Alteration of XML Data
When an XML document is sent from one application to another, the possibility
exists that the document might be tampered with in transit. Content might be
maliciously added, modified, or deleted in the document. Therefore, the
receiving application must be capable of validating the XML data as it is
received, rather than assuming that if the XML data was valid when it was sent,
it is still valid when it is received.

It is advisable that both the sender of the document validates the data by
applying the schema before it is sent and that the receiver validates the
documents as it is received to minimize the risk that data has been tampered
with in transit.

Topic Objective
To discuss the causes of
invalid XML documents.
Lead-in
There are several reasons

why invalid XML documents
get created in the first place.
Note
18 Module 8: Exchanging Business Data

Misinterpretation of XML schema
XML schemas perform a dual role. In addition to enabling validation to take
place when an XML document is loaded into the parser, they also act as a
source of documentation for application developers by telling them what
structure of XML to build. XML schemas can be quite complex to read and
understand, and the developer might misinterpret the grammar rules and build
an invalid XML document by mistake.
Module 8: Exchanging Business Data 19

Lab 8.1: Building B2B Services

*****************************I
LLEGAL FOR
N
ON
-T
RAINER
U
SE
*****************************
Objective
After completing this lab, you will be able to:

Prepare a message queue and configure Web sites for use in a B2B solution.


Create and register Component Object Model (COM) components and
Microsoft Windows
®
Scripting Components that can be used in a B2B
solution.

Scenario
LitWare Books plans to implement a B2B automated procurement system that
enables their employees to order new books and replenish the stocks for resale
through their business-to-consumer (B2C) Web site. The business managers at
LitWare Books have defined that:

Any purchase order request for a total value of 1,000 dollars or less can be
automatically approved.

Any purchase order request with a total value of more than 1,000 dollars
must not be automatically approved.

Topic Objective
To introduce the lab.
Lead-in
In this lab, you will create a
message queue and a Web
site for starting the
procurement process of
submitting purchase order
requests. You will also
create and register COM
components and Microsoft
Windows Scripting

Components that can be
used in a B2B solution.

×