Priority Context node/item

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Designing Mappings > Mapping Rules and Strategies >

Priority Context node/item

When applying a function to different items in a schema, MapForce needs to know what the context node will be. All other items are then processed relative to this one. This is achieved by designating the item (or node) as the priority context.

 

Priority-context is used to prioritize execution when mapping unrelated items.

 

Mappings are always executed top-down; if you loop/search through two sources then each loop is processed consecutively. When mapping unrelated elements, without setting the priority context, MapForce does not know which loop needs to be executed first, it therefore automatically selects the first source.

 

Solution:

Decide which source data is to be looped/searched first, and then set the priority context on the connector to that source data.

 

The CompletePO.mfd file available in the ...\MapForceExamples folder, is shown below.

 

Please note that there are multiple source components in this example. ShortPO, Customers, and Articles are all schemas with associated XML instance files. The data from each, are then mapped to the CompletePO schema / XML file. The priority context icon, is enclosed in a circle as a visual indication.

 

The CustomerNr in ShortPO is compared with the item Number in the Customers file.
CustomerNr has been designated as the priority context, and is placed in the a parameter of the equal function.
The Customers file is then searched (once) for the same number. The b parameter contains the Number item from the Customers file.
If the number is found, then the result is passed to the bool parameter of the filter function.
The node/row parameter passes on the Customers data to "on-true" when the bool parameter is true, i.e. when the same number has been found.
The rest of the customer data is then passed on as: Number, FirstName, LastName items, are all connected to the corresponding items in the target schema.

 

Designating the b parameter of the equal function (i.e. item Number), as the priority context would cause:

 

MapForce to load the first Number into the b parameter
Check against the CustomerNr in a, if not equal,
Load the next Number into b, check against a, and
Iterate through every Number in the file while trying to find that number in ShortPO.

context-switch-prof


© 2019 Altova GmbH