Format Data Conditionally

The last action we will perform on the table is to write an XPath expression to display the `R' rating for movies in a bold red.

23. Click the rating glyph.
24. In the Properties window, expand the Default Color property.
25. Click the XPath field, and then click the "more" button ( ).

Stylus Studio displays the XPath Editor dialog box.

26. Type the following XPath expression:

      if (rating = 'R') then 'red' else ""
       

    

Notice Stylus Studio's Sense:X auto-completion and text coloring as you type.

Figure 487. XPath Editor Dialog Box

27. Click OK.
28. Next, use the same process to enter this XPath expression for the Bold property:

      if (rating = 'R') then 'bold' else ""
       

    
29. Click Preview ( ).

Our report now looks like this:

Figure 488. Finished Example Report

 
Free Stylus Studio XML Training: