Tables

A table is a visual component that usually iterates over the data it contains. You typically create a table when you want your report to display multiple rows with two or more columns of dynamic data - one row for each movie in the videos.xml file, with each row containing the movie's title, its genre, and its rating, for example.

If your data can be displayed in a single column (only movie titles, for example), you might want to consider using either the list or repeater components. See Lists and Repeaters for more information.

Creating a Table

The easiest way to create a table in XML Publisher is to drag and drop a repeating element. When you drop the repeating element on the canvas, Stylus Studio displays a short-cut menu with an Insert Table choice. You can insert a table with either

You can also create a table manually (Report > Insert > Table, or select Insert Table from the canvas short-cut menu). When you create a table like this, however, the context and XPath are not set for you, and it will only contain the number of rows you explicitly create for it unless you also define the Loop property for a row.

Graphical Representation

Tables, like the one shown in Figure 496, are displayed as a single row with a loop symbol ( ); the loop symbol indicates a repeating row.

Figure 496 shows a table based on the book repeating element in books.xml that was created using the Populated Columns short-cut menu choice.

Figure 497 shows a table based on the same repeating element, but it was created using the Default Columns short-cut menu choice.

Finally, Figure 498 shows a table that was created manually using the Report menu. Notice that it does not have the loop symbol associated with repeating rows.

Sorting

By default, data for dynamic rows is displayed in document order. You can use an XPath expression in the Loop property's Sort sub-property to specify a different sort order. The Loop property appears on the Row tab of the Properties window.

Adding Rows and Columns

To add rows and columns to a table:
1. Select the cell before or after which you wish to add a row or column.
2. Right-click.

Stylus Studio displays a short-cut menu.

Alternative: Click the Report > Table menu.

3. Select the appropriate choice from the menu.

Deleting Rows, Columns, and Tables

To delete a row, column, or table:
1. Select a cell in the row or column you want to delete.
2. Click the Delete button in the toolbar ( ).

Stylus Studio displays a drop-down menu.

Alternative: Right-click.

Alternative: Click the Report > Table menu.

3. Select the appropriate choice from the menu.
 
Free Stylus Studio XML Training: