Scenario E: Resolving a choice with alternative message data

Before you start:
  1. Create the appropriate message model, either by using the tooling or by importing the message structure files (for example, C header or XML Schema Definition files).
  2. Create a message flow that has the following structure:
    MQInput > Mapping node > MQOutput
This scenario demonstrates how to resolve a choice with alternative message data. The message model used in this example is:
chsmess		(message)
	head			(xsd:string)
	choice		(group)
		str1		(xsd:string)
		int1		(xsd:int)
		dur1		(xsd:duration)
	footer		(xsd:string)
  1. Switch to the Broker Application Development perspective.
  2. Right-click the Mapping node and click Open Map.
  3. Accept the default project and name, and click Next.
  4. Accept the default usage and click Next.
  5. Clear the Based on records in a database check box and click Next.
  6. Select the source message chsmess and the target message chsmess, and click Finish.
  7. In the Connection pane, open the source and target trees by clicking on the addition (+) icons.
  8. Open the chsmess tree in the Source and Target panes in the same way.
  9. In both Source and Target panes, click the addition (+) icon adjacent to the choice group.
  10. Click head in the Message Mapping editor Source pane and drag it onto head in the Target pane. A line joins them.
  11. Repeat Step 10 for each corresponding element (str1, int1, dur1, and footer.)
  12. In the Map Script | Value table, open the tree by clicking the $target + box.
  13. Open the chsmess tree, then open the if. A set of condition elements appears.
  14. Open each condition. One condition exists for each choice. Each condition has the function fn:true().
  15. Click the first function (for example, for str1) and change it in the Edit pane to: $source/chsmess/head=’str1. If the input element head has a value str1, the assignment str1 <- $source/chsmess/str1 takes place.
  16. Click the second function (for example, for int1) and change it in the Expression editor to: $source/chsmess/head=’int1’. If the input element head has a value int1, the assignment int1 <- $source/chsmess/int1 takes place.
  17. Click the third function (for example, for dur1) and change it in the Expression editor to: $source/chsmess/head=’dur1’. If the input element head has a value dur1, the assignment dur1 <- $source/chsmess/dur1 takes place.
  18. Save the mapping by clicking File > Save.
You have completed this scenario. The message model contains a choice that has been resolved using other data in the instance message.
Related reference
Message mappings