Mapping XML choice elements

If you have an XML choice element in your message, you can map each possible choice in the XML mapping editor. In this topic, we discuss how to map a simple choice construct, as well as a choice construct containing complex type elements.

The choice construct defines a set of elements, and allows only one element from the set to exist in the parent element.

Mapping a simple element in a choice construct.

Follow these steps to map elements in a simple choice list in the XML mapping editor:
  1. Open the XML map in the XML mapping editor.
  2. Expand the elements in the source and target views. By default, the first choice in the list will appear in the each view:
    First choice element in the source view
  3. Click the source choice element. An arrow appears beside the element:
    Choice element drop down arrow
  4. Click the arrow to view all the choice elements in the source.
  5. To select the choice element that you want to map, click the element:
    Choice element selection
  6. Double click the element that is selected. Notice that the selected choice element now appears in the source view:
    Selected choice element appears in the source view
  7. Similarly, select a choice element in the target view:
    Choice element in target view
  8. Select the elements to map by clicking on the source element, and then clicking on the target element. Right click, and select Create Mapping.
    Create Mapping
  9. The mapped elements appear in the Overview section of the XML mapping editor:
    Mapped elements in Overview section
Note: Only the most recently mapped choice elements will appear in the Overview section of the XML mapping editor. You can view all the mapped choice elements in the Outline view, as shown below:
Mapped choice elements in the outline view

Mapping a complex type element in a choice construct.

When mapping a complex type element in a choice construct, each individual element in the choice element must be mapped separately. For example, on the source side we have a choice construct that contains the elements Address1 and Phone1. On the target side, we have a choice construct that contains the elements homeAddress and homePhone. The following image shows the XML map, with the first elements in the choice (Address1 and homeAddress) displayed.
Note: A box around the complex type element indicates a choice element. To see this box, click on the parent choice element, such as Address1 in the example. To view the choices available for the element, click the arrow in the choice box.

Source and target choice elements of complex type in the XML mapping editor.

In our example, the source has a choice of Address1, Phone1 (chosen by default), and Address2, Phone2, as shown below. The target has a choice of homeAddress, homePhone (chosen by default), andbusAddress, busPhone: To view the choices available for the source element, click the arrow in the choice box. Click to select the choice :
Choice element in the source view
Similarly, select the element busAddress, busPhone in the target. The mapping editor view changes to show the selected elements: Source and target elements in the mapping editor

Use the Match Mapping function to map the source element Address2 to the target element busAddress. Next, use the Create mapping function to map the source element Phone2 to the target element busPhone. The following image of the overview section of the editor shows the completed mapping:
Mapped choice elements in the overview section of the mapping editor

Feedback
(C) Copyright IBM Corporation 2005, 2006. All Rights Reserved.