Skip to main content

XML mapping in WebSphere Integration Developer V6.1.2, Part 1: Using the XML Mapping Editor to develop maps

Shane Cartledge (shanec@ca.ibm.com), Staff Service Analyst, IBM
Shane Cartledge is a software developer at the IBM Toronto Software Lab.
Peter Cinat (pcinat@ca.ibm.com), Software Developer, WebSphere Integration Developer, IBM
Peter Cinat is a Software Developer at the IBM Toronto Software Lab.
David Lauzon (lauzond@ca.ibm.com), Advisory Software Developer, IBM
David Lauzon is a Advisory Software Developer at the IBM Toronto Software Lab. You can contact David at lauzond@ca.ibm.com.
Andrea Rice (arice@ca.ibm.com), Staff Software Developer, WebSphere Integration Developer, IBM
Andrea Rice is a Staff Software Developer at the IBM Toronto Software Lab.
Dave Spriet (spriet@ca.ibm.com), Software Developer, IBM
Dave Spriet is a software developer for the IBM Toronto Software Lab.. He develops tools for WebSphere Message Broker and specializes in object-oriented technologies, XML, XML schema, and UML Modeling. He has a bachelor's degree (with honors) in Computer Science and Statistics from McMaster University.

Summary:  This article shows you how to quickly create robust and well-organized XML maps in WebSphere Integration Developer V6.1.2. It also describes tools you can use to test and debug maps to make problem determination easier.

Date:  26 Nov 2008
Level:  Intermediate
Activity:  734 views

Introduction

Purpose of mapping

When building a mediation flow, there are instances where the output message structure from one primitive does not match the input message structure for the next primitive. In this case a mapping can be used to convert the message from one structure to another. The messages pass through a mediation flow as Service Message Objects (also known as SMO) which have a consistent XML structure. When you use the mapping editor, you are creating mappings that transform a source XML document into a target XML document. The mapping editor takes these mappings and generates an XSL file to perform the actual XML transformations at runtime.

When creating a mapping, the goal is to build a mapping that will produce a complete and valid target XML document. The XML document that is produced should be complete in that it contains all the expected data and the document should also be valid with respect to its corresponding schema that it must match.

Part 2 of this article series, Working with complex XML structures in the XML Mapping Editor, explains some more advanced XML mapping topics.

The XML Mapping Editor

The XML Mapping Editor in V6.1.2 has been revised to make populating a target XML document with data from a source XML document an intuitive and visual task. In general, the source XML structure is shown on the left hand side and the target XML structure on the right hand side. By drawing connections between the source and target fields, you create mappings between the source and target elements and attributes. A properties view below the editing area allows you to refine and customize the mappings that you create within the XML Mapping Editor. The XML Mapping Editor also contains a test view which allows you to associate sample input XML and see the output XML of a map immediately.



Creating maps

Where to create maps

Maps are generally created within a Mediation Module project for use within a particular mediation flow. They can also be created in a Library project which will make them available for re-use within any map file that resides in a module that is dependent on the Library.

Within a mediation flow, map files are created using the XSL Transformation primitive. Each XSL Transformation primitive is associated with a map file that describes the transformations to be made to the input XML. The map file is created in accordance with information specified when you implement the primitive.

While working on a mapping, you may find that you are constantly mapping the same two element types. In that case, you may find it useful to create a Submap that can then be re-used whenever mapping those two types. A Submap is nothing more than a regular map file which can be called from other map files using the Submap transform. A Submap can be created from within the Mapping editor or it can also be created by right-clicking in the Business Integration view and selecting New > XML Map.

Choosing a mapping root

First determine what part of the target document needs to be changed and then determine where the data that will populate the target document is going to come from. Once you know what areas of the document you are going to work with, you can choose an appropriate root for your map. An XML map that is used within a mediation flow can only have a single input/source and a single output/target. In the case of mediation flows, the messages are SMO messages that are broken up as follows:

  • Context
  • Headers
  • Body

You can choose any one section of the SMO as a root or you can choose the root of the SMO if you need more than one of the sections. In most cases, your changes will occur in only the body of the SMO and the body is an appropriate root for your mapping. However, there are times when you may require data from the context or headers in order to properly populate your target body. There are also times when you may want to update the target context or target headers. In these cases, you will need to use the root of the SMO "/" as your root for the mapping. Using "/" as the root will allow access to all areas of the source and target SMO. Once a SMO mapping has been created with the chosen root, the root cannot be changed.

Mapping refinements

When working in the XML Mapping Editor, you will associate elements and attributes of the source schema with those of the target. Once you create an association between the source and target, the association is called a transformation or a mapping. Each mapping can have a single refinement to indicate what type of mapping it is. This section describes the refinements.

Move

Move is the most basic refinement -- it takes a simple or complex field on the source side and move it unchanged from the source to the target. The only change made to the copied field will be to namespace prefixes to ensure they are valid in the target document. When you want to copy something from the source to the target without altering it in anyway, Move is the recommended refinement.

Assign

The Assign refinement is used when you want to assign a constant value to a target element or attribute. Assign is only available for assigning a value to simple type fields such as string and int. To create an Assign mapping:

  1. Select the target element or attribute that you want to assign a value to
  2. Right-click the target element or attribute and select "Create Transform"
  3. Use the Properties view to assign the desired value to the target element or attribute

Local map

A Local map is a tool for organizing a mapping file. It allows you to nest mappings for complex types so that the top level mapping does not become cluttered with too much detail. It is important to realize that creating a Local map between a source and a target does not perform any data transformations on its own. Nothing will move from the source to the target until you go inside the Local map and create mappings using refinements such as Move. Local map is used as a container mapping to localize nested mappings (such as Move) which perform the actual transformations.

A Local map contains a single input field and a single output field. In cases where multiple input fields are required, a Merge mapping replaces a Local mapping but behaves similarly.

Once you have created a Local map between a source and target, you can double-click the Local map refinement to navigate into the map. Once inside the Local map you can create the child mappings. While inside a Local map, you will notice that you can navigate out of the Local map, back to the parent mapping by using the 'Up a level' icon () in the top right corner of the mapping area. While inside a Local map, you will notice that a gray background is used to indicate that you are working within a nested mapping.

A Local map is not reusable. In cases where you are mapping source and target types that you know will be mapped the same way in other maps, consider using a Submap which can be reused and shared among many mapping files. See the Submap section of this article for more information on creating Submaps.

Merge

A Merge refinement is similar to a Local map in the sense that it is essentially a container for nesting other mappings. Unlike a Local map, Merge supports multiple source inputs. This allows you to take data from two different source fields and merge them into a single target field. Merge is also used when working with arrays.

Submap

A Submap refinement is a mapping between two specific types that is stored in a separate file. A Submap is nothing more than a root mapping in a regular map file which can be referenced from any other map file making it ideal for reuse. Since Submaps are designed for re-use, it is recommended that you store Submaps in Libraries where they can be easily shared and reused amongst dependent modules. In cases where you have two different complex types that are frequently associated with each other for mapping purposes, a Submap is a good way to create a re-useable mapping between the types.

A Submap that is based on types cannot be tested as a standalone map. To test a Submap with a type as an input, call it from a Submap refinement in a parent map and then run a test on the parent map. A Submap based on global elements can be tested in isolation. For more information, see the Problem Determination section.

In some cases, you may find that you cannot create a Submap for a desired type because the type is not defined in an XSD file. This could be the case if the type is defined in a WSDL file. The Submap creation wizard will not allow you to create a Submap with a non XSD defined type as the input or output. In this case, you can refactor the type out of the WSDL file by doing the following:

  1. In the Business Integration view, locate the desired type in the Data Types category of the module or referenced library project.
  2. Right-click the type and select Refactor > Extract In-lined Business Objects

After extracting the desired type, you can create a Submap using the extracted type as an input and/or output. The Submap refinement is not available when working with local elements or anonymous types. In the case of local elements or anonymous types, reusable mappings are not an option at this time.

Built-in functions

The built-in functions described below are available when working with strings in the Mapping Editor. Other XPath functions can be used while mapping, but require a custom transform

Concat

The Concat function will concatenate two or more strings from the source into a single string value on the target side. The built-in Concat function supports the specification of a prefix, postfix, and delimiters through its property page.


Example use case data
InputRequired Output
<cityName>Toronto</cityName>
<countryName>Canada</countryName>
<destination>Toronto,Canada</destination>

To achieve the required output in this case, a Concat transform could be used with the following properties:

  • Specify the input order so that cityName is the first input and countryName is second input
  • Use a delimiter of "," on the cityName input

Normalize

The Normalize function will move a string from the source to the target and make the following modifications to the string during the move:

  • Remove leading and trailing white-space
  • Replace sequences of white-space within the string with a single space

Normalize Example
BeforeAfter
<destination> Toronto Canada</destination><destination>TorontoCanada</destination>

Substring

The Substring function will extract text from a source string. The Substring function uses a delimiter and index to determine what text to extract from the incoming source string. Based on the specified delimiter, the source string is divided into sections. The index is used to identify which section of the divided string you want to use. By default the index is 0, indicating that the first section will be used. For example, suppose that you wanted to extract the city name from <destination>Toronto, Canada</destination>

You can use the Substring function by specifying "," (comma) as the delimiter. By default the 0 index would return the first section of the separated string which would be Toronto in this example.

To extract the country name from the same string, specify ", " (space after the comma) as the delimiter and set the index to 1, which causes the second section of the divided string to be used, which would be Canada in this example.

In cases where you were not guaranteed a space after the comma in your source string, you could use a Custom refinement with an XPath expression such as: normalize-space(substring-after($destination, ",")).

Other refinements

Other refinements not mentioned in this article are mainly used when working with arrays and other structured data.

Using conditions

Mappings can be conditional. Conditions can be used to determine whether a particular mapping will occur at runtime or not. In cases where the data used to populate a target field is dependent on some condition, that condition can be applied to the mapping on that target field. Using conditions on mappings allows you to control the logical flow of the mappings. A transform can have a maximum of one condition and the condition is specified in the Properties view of the applicable transform. Conditions can be specified using an XPath expression or by using static Java methods. When you are working with optional source inputs in the XML Mapping editor, conditions that check for the existence of the source input are automatically generated to prevent the mapping from executing if the source input does not exist.

XPath conditions

Conditions can be written using XPath expressions. When the XPath expression is evaluated, the value of the condition will be determined based on the return value of the expression.


XPath Condition Evaluation Criteria
Expression Return TypeTrue ResultFalse Result
node-setnon-empty node-setempty node-set
stringa string that is one or more characters in lengtha zero length string
numberany number other than zero (negative or positive)zero
booleantruefalse

While writing conditions using XPath, you can use relative or absolute paths. Inputs to the transform are available as variables and can be inserted into the expressions. Content assist in the condition input area can be used to view a list of available variables. You can also use content assist in the condition input area to make use of XPath functions. To invoke content assist in the condition input area, use CTRL+Space.

When using relative paths, you currently cannot reference above the context node using syntax such as ../<element name>. In cases where you need to access information that is not accessible within one of the input values, use an absolute path. For an example of using variables, the content assist below shows that cityName is available as a variable:



After you click the cityName variable in the list above, $cityName is inserted into the entry field and then you can continue to create a condition such as $cityName = "Toronto".

There is currently no support for if-else conditions. To simulate the else portion of an if-else scenario, negate the original condition.

To understand the basics of using conditions, consider this example. A travel company is offering customers advice about their travel destinations in the form of one of the following tips:

  • Weather will be hot -- bring your sunscreen.
  • Weather will be cold -- bring your parka.

The tip depends on the temperature of the chosen destination. For destinations where the temperature is above 0°C, the hot weather tip is given, otherwise the cold weather tip is given. You can condition the mappings like this:

Each of the Assign transforms would contain a condition like these:

  • Condition for the assign of the hot weather tip: /body/getBestDestinationResponse/response/celsiusTemperature>0.
  • Condition for the assign of the cold weather tip: not(/body/getBestDestiantionResponse/response/celsiusTemperature>0).

Another use of conditions is when you want to use the value of one input field if it is present in the source, otherwise you will use the value of a different input field. Consider the following scenario:

Inputs:

  • An optional string input for a specific recommendation
  • A required string input for a general recommendation

Output:

  • A single recommendation as specific as possible. When the specific recommendation is present, that should be the value; otherwise, the general recommendation is used.

In this case, you might consider doing this:

  • Create a Move refinement between the input specific recommendation and the output recommendation. When the specific recommendation is present, the Move occurs and the value is set correctly. Because a condition is automatically generated for optional inputs, no additional conditions need to be added to this transform.
  • Create a Move refinement between the input general recommendation and the output recommendation. Condition the Move with the following condition so that it executes only when the specific recommendation is not present in the input: not(/body/response/specificRecommendation).

Another way to use conditions is to apply a filter to a list of repeatable elements.

Java conditions

You can also build conditions using calls to static Java methods. When using Java method calls, the return value of the method determines the condition result:


Java condition evaluation criteria
Method Return TypeTrue ConditionFalse Condition
org.w3c.dom.NodeListA non-empty node listAn empty node list or null
Stringa String that is one or more characters in lengtha zero length String
intany number other than zero (negative or positive)zero
booleantruefalse

To write a Java method to compute the logic for the condition:

  • Create the new static Java method in an existing Java project or create a new Java project to store the method within.
  • Make sure that your mapping project or one of it's library dependencies contains a dependency to your Java project
  • Beside the condition entry field, click the Configure user defined functions button (). Click Add and then start typing the name of the Java class that contains your method. Once found, select the Java class from the list of available options and click OK to complete the add process.
  • In the condition entry field, use the content assist (available by pressing CTRL+Space) to insert the appropriate method call.

For example, suppose you have:

Class:TravelCompanyUtilities
Method:isDesirableCity
Parameters:cityName (of type String)

The condition might look like this:

TravelCompanyUtilities::isDesirableCity(/body/response/destination/cityName)

or

TravelCompanyUtilities::isDesirableCity($cityName)

Tips and Tricks

This section contains some tips and tricks to help make XML mapping an easier task. The tips in this section include:

  • Tips for working faster: Match mapping, Content assist.
  • Tips for working with large schemas: Scrolling, Navigation trail.
  • Other tips: Test map view, Sorting transforms, Detailed and simplified views.

Match mapping

You can use match mapping when the source and target are similar or contain similar sections. Match mapping always attempts to match whatever is showing on the source side of the editor with whatever is on the target side of the editor. A match is made when an element or attribute on the source side has the same name and type as an element or attribute on the target side. To invoke match mapping, use the Map source to target based on the name and types toolbar button ( ). Match mapping will use Local maps to map complex types rather than using a Move, which makes it easier to tweak the mappings that are created.

For example, if a Move transform had been used to map the body on the source to the body on the target, and you wanted to make a minor adjustment to something in the body, you would need to delete the Move transform and create individual transforms at a more granular level. However, when using match mapping, Local maps are used and drilling into those Local maps allows you to get to the exact location where the changes need to be made. In this way, only transforms that correspond to the minor adjustments need to be changed.

When the source and target have similar fields of the same type but may not have the same name, you can use Local maps to match these similar types and then use match mapping within the Local maps that you create. For example, suppose we have the following source and target:


Invoking match mapping at this level will not find any matches and will display an error message indicating that no matches were found for the "getWeather" element in the target. However, the GetWeather element in the target is looking for a cityName and a countryName which will come from the first element in the destinations array on the source side. We can reset the starting point for the match mapping by creating a Local map between the destinations element in the source and the GetWeather element in the target.


From within the Local map, invoking match mapping will map the CityName and CountryName.

Content assist

Some of the entry fields that are used within the property pages of the Mapping editor contain content assist to help when syntax is important. If content assist is available in an entry field, a light-bulb icon ( ) will appear next to the entry field and the hover help on the light-bulb will indicate whither or not content assist is available. To invoke the content assist, use CTRL+Space.

Scrolling

When creating a transform or mapping in the editor, it is typical to do so by locating a source input field, clicking on the source input field, holding the mouse button down, dragging a connection over to the target field, and finally releasing the mouse button to complete the action. Using this method is quick and easy but inhibits the ability of using the editor's scroll bars at the same time. This makes it hard to work with large schemas where the source and target fields of an intended transformation are not always in view with each other at the same time. The following methods can be used to create transformations between a source and target that are not visible at the same time.

  1. Hover over the source input field, single-click the drag handle that appears but do not hold down the mouse button.

    This will initiate the connection creation process while still giving the ability to use the scrollbars at the same time. While the connection wire is active, you can also initiate scrolling by hovering near the editor edge and pausing briefly.

  2. Select the source input field without holding down the mouse button. Scroll to the appropriate matching field in the target, hold the CTRL key and click the target field to select it. Finally, right-click on the target field and select Create Transform. A transform between the selected source and target will be created and you can then customize the transform as desired.

  3. Select the source input field, right-click, and select Create Connection. Once the connection wire appears, you can use the scrollbars at the same time to find the target field and complete the transformation. While the connection is being created, you can also initiate scrolling by hovering near the editor edge and pausing briefly.

Navigation trail

As you create nested mappings such as Local maps, you can find yourself deep within an element structure wondering where exactly you came from. At the top of the editor is a navigation trail that lets you know what elements you are nested in. Clicking any part of the navigation trail will quickly bring the editor view to the associated level.

Test map view

While working in the XML Mapping Editor, you can use the Test Map view to test your mapping transforms as you create them. For details on the The Test Map view, see Problem Determination.

Sorting transforms

By default, the XML Mapping editor will sort the transforms column based on the source input. This means that the transformations align themselves with their associated source input fields. In some cases, it may be more convenient to have the transform column sorted by the target outputs. Since this will align transformations closest to their target output, it provides a quick way to see what type of transformation is operating on a particular target. To switch the sorting method, right-click in the mapping editor area and use the 'Sort Transforms' menu action, or click the desired sort method button on the local toolbar (by source , or by target )

Detailed and simplified views

By default, the XML Mapping Editor uses a simplified view of the XML inputs and outputs. There is some information that may be in the schema that is not shown by default in the XML Mapping Editor. For example, a choice defined in the schema is shown as a flat list in the mapping editor. In order to see such model group information in the mapping editor, use the detailed view. To switch from simplified view to detailed view, use the drop down menu in the top right corner of the XML Mapping Editor window:


In addition to the details shown in the XML Mapping Editor window, you can also see general information about the selected element in the properties view as well.

Problem determination: Test and debug

While creating a map it is a good idea to test the map periodically to ensure that the desired results are being achieved. Any map that uses a global element as the root element can be tested. Examples of maps that use global elements as the root input are all maps created for XSL Transformation primitives in the mediation flow editor. Maps that do not have a global element as the root input are typically used as Submaps and can be tested by calling them through a parent map.

Input files

In order to test a map in the tooling, the first step is to create or select an input document to test with. The easiest way to accomplish this is to use the input document generation tools that are included in the XML Mapping Editor. The input document generation tools will create a basic input document based on the input XML schema. Once the input document has been generated, you can start testing immediately and can later enhance the input by adding additional elements and values. The following methods can be used for creating input documents:

  1. While using the Create New XML Mapping wizard from an XSL Transformation primitive in a mediation flow, you can check the Create a sample XML input file for testing the XML Map checkbox.

  2. From within the XML Mapping Editor, you can click the Associate XML files toolbar button and then use the Generate Input button to create and associate a new sample input file.

    The Generate Sample Input File button is disabled in cases where the root input of the map is not a global element. Maps with global element inputs can only be tested by calling them from another map.

  3. From within the XML Mapping Editor, you can click the Test Map toolbar button to open the Test Map view. From the Test Map view, click the Associate XML files toolbar button and then use the Generate Input button to create and associate a new sample input file.

As an alternative to creating a sample input file, if you already have a sample input file, you can associate the existing XML input file with the map file using the Associate XML files toolbar action. Currently, input files are generally saved in the same project as the maps they apply to and show up in the Business Integration view under the Mapping > XML Map Test Data category.

Iterative testing using Test Map view

Once you have a sample input file associated with the map file, you can use the Test Map view to test the map file. This method of testing can be used as you are still developing your mappings. The view will perform transformations on the input document using whatever transformations you have implemented in your mapping file, even if you have not yet saved the changes to the mapping file. This allows you to ensure that the transforms you create have the desired result before committing changes to your mapping file. To open the Test Map view, use the Test Map action () on the mapping editor toolbar.

While using the Test Map view, you can refresh the output at anytime by clicking the Run transformations" button on the Test Map view toolbar. You can also make updates to the input XML file from the Test Map view and can save those changes by clicking the Save selected input file" toolbar button. Changes to input XML files can also be committed to a new input file by using the "Save selected input file as" toolbar button.

The Test Map view provides two methods for viewing the input and output XML. The visual tab represents the XML in a tree format allowing you to navigate and edit the values easily. The visual tab also provides some validation such as verifying whether the value assigned to a simple type is valid.

Testing maps using the Integration Test Client

In addition to the Test Map view, you can also test a completed XML Map using the Integration Test Client. Tests that you create in the test client can be saved and re-run multiple times. You can also debug mapping transformations while testing with the Integration Test Client.

To test a map file using the integration test client, right-click on an XML map file in the Business Integration view and select 'Test'. You can also select an XSL Transformation node in a mediation flow and right-click to invoke the Test XML Map action as well.

To debug a map while using the integration test client, select the "Stop for debug before transformations" checkbox in the Invoke XML Map Event detailed properties before running the event. You can also set breakpoints on the transformations in the XML Mapping Editor by right-clicking the transformation and selecting an action from the "Local Debug" menu.

Testing Maps on the Server

When using the above methods of testing, the maps are being tested locally in the tooling. There may be cases where the map executes successfully in the tooling but behaves incorrectly at runtime while running on the server. In these cases, you will need to debug the problem on the server.

Tip

While testing a component, if you want to use input data that you have already created in one of your maps input files, you can do so by making use of the value pool. When you are locally testing an individual map in the integration test client, you can populate the value editor using data from a one of the maps input files. Once the data is visible in the value editor, you can save individual values to a data pool. After saving a value to a data pool, it will be available when you later run a component test to test your entire mediation flow. For example, if you have created an array of sample inputs in one of your input XML files, you can save the array to the data pool and use it as an input for a component test.

Testing an XML map on the server is accomplished by testing the component that contains the XML Map to be tested. In the Assembly Editor, right-click the mediation flow component that contains the map(s) to be tested and invoke the Integration Test Client using Test Component or Test Component in Isolation.

To understand how an XSL Transformation primitive is executed at runtime, consider the following scenario


  1. SMO input object is received by the 'SortDestinations' XSL Transformation primitive,
  2. SMO input is serialized into XML for processing.
  3. XML input is transformed using the XSL file associated with the primitive and an XML output is produced.
  4. Output XML is de-serialized into the SMO output object.

Fine grained trace in the Integration Test Client will allow you to see the inputs and outputs to each XSL Transformation primitive in the mediation flow. In most cases, if an XML map works during local testing and fails at runtime, the problem is in Step 4 from above, the conversion of the output XML to the SMO object. This is the point where an inconsistency between the output XML and the schema will cause a failure. To help diagnose and fix these types of problems, you can turn on server tracing to allow you to examine the messages.

To turn on server tracing:

  1. In the Servers view, right-click the applicable server and select Run administrative console.
  2. Log-in to the administrative console (default id and password is admin).
  3. In the Troubleshooting section, select Logs and Trace.
  4. In the Logging and Tracing area, click the server name (e.g. server1).
  5. Click Change Log Detail Levels.
  6. In the Change Log Details Level entry field, add the following text to whatever text already exists in the entry field: : com.ibm.ws.sibx.*=all.

    For example, if the entry field contains this before making a change: *=info.

    The entry field will look like this after the changes: *=info: com.ibm.ws.sibx.*=all.

  7. Click OK.
  8. Click Save to save changes and promote the configuration changes to the server.
  9. Logout of the administration console.
  10. Restart the server.

Once the server tracing has been enabled, rerun your test and then review the trace.log file, which is in one of the following locations:

<WID_INSTALL_DIR>\pf\wps\logs\<SERVER_NAME> or <WID_INSTALL_DIR>\pf\esb\logs\<SERVER_NAME>

When you open the trace.log file, you can locate serialized SMO instances by searching for the string: <smo.

You can also view the raw XML data before and after a transformation primitive by looking for the following strings:

Serialized DataObject prior to transformation and Result of transformation.

Another option for debugging is to set a breakpoint on the XSL transformation primitive in the Mediation Flow Editor. The debugger will allow inspection of SMO values both before and after the XSL transformation primitive at runtime.

Best practices

Organizing mappings

When working in the XML Mapping Editor, there are things you can do to make the maps easier to navigate, understand, and maintain. One technique for implementing a map is to start by looking at the fields in the target one by one. For each field in the target, consider:

  1. Does the target field need to be populated? (Is it required?)
  2. If the target field needs to be populated, where will the data come from?
  3. If the target is going to be populated from data that is in the source XML, where in the source is the data located?
  4. Is the data source of the same type as the target data type? If the types are the same, and the data does not need to be modified in any way, consider using a Move transform.
  5. If the data from the source and the target are not the same type or manipulation of the data is required, consider using a Local map or a Submap to map the source and target. By using a Local map or a Submap, you will be able to nest the details of the mapping inside a child transform leaving less clutter and confusion at the root level of your mapping file.
  6. Will there be a future requirement to map the source and target types in another mapping or multiple times in the current mapping? If you determine that these types are frequently mapped together, consider using a Submap which is re-usable, otherwise, a Local map is the way to go.
  7. If there are multiple source inputs required to populate a single target, consider using a Merge which is a specialized Local map that accepts multiple inputs.
  8. Within a Submap or Local map, do many of the source and target fields have the same name and types? If there is a lot of similarity between the source and target, consider using Match Mapping to map the similar fields as a starting point for further customizations.
  9. For complex types that are the target of a mapping, ensure that none of the target types children are targets of any other mappings other than those that are defined within a container mapping on the parent. For example, suppose that we wanted to copy all the context information from the source to the target but we also wanted to add something from the body to the context/correlation as well.

    Even if the Local map on context does not map the correlation element, the Move is still wrong, because it must be within the Local map.

Once you have determined the best type of mapping for each target field at the root level, you can use the same process to create mappings within the Local map, Merge, and Submap transforms that you have created.

Migrating maps from V6.0.2 to V6.1

The format of XML Maps changed in Integration Developer V6.1. A tool that migrates Integration Developer V6.0.2 XML mapping files (.xmx) to the new Integration Developer V6.1.2 format (.map) is provided in Integration Developer. After importing projects containing *.xmx files, you will receive warnings in the Problems view. To launch the migration tool, right-click on a warning message and select Quick Fix, or try to open a *.xmx file in Integration Developer V6.1.2.

Once you have completed the auto migration, you will still need to test your migrated map file to ensure that it produces the desired results. In V6.0.2, empty elements were created for required elements in the target XML even if those elements were not mapped in the mapping, however, in V6.1.2, these empty elements are no longer created unless you explicitly create a mapping. Because of this and other differences in the two version, it is recommended that you test the maps after migration.

Part 2 of this article series, Working with complex XML structures in the XML Mapping Editor, explains some more advanced XML mapping topics.


Resources

About the authors

Shane Cartledge is a software developer at the IBM Toronto Software Lab.

Peter Cinat is a Software Developer at the IBM Toronto Software Lab.

David Lauzon is a Advisory Software Developer at the IBM Toronto Software Lab. You can contact David at lauzond@ca.ibm.com.

Andrea Rice is a Staff Software Developer at the IBM Toronto Software Lab.

Dave Spriet is a software developer for the IBM Toronto Software Lab.. He develops tools for WebSphere Message Broker and specializes in object-oriented technologies, XML, XML schema, and UML Modeling. He has a bachelor's degree (with honors) in Computer Science and Statistics from McMaster University.

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=354948
ArticleTitle=XML mapping in WebSphere Integration Developer V6.1.2, Part 1: Using the XML Mapping Editor to develop maps
publish-date=11262008
author1-email=shanec@ca.ibm.com
author1-email-cc=
author2-email=pcinat@ca.ibm.com
author2-email-cc=
author3-email=lauzond@ca.ibm.com
author3-email-cc=
author4-email=arice@ca.ibm.com
author4-email-cc=
author5-email=spriet@ca.ibm.com
author5-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers