Ifs

An if is a component that represents a condition (if... then... else...). You can use if components to control report content. You can insert if components within other components (within a table cell, for example).

Creating an If

The easiest way to create an if component in XML Publisher is to select Report > Insert > If from the Stylus Studio menu, or select Insert If from the canvas short-cut menu.

The if component's context is established automatically only if you insert within another component - such as a table or list - whose context is already set. The if component does not inherit its context from the body component.

Graphical Representation

In the XML Publisher canvas, an if component is represented as two tabs, true and false, within a bounding box drawn with a dashed line. Figure 474 shows an empty if component.

Figure 474. If Component

Example

We need to create a report that contains a simple table that lists the title and rating for all movies in the videos.xml document. In addition, if the movie carries an `R' rating, we want to display the R-rated symbol ( ) for emphasis. A sample of the report is

Figure 475. Example of an If Component

To create this report in XML Publisher, we would:

1. Create a table by dragging the video repeating element and dropping it on the canvas. This establishes the context for the cells in the table.
2. Drag and drop the title element in the table's first cell (as a value).
3. Right-click and insert an if component in the table's second cell.
4. Select the if component and click the If tab in the Properties window.
5. Set the Condition property to rating='R'.
6. Specify the true condition:
a. Select the true tab.
b. Right-click and select Insert Image.
c. Set the image component's Source property to the location of the image we want to display for R-rated movies ( c:\MyProjects\images\r_rating.gif, for example).

Figure 476. Setting the True Condition

7. Specify the false condition:
a. Select the false tab.
b. Drag the rating node from the data sources panel and insert it as a value.

Figure 477. Setting the False Condition

XML Helps Uncork Innovative Winery Web Sites

Learn how Freerun Technologies, Inc., a leading Internet services provider used Stylus Studio and XML technologies to develop a framework for Web-based eCommerce applications for the wine industry, reducing development cycles.

Generating Java Code with Stylus Studio

This is a video tutorial on how to generate Java Code with Stylus Studio

XML Unicode Encoding

Stylus Studio supports over 300 different file encodings, including UTF-8, UTF-16, EUC-JP, SHIFT-JIS, and more, alowing you to work with any XML document. Robust text editors support standard editing features, and Sense:X intelligent auto-completion.

Accessing Relational Databases as XML with Stylus Studio's File Explorer

This demonstration is the first part of our series on working with relational and XML data, covering how to use Stylus Studio's File Explorer to connect to and query relational database tables as XML.

Stylus Most Wanted

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.