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

Figure 469. Properties Window

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 469, the Properties window for the rating element in the video table includes tabs for the

  • The context and XPath expression that return the dynamic value of the rating element
  • Text value
  • Cell
  • Column
  • Row
  • 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 is the only component without tabbed pages.

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.

Figure 470. Preview of an XML Publisher Report

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

Figure 471. Properties for the Rating Element

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

  • 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.
  • 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 472.

Figure 472. XPath Editor Dialog Box

The XPath Editor dialog box supports Stylus Studio's Sense:X auto-completion and text coloring, which can provide useful prompts as you type your XPath expression.

To display the XPath Editor dialog box:
1. Click the XPath entry field for the property you want to define.

The text cursor and a "more" button appear in the field.

Figure 473. Opening the XPath Editor Dialog Box

2. Click the "more" button.

Stylus Studio displays the XPath Editor dialog box.

Free Stylus Studio XML Training:
W3C Member