
removeContexts
Use
You use
removeContext() to delete the top context for an element. The top hierarchy level is therefore deleted.Example
In the following example, a list of debtors that lists one or more payments made in the field
payment is to be transformed into a list that only contains payments made. The payments and the debtors also have the attribute id in each case to help identify them.Source Structure (left) and Target Structure (right)
|
Field Name |
minOccurs |
maxOccurs |
Field Name |
minOccurs |
maxOccurs |
|
DebitorListMsg |
1 |
1 |
AllDebtsMsg |
1 |
1 |
|
Debitor |
0 |
unbounded |
debt |
0 |
unbounded |
|
id (Attr) |
id (Attr) |
1 |
1 |
||
|
payment |
1 |
unbounded |
|||
|
id (Attr) |
To delete the top hierarchy level
Debitor, connect the element payment to the function removeContexts(). Specify as the target field the field in which you want the contents of payment to be copied to, in this case debt.Message Mapping Using removeContexts()
|
Target Field Mapping |
|
/AllDebtsMsg=/DebitorListMsg |
|
/AllDebtsMsg/debt=removeContexts(/DebitorListMsg/Debitor/payment) |
|
/AllDebtsMsg/debt/id=/DebitorListMsg/Debitor/payment/id |
Example
|
Source Instance |
Result |
|
<?xml version="1.0" <DebitorListMsg> <Debitor id="1"> <payment id="1"> </Debitor> <Debitor id="2"> <payment id="4"> </Debitor> <Debitor id="3"> <payment id="5"> </Debitor> </DebitorListMsg> |
<?xml version="1.0" <ns0:AllDebtsMsg
<debt id="1">
<debt id="4">
<debt id="5">
</ns0:AllDebtsMsg> |