Open topic with navigation

TIBCO BusinessEvents® Enterprise Edition 6.3.1

# Coercions

In some situations, the datatype of a Scope Variables element may be undefined. In these situations, you may know the data type of the element, and you can coerce the element into a specific type. Using the Coercions button in the Input tab toolbar you can create and manage your coercions.

The following example illustrates a schema with an element defined as the "any element" data type. The schema is for a generic incoming message that can have any type of body. In the example, however, the any element is coerced into an Order type so that it can be mapped to a choice element.

Figure 78: Example Schema of Coercion

The following procedure describes how to coerce the `Body` element of the incoming message into a specific datatype and map it to a choice element.

Note: There are many ways of accomplishing the same result as this example. This example attempts to illustrate the simplest method to achieve the desired result.

Procedure
1. Select the element of type any element in the Scope Variables schema. Click the Coercions button in the Input tab toolbar. In the Coercions dialog, click the Insert button (+) to add a coercion for the currently selected element.

   The Coercions dialog allows you to manage all of your coercions for a function in one dialog. You can create, modify, or delete coercions for any element in the Scope Variables schema using this dialog, not just the currently selected element. If you are creating a coercion for an element that is not currently selected, use the XPath field to specify the location of the element.

   Click the Element radio button to specify that you are specifying a schema element.

2. Click the Browse Resources button next to the Schema field to browse a list of schemas that can be used. In the Select a Resource... dialog, select the schema that you would like to specify

   Click OK to coerce the element into the data type of the selected schema element. The following would be the resulting schema where the element of the datatype any element has been replaced with the `Order` schema.

3. Map the `Name` element to the `Name` element in the Function panel. Then, map the coerced `Order` element to the choice element in the Function panel.

   The Mapping Wizard dialog appears and asks if you wish to create an `Order` or a `CreditLimitIncrease` element. Select `Order` and click Next.

   The Mapping Wizard then asks you to create a For Each. Even though there is only one element in the Scope Variables schema (the `Message` element is not repeating), a For Each is used because this construct allows you to map the individual items of the Order element. Click Next to continue.

   The Mapping Wizard then asks if you wish to automatically map elements with the same name. Click Finish to accept the default mappings.

4. The following is the completed mapping.

Did you find this helpful?

YesNo
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO BusinessEvents® Enterprise Edition

Copyright © 2004-2024. Cloud Software Group, Inc. All Rights Reserved.