Transformation Designer - transformation language - examples
The example below shows the map command, where a single field in the input is being mapped to a single field in the output.
<transformation>
<map>
<target>FredsMart/PurchaseOrder/OrderRef</target>
<source>SSC/Payload/SalesOrder/OrderNum</source>
</map>
</transformation>
Any part of the data contained in the source that is not mapped to a target, will not be output. Each field must be specifically mapped.
Given the following input data:
<SSC> <Payload> <SalesOrder> <OrderNum>123456</OrderNum> <Amount>12.34</Amount> </SalesOrder> </Payload> </SSC>
the above TML would generate the following output:
<FredsMart> <PurchaseOrder>>123456</OrderRef> </PurchaseOrder> </FredsMart>
When TML processes each command, the targets are 'spliced' together to create an overall document structure.
The order in which the parameter information is given is not important, that is, the target can be defined before the source, or vice versa. Additionally, each field will be written to the output in the order in which it is defined.
Thus, we can modify the above TML to include a mapping for the amount field in the sample data, outputting it before the order number field:
<transformation> <map> <source>SSC/Payload/SalesOrder/Amount/</source> <target>FredsMart/PurchaseOrder/TotalAmount</target> </map> <map> <target>FredsMart/PurchaseOrder/OrderRef</target> <source>SSC/Payload/SalesOrder/OrderNum</source> </map> </transformation>
The output from this TML would be:
<FredsMart> <PurchaseOrder> <TotalAmount>12.34</TotalAmount> <OrderRef>123456</OrderRef> </PurchaseOrder> </FredsMart>
TML also supports having multiple source fields for a single target field. In this case, each source is written to the target in the order it is provided in the TML. The values are appended. The example below demonstrates this.
<transformation> <map> <target>FredsMart/PurchaseOrder/OrderRef</target> <source>SSC/Payload/SalesOrder/OrderNum/</source> <source>SSC/Payload/SalesOrder/Amount</source> </map> <transformation>
The output from the TML would be:
<FredsMart> <PurchaseOrder> <OrderRef>123456</OrderRef> </PurchaseOrder> </FredsMart>