xml spy
Previous  Top  Next

Priority Context


When applying a function to different items in a schema or database, 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.

 

A simplified version of the complete DB-CompletePO.mfd file available in the C:\Documents and Settings\<username>\My Documents\Altova\MapForce2008\MapForceExamples folder, is shown below.

 

Please note that there are multiple source components in this example. ShortPO is a Schema with an associated XML instance file, while CustomersAndArticles is a database schema. The data from both, 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 database.
CustomerNr has been designated as the priority context, and is placed in the a parameter of the equal function.
The CustomersAndArticles database is then searched (once) for the same number. The b parameter contains the Number item from the database.
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 Customer 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 database while trying to find that number in ShortPO.

 

context-switch

 

Priority context and user-defined functions:

If a user-defined function has been defined of type "inline", the default setting, then a priority context cannot be defined on one of the parameters of the user-defined function. The user-defined function can, of course, contain other "Standard" user-defined functions which have priority contexts set on their parameters.

 

If the user-defined function was originally of type "standard" with a priority context, and was subsequently changed to one of type "inline", then the priority context is hidden and deactivated. Changing the same function back to "standard", shows the priority context and enables it once again.

 

Please see

 

 


Previous  Top  Next

© 2008 Altova