Step 5: Creating a representation from a table

Now we want to generate 2 new sites for Mrs. Green's Project: the pond and the island. To this end, we first need a representation for the sites. Create a data table with a column called and two rows. The values for the cells shall be gold fish pond and island. For this you could, for instance, use Table Creator node.

Ouput of the Table Creator node

Now add a Create REST Representation node. Connect the table we have just created to the input port.

Table Creator node linked to a Create REST Representation node

Open the dialog of the Create REST Representation node. Like in the Read REST Representation node (see Step 2) there is a steady upper part of the dialog. The lower section of the dialog will change depending on the Data Format you select.

Create REST representation dialog (XML mode)

Select XML as Data Format and set the Root element name to sites. Then execute the node. Like in the reponse body port of submitter nodes (see Step 1), the representation can either we viewed in the output port (which contains only a single cell) or in a view.
In this case we see that there is a name attribute which is a child element of a site element. This hierarchy is inferred from the column name. The element separator (here a period) delimits the elements of the path. We could also create a site element with a name attribute instead of a name tag. For this, the would have to be excluded in the Select mode column filter in the dialog.

Create REST represenation view (XML)

The default values for most of the options in the Create REST representation node can be adjusted in the Preferences.

So far, we have demonstrated how to create representations with nested attributes. But actually we do not need such a complex content type for our intended post. As an exercise, create the follow JSON representation:

JSON representation for POST request

For this you have to change the name of the column in the input table to name. In dialog of the Create REST representation node, you need to change the Data Format to JSON. You can then use the default settings for JSON.