Repeaters

A repeater is a component that iterates over data in a data source based on the context defined for it. When the report is executed, a new line is added to the report for each new value. These lines are not formatted in any way, so, depending on your needs, you might prefer to use the list or table components for repeating data. See Lists and Tables for more information.

Creating a Repeater

The easiest way to create a repeater 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 Repeater choice. The repeater's context and XPath are set based on the repeating element used to create it. You specify the data you want the repeater to contain by dragging the appropriate node from the data sources panel and dropping it in the repeater as Value.

You can also create a repeater manually (Report > Insert > Repeater, or select Insert Repeater from the canvas short-cut menu). When you create a repeater like this, however, the context and XPath are not set for you, and it will iterate over the data you specify only if you also define the Loop context and Xpath properties for an item.

Graphical Representation

In the XML Publisher canvas, a repeater is represented as a bounding box drawn with a dashed line, usually with a loop symbol ( ) on the left side of the bounding box. Figure 505 shows a repeater based on the title element in videos.xml. It was created by

1. Dragging the video repeating element on the canvas and selecting Insert Repeater from the short-cut menu.

This action defines the context for the iterative action.

2. Dragging the title element and dropping it inside the repeater.

This action defines the data to be included in the repeater.

The loop symbol is present only if the repeater's Loop property has values specified for its Context and XPath sub-properties. You can specify these properties manually in the Properties window, but it is usually easier to create the repeater by dragging a repeating element, dropping it on the canvas, and choosing Insert Repeater.

Sorting

By default, data for the repeater component 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.

 
Free Stylus Studio XML Training: