Component Properties

Each component in a report - the body, tables, lists, repeaters, and so on - is associated with a set of properties that control its formatting and content. The text component has properties for Color, Font, Size, and so on. The Color property, for example, lets you select aqua, bisque, blue, and so on. Properties vary based on the component. (See Properties Reference for a complete list.)

Context and XPath Sub-Properties

Each property has Context and XPath sub-properties that let you define the conditions under which you want to, say, display a value or apply a given formatting characteristic. You can use the Color property's Context and XPath sub-properties to format text based on the value returned by an XPath expression - format all `R' rated movies in videos.xml using the color red, for example. (See Example: Using Context and XPath Sub-Properties to Format Text later in this section for an illustration of this technique.)

The Properties Window

Component properties are displayed in the Properties window, a dockable window you can place anywhere on your desktop.

To display the Properties window, click View > Properties

The Properties window consists of one or more tabbed pages. The specific tabs that are present in the Properties window vary based on the component you have selected in the report canvas. As shown in Figure 548, the Properties window for the rating element in the video table includes tabs for the

l The context and XPath expression that return the dynamic value of the rating element
l Text value
l Cell
l Column
l Row
l Table

The order of the tabs in the Properties window reflects the hierarchy of the currently selected component, from the most specific (the currently selected component) to the most general (the parent component to which it belongs), left to right. The report body has Document, Decimal Format, and Text tabs that let you control global formatting characteristics.

Example: Using Context and XPath Sub-Properties to Format Text

Our report contains a table based on the video element from videos.xml; the table lists the movie title and rating. When we preview the report, we see that if a movie's rating is `R' the rating is displayed in red, while other movie ratings are displayed using the default color.

If we look at the properties for the rating element, we can see how this was achieved.

As you can see, Default Color property is specified as <dynamic>. Stylus Studio sets the Default Color property to this value automatically when you specify

l A context for the evaluation of an XPath expression defined in the XPath property. Here, the context is $video. Stylus Studio created this variable, which represents the videos.xml document, when we created the table using the video repeating element from this document.
l An XPath expression to be evaluated in the context defined by the Context property. Here, the XPath expression is if (rating = 'R') then "red" else "".

Together, these properties control when data from the rating element in the videos.xml document is set to the color red.

Entering XPath Expressions

You can enter an XPath expression by typing directly in the XPath field. If you prefer, you can use the XPath Editor dialog box, shown in Figure 551.

 
Free Stylus Studio XML Training: