Export
Export operation exports one or more tables into any text-based format (such as XML, HTML, JSON, etc) with any structure of your choice. The
specification of the output is defined as a script in InfoLink’s
proprietary template language. You can create an export script under
Scripts section of the navigation tree: right-click on the Scripts
section, select Create script. In the popup window select Export script as script type, enter a script name, and click Create.
Export operation parameters overview:
-
Export scriptis the name of an export script created under theScriptssection of the navigation tree. You can use the dropdown suggestions to pick a script name. -
Target Source,Target Space, andTarget Tablespecify location of the export file to be created. It can be any source that support “open table as file for writing” operation, for example, Amazon AWS S3.
Export script is executed by reading the script file, outputting its
content to the output file and executing export instructions. Export
instructions are represented as XML tags with il: namespace prefix. A
list of supported instructions:
-
<il:forEachRow source="source_name" table="table_name" var="var_name" condition="filter_expression">output_text</il:forEachRow>:il:forEachRowinstruction iterates over records of tabletable_namefrom sourcesource_namebinding each record to variablevar_nameand evaluating the content ofil:forEachRowas content script.conditionattribute is optional. It is a filter expression in a query language of the source. In the condition expression you can refer to a column asvar_name.[column_name]wherevar_nameis a variable defined in an (current or outer) instruction such asil:forEachRowandcolumn_nameis any column in the record bound to the variable. You must always quote column names using square brackets in the condition expression.il:forEachRowinstructions can be nested. In this case condition in the nestedil:forEachRowinstruction can be used as a join predicate between the nested tables. -
<il:out val="expression"/>:il:outinstruction is substituted with the result of theexpression, which can be any expression in a query language of the source. In the expression you can refer to a column asvar_name.[column_name]wherevar_nameis a variable defined in an outer instruction such asil:forEachRowandcolumn_nameis any column in the record bound to the variable.
Example 1: Export tables with one-to-many relationship into nested XML
The following export script demostrates export into XML format. There is
one-to-many relationship between tables export_products and
export_parts. In the export script we nest all corresponding rows from
export_parts into export_parts elements.
<?xml version="1.0" encoding="utf-8"?>
<doc>
<title>Product list</title>
<il:forEachRow source="PADB_SQLServer" table="export_products" var = "p" condition="p.[name] like '%Aurora%'">
<product>
<name><il:out val="p.[name]"></il:out></name>
<details>
<weight><il:out val="p.[weight]"/><il:out val="p.[weight_unit]"/></weight>
</details>
<parts>
<il:forEachRow source="PADB_SQLServer" table="export_parts" var = "part" condition="p.[product_id] = part.[product_id]">
<part>
<name><il:out val="part.[name]"/></name>
<quantity><il:out val="part.[quantity]"/></name>
</part>
</il:forEachRow>
</parts>
</product>
</il:forEachRow>
</doc>The output of the above script looks as follows:
<?xml version="1.0" encoding="utf-8"?>
<doc>
<title>Product list</title>
<product>
<name>Aurora 88 Black with Gold Cap Fountain Pen</name>
<details>
<weight>39g</weight>
</details>
<parts>
<part>
<name>14k Yellow Gold nib unit</name>
<quantity>1</name>
</part>
<part>
<name>Gold-Plated Threaded Cap</name>
<quantity>1</name>
</part>
<part>
<name>Resin body</name>
<quantity>1</name>
</part>
</parts>
</product>
<product>
<name>Aurora Talentum Classic Burgundy Gold</name>
<details>
<weight>30g</weight>
</details>
<parts>
<part>
<name>14k Yellow Gold nib unit</name>
<quantity>1</name>
</part>
<part>
<name>Gold-Plated Threaded Cap</name>
<quantity>1</name>
</part>
<part>
<name>Resin body</name>
<quantity>1</name>
</part>
</parts>
</product>
</doc> Example 2: HTML
Below is an example of exporting data into HTML. It iterates over
issues_all table and exports the issues into HTML suitable for sending
via email (no stylesheet reference, styles inlined).
<h2>Issues list</h2>
<table style="border: 2px solid rgb(200,200,200); border-collapse: collapse;">
<tr>
<td style="border: 1px solid rgb(190,190,190); padding: 5px 10px;text-align: center;"><b>App name</b></td>
<td style="border: 1px solid rgb(190,190,190); padding: 5px 10px;text-align: center;"><b>Job</b></td>
<td style="border: 1px solid rgb(190,190,190); padding: 5px 10px;text-align: center;"><b>Issue</b></td>
<td style="border: 1px solid rgb(190,190,190); padding: 5px 10px;text-align: center;"><b>When</b></td>
</tr>
<il:forEachRow source="Stage" table="issues_all" var = "t">
<tr>
<td style="border: 1px solid rgb(190,190,190); padding: 5px 10px;text-align: center;"><b><il:out val="t.[appname]"></il:out></b></td>
<td style="border: 1px solid rgb(190,190,190); padding: 5px 10px;text-align: center;"><il:out val="t.[object]"/></td>
<td style="border: 1px solid rgb(190,190,190); padding: 5px 10px;text-align: center;"><il:out val="t.[title]"/></td>
<td style="border: 1px solid rgb(190,190,190); padding: 5px 10px;text-align: center;"><il:out val="t.[when]"/></td>
</tr>
</il:forEachRow>
</table>