Working with Tables

Stylus Studio provides several features to help you work with tables in the Grid tab. Changes you make to tables in the Grid tab, such as adding a nested table, are reflected in the underlying XML document.

This section covers the following topics:

Adding a Nested Table

You add nested tables to a document in the Grid tab using the Add Nested Table dialog box, shown in Figure 123. This dialog box allows you to specify the path to the root for the new table, a row element name, and the number of rows.

A nested table is created as a child of the current element. The nested table shown in Figure 124, myTable, was created as a child of the <book> element.

Nested tables are created with two default rows, which use the element name you provide in the Row Element Name field of the Add Nested Table dialog box. Rows get a default text value of Row n text, where n is an incrementing value starting with 1. You specify the number of rows using the Number of rows field.

To add a nested table:
1. Select the element to which you want to add a nested table.
2. Click Add Nested Table ( ). This action is also available from the XML > Grid Editing menu and from the grid shortcut menu.

The Add Nested Table dialog box appears.

3. Optionally, specify the path to the root. If you leave this field blank, the nested table is created as a child of the current element.
4. Enter a row element name.
5. Optionally, change the number of default rows.
6. Click OK.

The nested table is added to the document and appears in the grid.

Moving a Nested Table

You can change the order of nested tables within a row.

To move a nested table:
1. Select the heading of the nested table you want to move.
2. Click the Move Up ( ) or Move Down ( ) button to move the table to the desired location. These actions are also available from the XML > Grid Editing menu and from the grid shortcut menu.

Deleting a Table

To delete a table:
1. Select the heading of the table you want to delete.
2. Click Delete ( ). This action is also available from the XML > Grid Editing menu and from the grid shortcut menu.

The table is deleted from the document.

Sorting a Table

You can sort tables on any column in ascending or descending order.

To sort a table:
1. Select a cell in the column on which you want to sort the table.
2. Click the Sort Ascending ( ) or Sort Descending ( ) button to sort the table rows in ascending or descending order, respectively. These actions are also available from the XML > Grid Editing menu and from the grid shortcut menu.

The table rows are sorted based on the order you select.

Copying a Table as Tab-Delimited Text

You can copy a tab-delimited text version of a table to the clipboard. This makes it possible to paste document contents from the grid into spreadsheets and other editors that can manage tab-delimited files. Figure 125 shows books/book in books.xml pasted into Microsoft Excel, for example.

Note that when you use this feature, the entire table is copied - column headings (element and attribute names) are not distinguished from cell contents (element and attribute values) in the spreadsheet.

To copy a tab-delimited table to the clipboard:
1. Select the heading of the table you want to copy.
2. Select XML > Grid Editing > Copy as Tab-Delimited from the menu. This action is also available from the grid shortcut menu.
 
Free Stylus Studio XML Training:
W3C Member