IBM Integration Bus, Version 10.0.0.2 Operating Systems: AIX, HP-Itanium, Linux, Solaris, Windows, z/OS


Configuring the local environment tree Variables folder by using the Cast function

You can use the Cast function to define variables in a message map that are defined in the local environment tree Variables folder.

Procedure

Sometimes you need to use information passed in a variable in the local environment tree. In other instances, you might need to calculate the output value of a different element in the message body based on one of the local environment variables. You can also set variables in the output local environment, and use them for routing later in the message flow. To configure the local environment tree Variables folder so you can use its elements as part of your transformations, complete the following steps:

  1. Create a schema file in your application, integration service, or library to define the elements of the local environment tree Variables folder and their type:
    • In the Application Development view, select New > Message Model > Other XML. Click Next.
    • Select Create an empty XML schema file, I will model my data using the XML schema editor, and then click Next.

      This figure shows the window that opens where you choose the option Create an empty XML schema file, I will model my data using the XML schema editor.

    • Create an XSD file YourLExsdFileName.xsd, where YourLExsdFileName is the name of the file that contains the local environment variables folder message model. Then, click Finish.

      This figure shows graphically the window that you use to select the project and enter the xsd file name.

    • The XSD file opens in a new tab where you use the XML Schema editor to define your variables and their types.

      For example, you can define the following schema:

      <?xml version="1.0" encoding="UTF-8"?>
      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
             <xsd:element name="Country"  type="xsd:string"/>
             <xsd:element name="CountryCode"  type="xsd:integer"/>
      </xsd:schema>
      Note: You can define the local environment variables in a message flow node by using ESQL or Java™. Namespaces is not defined. For this reason, the schema is also defined without a namespace declaration.
  2. Use the Cast function to define the local environment variables in the message map so they are visible under the Variables folder in the map. Complete the following steps to cast the any element to a variable and its type in the output local environment tree:
    • Right-click the any element, and then select Cast.

      This figure shows graphically the menu options that you choose to cast an element. You right-click the any element, and then select Cast.

    • In the Type Selection window, select a type, for example Country, and then click OK.

      This figure shows the Type Selection window with the elements Country and CountryCode within a red square.

Results

You have defined one local environment variable that can be used by other message flow nodes in your message flow for routing or filtering.

You can see the element Country under the local environment Variables folder in the message map.

This figure shows graphically the element Country under the any element of the local environment Variables folder.

Example

Another example:

If you set in an ESQL compute node two simple fields within the Variables folder of the Local Environment tree by using the following code:

SET Outputlocal environment.Variables.dec = 10.1;
SET Outputlocal environment.Variables.str = 'Some text';

To access these fields in a Mapping node by using the Cast function, you must create a schema file in your integration solution to define the elements and their type. Note that since the ESQL is not using any namespace to qualify these elements, the schema is also defined without a namespace declaration:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
       <xsd:element name="dec"  type="xsd:decimal"/>
       <xsd:element name="str"  type="xsd:string"/>
</xsd:schema>

Once the schema file is saved, you can then select the any element under the Variables section in the Local Environment tree, and use the context menu action Cast to add a Mapping cast for each of the elements "dec" and "str" that are required in the message map. For more information, see Mapping xsd:any on an input or output message.

What to do next

Define transforms between the input local environment tree and the output local environment tree. For more information, see Specifying a transform (mapping operation) and Transform types in the Graphical Data Mapping editor.


br30019_.htm | Last updated 2015-09-24 12:54:37