Use
You use createIf() to create a tag in the target structure independently of a condition.
Example
In the example below, a mapping is required between two different formats for a list of messages. The attribute type is used in the source structure to classify the message as either internal (type="internal") or external (type="external"). However, in the target structure the tag internalRequest or externalRequest is used:
Source Structure (left) and Target Structure (right)
Field Name | minOccurs | maxOccurs | Field Name | minOccurs | maxOccurs |
RequestListMsg | 1 | 1 | RequestListEIMsg | 1 | 1 |
request | 0 | unbounded | internalRequest | 0 | unbounded |
type (Attr.) | 1 | 1 | initiator | 1 | 1 |
creator | 1 | 1 | contact | 1 | 1 |
contact | 1 | 1 | issue | 1 | 1 |
description | 1 | 1 | externalRequest | 0 | unbounded |
initiator | 1 | 1 | |||
contact | 1 | 1 | |||
issue | 1 | 1 |
You use createIf() to create the respective target field independently of attribute type:
Message Mapping Using createIf()
Target Field Mapping | Value of Constant() |
/RequestListEIMsg=/RequestListMsg | |
/RequestListEIMsg/internalRequest= | internal |
/RequestListEIMsg/internalRequest/initiator= | |
/RequestListEIMsg/internalRequest/contact= | |
/RequestListEIMsg/internalRequest/issue= | |
/RequestListEIMsg/internalRequest= | external |
/RequestListEIMsg/externalRequest/initiator= | |
/RequestListEIMsg/externalRequest/contact= | |
/RequestListEIMsg/externalRequest/issue= |
The function removeContexts() is required because the attribute type is mapped in place of the source field request. Therefore, there is no target field for request and no context in the target structure. However, the type queue has nevertheless saved the request context so that processing would terminate early if you did not delete this context.
Example
Source Instance | Result |
encoding="UTF-8"?>
| encoding="UTF-8"?>
<externalRequest> |
No comments:
Post a Comment