Powered By

Free XML Skins for Blogger

Powered by Blogger

Wednesday, December 31, 2008

collapseContexts in XI Message Mappings

Use

collapseContexts()copies the first value from all contexts to one context. Empty contexts are replaced with an empty string.

This graphic is explained in the accompanying text

This can be useful if an upper-level node is to be created each time a lower-level node exists, for example. The function is useful in combination with the function SplitByValue().

Example

In the following example, a separate upper-level element is to be created in the target structure for each occurrence of element :

Source Structure (Left) and Target Structure (Right)

Field Name

minOccurs

maxOccurs

Field Name

minOccurs

maxOccurs

srcRoot

1

1

destRoot

1

1

srcSub

0

unbounded

destSub

0

unbounded

srcItem

0

unbounded

destItem

0

unbounded

This is achieved by using a combination of the functions SplitByValue() and collapseContexts(). To create a queue for in which a context change is performed after each value, use removeContexts() and SplitByValue(). To create a queue with exactly as many context changes, but with empty values (the aim is to create the same number of upper-level tags without values), apply collapseContexts() to the same nesting of functions:

Message Mapping with collapseContexts() and SplitByValue()

Target Field Mapping

Value of SplitByValue()

/destRoot=/srcRoot


/destRoot/destSub=
collapseContexts(
SplitByValue(
removeContexts(/srcRoot/srcSub/SrcItem)))

Each Value

/destRoot/destSub/destItem=
SplitByValue(
removeContexts(/srcRoot/srcSub/SrcItem)))

Each Value

Example

Source Instance

Result

encoding="UTF-8"?>




PID001


PID002



PID003


PID004


PID005



PID006


PID007


xmlns:ns0="workshopDemo">


PID001


PID002


PID003


PID004


PID005


PID006


PID007

No comments: