Advanced XI Mapping useful with MDM
This weblog explains a mapping that could be used when distributing data from MDM XML files
to databases using XI. The source message has different records that
need to be updated in a database if and only if they have a key field defined.
In the following example, the key is the field CR. The first record has a key CR=1
so it must be mapped into an UPDATE statement. The second record does not define a
CR key field so it is not converted into a statement.
Target Message
Tasks to be completed
This can be easily done by assigning the key
CR to the Statement under the root context. Explicitly as follows:
/ns:MsgTypeUpd/Statement = /ns:MsgTypeSrc/M1/CR
- Map each target field. Each target is mapped with the corresponding
source field if and only if the key exists for that record
We can check weather the key exists by using the exists block
and the ifWithoutElse block. Apart from that, we'll
have to make sure that no context is empty, that's why we are removing
the contexts and then splitting the fields.
The queues from a test are shown below, it is clearly seen that the element "4444"
remains unassigned because a key is missing at that same position.
This solution is good enough if the number of fields in the table is small,
but if there are several of them it would be better to create a "User defined
function" to make the job. The mapping would look like,
For this implementation we are supposing that the key field has cardinality 0..1
and that each field has cardinality 1. This is not always the case. I promise I'll
post an upgraded version of this ifExists function block with more functionality
and completely tested in different structures.