The map editor, BizTalk Mapper Designer, enables us to perform transformations of complex messages in a visual and extremely simple way, expressed in graphics associations of links that define the relationships between the various elements of messages.
These relationships between elements are internally implemented as XSL Transformations (XSLT – Extensible Stylesheet Language Transformation) which is the standard recommended by Worldwide Web Consortium (W3C) to perform transformations between XML schemas.
The BizTalk Mapper resides in the Visual Studio Shell and some of its functionalities rely on the user interface elements of the Visual Studio shell. For example, you use the File, Edit, and View menus just as you would for other development in Visual Studio. It becomes active when you add a new map to a BizTalk project, when you open an existing map (a .btm file), or when you reactivate a map by clicking its tab in the main Visual Studio editing window.
The editor consists essentially of three modules:
- Source Schema view: this is the data structure of the source message and is on the left side of the main window – point 1;
- Destination Schema view: this is the data structure of the target message and is on the right side of the main window – point 2; The links that define the mapping lead into the destination schema tree view from the grid view, and ultimately from the source schema tree view.
- Mapper Grid view: is in the middle of the main window, between the two data structures (source and target) – point 3; This area plays a critical role in the definition of maps, containing the links and functoids that control how data in a source instance message is transformed into an instance message that conforms to the destination schema. The grid view can have multiple layers, called grid pages, allowing you to organize complex maps into logical subdivisions of mappings and are accessible through the tabs that are at the bottom of the mapper grid view – point 4.
Apart from these three modules, there are two windows of extreme importance for the developer:
- Toolbox window: typically is at the left side of the source schema – point 5; providing access to all functoids that we can use in BizTalk maps.
- Properties window: in this window we can see and modify the properties of a selected object on the mapper grid or in the schemas (link or functoid in a grid page; a schema node in the source or destination schema), usually is available at the right of the destination schema – point 6.
In general, this tool allows us to map elements from one schema to another, using predefined functions to transform values (functoids), custom XSLT transformations, custom .NET/C#, COM, VBscript code or using external XSLT, but the use of these options rely heavily on the experience of the programmer
In fact, this editor is generating an XSLT file that can be used in others .NET (non BizTalk) applications.
Links and Functoids
Transformations inside maps can be defined as simple relations, such as copying a name or address of a document to another. We can express a direct copy of the data using a link, which is represented in the BizTalk Mapper Designer as a line connecting the elements from source to destination elements:
- Links specify the basic function of copying data from an element or attribute in an input instance message to an element or attribute in an output instance. You create links between records and fields in the source and destination schemas at design time. This drives the creation, at run time, of an output instance message conforming to the destination schema from an input instance message conforming to the source schema.
The user can also specify more complex transformations using functoids. We can consider functoids, as pre-defined functions that we can use to perform complex mappings and transformations
Typically on a map, the data is copied from source to destination by dragging links between elements of the two schemes. Functoids stays in the middle of these operations and apply an operation on the incoming data in order to transform them to the requirements of the destination. BizTalk Mapper Designer represents a functoid as a box in the middle of the link or links between the processing elements
BizTalk Mapper provides an extensive set of functoids that can be used in maps to perform a variety of operations on data that is being mapped from a source instance message to a destination instance message.
By default, the functoids are organized into nine categories based on their intended purpose:
- Advanced Functoids: used to create various types of data manipulation, such as implementing custom script (C#, Visual Basic .NET, XSLT), value mapping, and managing and extracting data from looping records.
- Conversion Functoids: used to convert data, such as: convert ASCII to characters or to convert numbers from one base to another (hex, decimal).
- Cumulative Functoids: used to perform various types of accumulation operations for values that occur multiple times within an instance message.
- Database Functoids: used to look up data from a database and to perform simple cross-referencing operations (sometimes called ID mapping).
- Date and Time Functoids: this is a set of operations applicable on dates like, add date, time, date and time, or add days to a specified date, in output data.
- Logical Functoids: used to conditionally control the behavior of other functoids and to determine whether particular output data is created.
- Mathematical Functoids: used to perform specific numeric calculations such as addition, multiplication, and division.
- Scientific Functoids: used to perform specific scientific calculations such as logarithmic, exponential, and trigonometric functions.
- String Functoids: used to manipulate data strings (text alphanumeric) by using well-known string functions such as concatenation, length, find, and trim.
However, the platform allows that new functoids can be created by the developer as well as organize and create new categories.
Reference project for the creation and installation of new functoids: “BizTalk Mapper Extensions UtilityPack”.
The mapper grid plays a critical role in the definition of maps, containing the links and functoids that control how data in a source instance message is transformed into an instance message that conforms to the destination schema.
The grid view can have multiple layers, called grid pages, allowing you to organize complex maps into logical subdivisions of mappings. BizTalk 2010 no longer has the limitation of 20 grid pages that exist in the previous versions of the product.
Partitioning maps on different pages, in addition to being a good practice, can become extremely useful in order to organize them and thus make them more readable. Although in small maps, one page is enough, when dealing with complex schemes such as EDI, "infecting" a page with numerous links and functoids makes them unreadable or difficult to understand, getting to the point of not being able to distinguish one element from another.
We can define the pages as logical containers of links and functoids, serving only to organize the maps, this because, at run time they don’t have any impact since they are invisible to the compiler.
Possible operations on pages
By default, a map file is created with one grid page named “Page 1”. Once you have selected source and destination schemas, you can access the grid page menu by right-clicking the tab at the bottom of the grid page.
Despite the most frequent operations to be: the creation and renaming of pages, there are 4 operations that can be carried on pages:
- Add new page: This is the most common operation, adds a new grid page, also known as a layer, to the grid view that allows us to organize different areas of the map in logical containers
- Right-clicking the tab at the bottom of the grid page and select “Add Page” option to add a new grid page to the map.
- Rename an existing page: very often forgotten, this option allows renaming of the displayed grid page, in order to make them more legible and give them visual impact.
- Right-clicking the tab at the bottom of the grid page and select “Rename Page” option.
- Delete an existing page: eliminate unnecessary or obsolete pages.
- Right-clicking the tab at the bottom of the grid page and select “Delete Page” option
- Reorder map pages: very often we have the need to organize the disposition of the pages in a different sequence, to do this just:
- Right-clicking the tab at the bottom of the grid page and select “Reorder Pages” option
- BizTalk Server: Basics principles of Maps – Introduction (Part 1)
- BizTalk Server: Basics principles of Maps – What are maps and where BizTalk can use them? (Part 2)
- BizTalk Server: Basics principles of Maps – Basic maps functionalities (Document mapping) (Part 4)
- BizTalk Server: Basics principles of Maps – Organizing Maps (Part 5)
- BizTalk Server: Basics principles of Maps – Testing and Validation of maps (at design time) (Part 6)