Powered By

Free XML Skins for Blogger

Powered by Blogger

Wednesday, December 31, 2008

SplitByValue in XI Message Mappings

Use

SplitByValue() is the counterpart to removeContexts(): Instead of deleting a context, you can insert a context change in the source value queue. You then receive this element for each inserted context change instead of a top node element. However, for this to be possible, the top node source field must be assigned a top node target field and minOccurs must be >0. A maximum of minOccurs top node target fields can be inserted here.

You can insert a context change in the queue after each value, after each change to the value, or after each tag without a value.

Example

The following source structure enables the personal numbers of managers to be compiled in a list. The target structure requires that four rooms are occupied (minOccurs of rooms is 4, maxOccurs of rooms is 4). The first four managers from the list of managers are then distributed among the four rooms.

Source Structure (Left) and Target Structure (Right)

Field Name

minOccurs

maxOccurs

Field Name

minOccurs

maxOccurs

ManagerMsg

1

1

RoomsMsg

1

1

managers

1

1

room

4

4

personalId

0

unbounded

personalId

1

4

The context for personalId of the source structure is managers. There is only one context of this type. All personalId-elements are located in this context. To receive an additional context after each personalId tag, connect both personalId elements of the source and target structures, and in the function properties set the context change for each subelement of managers (Each Value). The manager context must also exist in the target structure. Therefore, assign the target field room to the source field managers.

Message Mapping Using SplitByValue()

Target Field Mapping

Value of SplitByValue()

/RoomsMsg=/ManagerMsg


/RoomsMsg/room=/ManagerMsg/managers


/RoomsMsg/room/personalId=
SplitByValue(/ManagerMsg/managers/personalId)

Each Value

Since the frequency of room is set to exactly four, four contexts are generated. In other words, four times the element room with each context having a subelement personalId (the other managers do not get a room):

Example

Source Instance

Result

encoding="UTF-8"?>




PID001


PID002


PID003


PID004


PID005


PID006


PID007


xmlns:ns0="workshopDemo">


PID001


PID002


PID003


PID004

No comments: