Create an XML query to access your XML data source

Building a Report with an XML Pluggable Data Source 45-11

4. Select Procedure, and click OK to display the PLSQL Editor for the new program

unit. 5. In the PLSQL Editor, enter the following PLSQL code to change the text color of the alternating rows to blue: PROCEDURE LineColors IS BEGIN if :LineNo mod 2=0 then srw.set_text_colorblue; else srw.set_text_colorblack; end if; END;

6. Click Compile to compile the procedure.

If any errors display, make sure the code is correct, and that you created the summary column in the steps above.

7. Click Close.

To create a format trigger for each field that calls the procedure:

1. In the Object Navigator, under your report name, expand the Paper Layout node

and navigate to Main Section Body M_G_WAREHOUSE_ID_GRPFR R_ G_WAREHOUSE_ID M_G_WAREHOUSE_ID1_GRPFR R_G_ WAREHOUSE_ID1 .

2. Under R_G_WAREHOUSE_ID1, double-click F_PRODUCT_ID to display the

Property Inspector. Note: You can copy and paste this code from the procedure provided in the xmlpds_code.txt file. Just copy the text under Line Colors Procedure. Note: Optionally, you can also change the fill colors of the alternating rows by following the steps in the above section, and using the following PLSQL code. In this example code, we have changed the fill color of alternating rows to red and blue: PROCEDURE LineColors IS BEGIN if :LineNo mod 2=0 then srw.set_foreground_fill_colorblue; srw.set_fill_patternsolid; else srw.set_foreground_fill_colorred; srw.set_fill_patternsolid; end if; END; Note: If you cannot find a particular field, use the Find field at the top of the Object Navigator. 45-12 Oracle Reports Users Guide to Building Reports

3. In the Property Inspector, under Advanced Layout, double-click the Format

Trigger property field to display the PLSQL Editor. 4. In the PLSQL Editor, use the template to enter the following PLSQL code: function F_PRODUCT_IDformatTrigger return Boolean is begin LineColors; return TRUE; end; 5. Add a format trigger for the following fields, using the same code as in the previous step. Be sure not to delete the first line of the code, where the format trigger name is defined: ■ F_PRODUCT_NAME ■ F_QUANTITY_ON_HAND ■ F_WAREHOUSE_ID1 6. Save your report. 7. Click the Run Paper Layout button in the toolbar to run your report to paper. Your report should look something like this: Figure 45–6 XML PDS Report with Alternating Row Colors You have now applied alternating row colors to your report.

45.2.6 Filter your XML data using a group filter

If you have a lot of data in your XML file, you might want to consider sorting and filtering it. You can do so by creating a group filter and a hierarchy. The steps in this section will show you how to create a filter that will only show the inventory items for a user-defined quantity amount. The filter will be based on a parameter that the user Note: Make sure you do not touch the boldface text. Simply type in the code below this text to create the format trigger. You can copy and paste this code from the procedure provided in the xmlpds_code.txt file. Just copy the text under Format Trigger Code.