Overview
Fields can contain tabular data, where each cell is treated as an independent link. Tabular field data can come from a number of sources, including delimited field content, other data sources, HTML, XML, or built from conditional logic.
Example
In this example the field “AttributeValues” contains the following XML snippet:
1 2 3 4 5 6 7 8 9 10 11 | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AttributeValues> <AttributeValue attributeId = "quantity" orderNo = "10">68</AttributeValue> <AttributeValue attributeId = "order code" orderNo = "7">GF 33</AttributeValue> <AttributeValue attributeId = "id" orderNo = "9">116</AttributeValue> <AttributeValue attributeId = "description" languageId = "de" orderNo = "2"><p>AC99AFFF mit FG 50</p></AttributeValue> <AttributeValue attributeId = "width" orderNo = "13">4000</AttributeValue> <AttributeValue attributeId = "height" orderNo = "6">20</AttributeValue> <AttributeValue attributeId = "diameter" orderNo = "11">100</AttributeValue> <AttributeValue attributeId = "price" orderNo = "8">312,5</AttributeValue> </AttributeValues> |
The first stage is configure the field as ‘Tabular’ using field options, with the source as ‘Field Content’ and type ‘XML’.
Then transform the XML into a simple HTML table using a simple XSL statement, which define the contents of the tabular field:
1 2 3 4 5 6 7 8 9 10 11 12 13 | <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <table> <xsl:for-each select="/AttributeValues/AttributeValue"> <xsl:sort select="@orderNo" data-type="number" order="ascending" /> <tr> <td><xsl:value-of select="@attributeId" /></td> <td><xsl:value-of select="text()" /></td> </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> |
Now the field shows as expandable in the EasyCatalog panel:
At this stage, individual cells, or the entire table can be inserted into a document and tracked.
How Links Work
Each cell is treated as a field in terms of tracking and updating. The field is a ‘Computed Field’, linked to the ‘AttributeValues’ field, but modified using a command which extracts data from a specific cell in the table. This is done via the ‘TABLESTR’ command, which in the following example, extracts data from the top left cell:
The parameters are the ‘Row ID’ and ‘Column ID’ as configured by the ‘Field Options’. It’s important these are carefully considered as they affect the ability to update the field.
Updating Tables
A typical use would be to insert part or all of a field as a table. To do this, and keep it updated, first insert the entire ‘AttributeValues’ field into the document. A table is created with the following settings, which are defined on the Table->Table Options… dialog box:
Populate Using Tabular Field
Field : AttributeValues
Once a table has been setup in this way it stays synchronised with the contents of the field. During the update process, EasyCatalog will insert or delete rows as necessary. Columns are updated based on the TABLESTR command used in the existing table, so it’s possible to be selective of the fields in a table.
Additional Processing
Tabular fields provide a mechanism to manipulate the source table. This allows manipulation of both the table structure and content. When executed, an object called ‘table’ is passed to the script, which can perform LUA based processing on it. For example, the following code returns a rotated version of the original table. For full documentation consult the LUA documentation.
1 2 | newtable = table:rotate(); newtable:present(); |