Mapping Data Using Merge Tags (Magic xpi 4.5)
The Data Mapper lets you map data from various Sources into templates. You do this by mapping the data to a template file. You create a template with special merge tags that are used to define data elements. Merge tags are used to define data elements that are matched with, and replaced by, the appropriate merge tags in the associated template. The Data Mapper uses these tags to map data from various Source types. You can create the template in any text editor and save it as .txt, .rtf, .htm, or .html.
The template file can be any type as long as the merge tags are stored as regular ASCII strings.
Merge tags are recognized by a special syntax: <!$MG_name>
Where the prefix, !$MG_, is a constant syntax and the name is the name of the tag.
When you use the Data Mapper utility, and define an HTML file as the Destination, the merge mechanism scans the template file for merge tags. The scanned tags are displayed in the Destination table of the Data Mapper.
You can map these tags to any Source. For example, you can map flow variables or Database fields to the tags.
When the Data Mapper utility is executed, the tags are replaced by values according to the Source mapping that you defined.
For tags that are embedded, the contents of the repeat area are duplicated and the tags are replaced with the Source mapping values.
You must indicate your Destination template in the Template properties dialog box.
The following are the merge tags that you can use in your template:
|
|
<!$MG_NAME>
|
This tag defines a tag name that is matched with a data element defined in the Data Mapper. You must replace NAME with a name for the tag. If a match is found when the tag is scanned by the Data Mapper, the value replaces the tag.
|
<!$MGREPEAT>
|
This tag defines the beginning of a repeated area. The repeated area is duplicated and processed for each operation, thereby allowing for an unknown number of data rows. The tag is removed from the output.
|
<!$MGENDREPEAT>
|
This tag defines the end of a repeated area. The tag is removed from the output.
|
<!$MGIF_NAME>
|
This tag defines the start of an IF block. The user must map a value from the Source or define an expression that translates to a logical value. The data is assumed to be logical and is evaluated. If the data is True, the rest of the IF block is processed. Otherwise, the ELSE block is processed (if it exists).
|
Note:
|
Special characters (such as *, ., ?, < and >) are not legal characters for template file tags, since the results are unpredictable.
|
How Do I Create Dynamic Text Files?