Use logical expressions to create if-then-else statements to modify XML data. A logical expression is useful if you need to set conditions to determine which mapped element to use, save a portion of data in a repeating group, or define a basic expression to save data for an element such as a flag.
Use any of the following logical expressions to modify XML data:
Use this logical expression type to create an if-then-else statement to identify one specific piece of data in a repeating group. For example, your trading partner sends you an XML document that contains a repeating element called Partner. Each repetition of the Partner element defines a different type of data, as shown in the following example:
<Partner>
<PartnerType> Includes bill-to data.
<PartnerID>
<Partner>
<PartnerType> Includes ship-to data.
<PartnerID>
<Partner>
<PartnerType> Includes buyer data.
<PartnerID>
When you create the transaction map for this repeating group, the Partner element and its children occur only once in the document type definition (DTD) file from your trading partner. If you need only the ship-to data from the second occurrence of the repeating group, you can use an if-then-else operation to identify the data you need to map.
To create an if-then-else statement for a repeating group:
Right-click a transaction in the Trading Partner Tree and select Edit Transaction Map to display the transaction map.
In the Target XML column of either the received map or the reply/sent map, right-click the element you want to modify and select Modify Mapping to display the XML Mapping Conversion Editor dialog box.
Note: To define a logical expression, the element you select must be a repeating group and must have a mapping defined.
From the Operations field, double-click RepeatingGroupSelection to add it to the operation stack.
The Repeating Group Selection dialog box displays.
Define the logical expression by selecting the operator, such as EQUAL, and defining the value.
To create a logical expression for the example above, select Equal as the operator and enter Ship To as the value.
Click OK to return to the XML Mapping Conversion Editor dialog box.
If necessary, move the operation to the correct place in the operation stack.
To create a valid logical expression, the logical operation falls below the item you want to modify in the operation stack.
Add additional sources and operations, as necessary.
Click OK to return to the mapping utility main window.
From the File menu, select Save Transaction Map to save the map.
Use this logical expression type to create an if-then-else statement to use a mapping from another element if the conditions you state are met.
Right-click a transaction in the Trading Partner Tree and select Edit Transaction Map to display the transaction map.
In the Target XML column of either the received map or the reply/sent map, right-click the element you want to modify and select Modify Mapping to display the XML Mapping Conversion Editor dialog box.
From the Operations field, double-click XPathSelection to add it to the operation stack.
The XPath Selection dialog box displays.
Build the expression by selecting the data element you want to use and the operator and value.
Click OK to return to the XML Mapping Conversion Editor dialog box.
If necessary, move the operation to the correct place in the operation stack.
To create a valid logical expression, the logical operation falls below the item you want to modify in the operation stack.
Add additional sources and operations, as necessary.
Click OK to return to the mapping utility main window.
From the File menu, select Save Transaction Map to save the map.
Use this logical expression type to create a basic if-then-else statement to modify XML data. For example, your trading partner might send XML data in an element that is used as a flag, such as Success or Fail. The flags might not correspond exactly to the data format you use in Eclipse to indicate the same flag. You might need to store the Success flag as a 1 value in your system. Use a basic logical expression to tell the system that if it reads Success in the data element, to store a 1 in the mapped Eclipse element.
To create a simple if-then-else operation:
Right-click a transaction in the Trading Partner Tree and select Edit Transaction Map to display the transaction map.
In the Target XML column of either the received map or the reply/sent map`, right-click the element you want to modify and select Modify Mapping to display the XML Mapping Conversion Editor dialog box.
Note: To define a logical expression, the element must have a mapping defined.
From the Operations field, double-click Logical If-Then-Else to add it to the operation stack.
The If-Then-Else Logical dialog box displays.
Build the expression by entering the following information:
Expression Section |
Description |
If operand value |
Select the operator and the value for the expression. |
Then use this value |
Enter the value to use if the data meets the criteria stated in the If statement. |
Otherwise use this value |
Enter the value to use if the data does not meet the criteria stated in the If statement. |
To create a logical expression for the example above, select Equal as the operator and enter Success as the value. In the Then value, enter 1. This is the value the system stores in the mapped element if it reads "Success" in the source data element. In the Otherwise value, enter 2. This is the value the system stores in the mapped element if it does not read "Success" in the source data element.
The XQuery Preview area displays the expression as it appears in the XQuery code for the transaction map.
Click OK to return to the XML Mapping Conversion Editor dialog box.
If necessary, move the operation to the correct place in the operation stack.
To create a valid logical expression, the logical operation falls below the item you want to modify in the operation stack.
Add additional sources and operations, as necessary.
Click OK to return to the mapping utility main window.
From the File menu, select Save Transaction Map to save the map.
See Also: