184 Part III Manipulating Messages
sales-related information. Transforming the common format into a variety of
output formats, or fanning-out, makes sense because we can then pass this
information to various systems in a variety of output formats without requiring
an additional transformation. This is where XML—and Extensible Stylesheet
Language Transformations (XSLT) in particular—shine. There is a clear need for
transformation services within any EI process, and XSLT is an excellent tool to
perform those transformations.
This chapter will illustrate a few ways you can transform messages to
make your integration solution work well. (We will discuss additional methods
in Chapter 11, where we cover many of the tools available through Microsoft
BizTalk Server 2004.) We begin this chapter by illustrating the most common
language for navigating an XML document, XPath. We will also demonstrate
some of the tools available to make message manipulation easier, such as
UpdateGrams, XML Diff, and XML Patch. We will conclude this chapter by giving
you some ideas on how to enrich your messages when they lack information
and how to filter your messages when you have more data than you need.
Transforming Message Contents by Using XPath
Because the use of XML has grown rapidly over the past few years, we think it
is safe to say that the primary form of messages in modern systems is XML.
Given that, we need a language to query content from the XML documents
used within these systems. XPath is a language created to find parts of an XML
document and designed to be used with XSLT. In this section, we will use XPath
and XSLT to transform XML messages into HTML documents. We could trans-
form XML messages into text files by using Comma Separated Values or different
types of XML documents as well, but that is outside the scope of this chapter.
In XPath, a query is not automatically performed over all the XML con-
tent but always has a starting point or context node. This can be any node in
the node tree that constitutes the document. From this fixed point, you can
issue queries such as, “Give me all your children.” This kind of query makes
sense only if a starting point is defined. This starting point can be the root
node, of course, which would query the entire document. You can think of
the root node as being similar to the root folder of the file system on your
local computer. All other folders can then be found by opening child folders
along a particular path.
Consider the following XML fragment. It consists of a customer’s account
information in the Microsoft Pet Shop application. This XML fragment is part of
a larger document that contains all accounts that were queried from the Pet