How Do I Extract Specific Data from a Multi-Occurrence Compound Based on Sibling Element Data? (Magic xpi 3.x)
Use a variable to extract the required filtering data from a multi-occurrence compound based on sibling element data. Then use this variable for filtering the compound using conditioned mapping.
Filter values may be concatenated in order to extract data sets from the multi-occurrence compound.
Sample Schema:
Sample XML Document:
-
Define a variable to hold the extracted data.
-
Create a Data Mapper step.
-
In the Source/Destination Management screen, define an XML Source type, based on the given schema.
-
Define two Variable Destination types. For the first Destination, select the F.CustomerId variable. For the second Destination, select the F.Quantity variable, as shown below.
-
In the Data Mapper screen, connect the Source XML compound element to the first Destination compound element. This is the variable’s parent.
-
Define the filter criteria based on one or more elements in the Source. For example: Source/S3/Order/CustomerID ='100'
-
Connect the simple elements that you want to extract to the variable in the Destination. Add an expression, if required.
-
Connect the child Source XML compound element to the second Destination compound element (the variable’s parent).
-
Define a filter criteria on the OrderLines map based on one or more elements in the Source. For optimization purposes, you can include a logical expression based on values extracted from the parent. For example: Source/S3/Order/OrderLines/ItemID ='210' AND F.CustomerId <> ''
-
Connect the simple elements that you want to extract to the variables in the Destination, as shown below. Add an expression, if required.
Note:
|
In similar cases, but when values come from multiple Sources, it is best to divide the process into two separate Data Mappers since we cannot guarantee the sequence of events.
|
|