XForms/Insert and Delete into Table

Motivation
You want to insert and delete records into a table. In this example records are appended to the end of a table but any selected row can be removed. This example does "in-place" table editing. There is no separate form to enable viewing a new record other than in the actual table.

Discussion
This example uses the last and index XPath functions to find out what row of the table should be operated on.

You can also create a version that has a delete and add button in each row. In this design the index function is used to delete the current row selected and insert after the currently selected row.

In some applications the order of rows is important. You can also add buttons to each row to move the selected row up or down.

Note that after you add the row, you should move the insert cursor to the first field. This is done by using the setfocus element.