Creating the Dequeuing Procedure

Customizing Reports with XML 22-3

22.1 Customization Overview

By using the Oracle Reports XML tags, you can customize reports created using Oracle Reports Builder. Creating and applying an XML customization is a three-step process: 1. Create a customization file using Oracle Reports XML tags. You can create this customization by building a report using Oracle Reports Builder then saving your report as XML. You can also build the customization manually, with any sort of text editor or a sophisticated XML editor, as long as you include the XML tags that are required for the particular Oracle Reports customization. 2. Store the XML customization in a location that is accessible to Oracle Reports Services. 3. Apply the XML customization to another report with the CUSTOMIZE command line keyword or the SRW.APPLY_DEFINITION built-in procedure, or run the XML customization by itself if it contains a complete report definition with the REPORT or MODULE command line keyword. Note: For reports developed in a release prior to Oracle Reports 10g Release 2 10.1.2 patch 2, you may find the PLSQL package specification or body is missing when opening the XML reports. In this case, either: If the RDF exists, regenerate the XML output file using Oracle Reports 10g Release 2 10.1.2 patch 2 or later. Or, edit the XML to add type=packageSpec andor type=packageBody in the function element, as follows: programUnits function name=a type=packageSpec textSource [CDATA[PACKAGE a IS function lire return date ; END a;]] textSource function function name=a type=packageBody textSource [CDATA[PACKAGE BODY a IS function lire return date is c2 date; ... END;]] textSource function function name=cf_1formula returnType=date ... function programUnits Note: Although it is possible to create an entire report manually using the Oracle Reports XML tags, only manually created customizations and data models are documented and supported. 22-4 Publishing Reports to the Web with Oracle Reports Services

22.2 Creating XML Customizations

This section provides examples of various report customizations. It includes examples of: ■ Required XML Tags ■ Changing Styles ■ Changing a Format Mask ■ Adding Formatting Exceptions ■ Adding Program Units and Hyperlinks ■ Adding a New Query and Using the Result in a New Header Section ■ Encoding the URL

22.2.1 Required XML Tags

Every XML customization must contain the following required tag pair: reportreport For example, the following is the most minimal XML customization possible: report name=emp DTDVersion=9.0.2.0.0 report This XML customization would have a null effect if applied to a report because it contains nothing. It can be parsed because it has the needed tags, but it is useful only as an example of the required tags. The report tag indicates the beginning of the report customization, its name, and the version of the Data Type Dictionary DTD file that is being used with this XML customization. The report tag indicates the end of the report customization. The report tags name attribute can be any name you wish, either the name of the report the XML file will customize, or any other name. This example represents a minimal use of the report tag. The report tag also has many attributes, most of which are implied and need not be specified. The only required report attribute is DTDVersion. See Also: Section A.5.21, CUSTOMIZE Note: For a description of the SRW built-in package, including the SRW.APPLY_DEFINITION built-in procedure, see the Oracle Reports online Help. Customizing Reports with XML 22-5 A full report definition requires both a data model and a layout and therefore also requires the following tags and their contents: ■ datadata ■ layoutlayout The data tag has no accompanying attributes. The layout tag has two attributes, both of which are required: panelPrintOrder and direction. If you use the default values for these attributes respectively acrossDown and default, you need not specify them. Examples of the data and layout elements are provided in the following sections.

22.2.2 Changing Styles

The example in this section demonstrates the use of XML to change the fill and line colors used for report fields F_Mincurrent_pricePersymbol and F_ Maxcurrent_pricePersymbol. report name=anyName DTDVersion=9.0.2.0.0 layout section name=main field name=F_Mincurrent_pricePersymbol source=Mincurrent_pricePersymbol lineColor=black fillColor=r100g50b50 field name=F_Maxcurrent_pricePersymbol source=Maxcurrent_pricePersymbol lineColor=black fillColor=r100g50b50 section layout report We assume in this example that the section and field tags name attributes match the names of fields in the Main section of the report this XML file will customize. In keeping with this assumption, the other attributes of the field tag will be applied only to the fields of the same name in the reports Main section.

22.2.3 Changing a Format Mask

The example in this section demonstrates the use of XML to change the format mask used for a report field f_trade_date. report name=anyName DTDVersion=9.0.2.0.0 layout Note: To apply an XML customization file to modify an existing report trigger or to create a new report trigger, you must specify the relevant trigger attribute of the report tag: For example, to modify or create a Before Report trigger, use the beforeReportTrigger attribute: report DTDVersion=9.0.2.0.0 beforeReportTrigger=BeforeReport If you do not specify this attribute when you want to apply an XML customization file to modify or create a report trigger, the report trigger PLSQL code will be treated as a local independent function when the XML customization file is applied to your report. 22-6 Publishing Reports to the Web with Oracle Reports Services section name=main field name=f_trade_date source=trade_date formatMask=MMDDRR section layout report Notice that the field tag provides its own closure . If the field tag used additional sub-tags, you would close it with field.

22.2.4 Adding Formatting Exceptions

The example in this section demonstrates the use of XML to add a formatting exception to highlight values greater than 10 in a reports f_p_e and f_p_e1 fields. report name=anyName DTDVersion=9.0.2.0.0 layout section name=main field name=f_p_e source=p_e exception textColor=red condition source=p_e operator=gt operand1=10 exception field field name=f_p_e1 source=p_e exception textColor=blue condition source=p_e operator=gt operand1=10 exception field section layout report In this example, the value for operator is gt, for greater than. Operators include those listed in Table 22–1 : Table 22–1 Values for the operator Attribute Value Usage eq equal lt less than lteq less than or equal to neq not equal to gt greater than gteq greater than or equal to btw between notBtw not between like like notLike not like null null notNull not null Customizing Reports with XML 22-7 Notice also that, unlike the previous example, the field tags in this example uses sub-tags, and, consequently, closes with field, rather than a self-contained closure .

22.2.5 Adding Program Units and Hyperlinks

The example in this section demonstrates the use of XML to add a program unit to a report, which in turn adds a hyperlink from the employee social security number :SSN to employee details. report name=anyName DTDVersion=9.0.2.0.0 layout section name=header field name=F_ssn1 source=ssn1 advancedLayout formatTrigger=F_ssn1FormatTrigger field section section name=main field name=F_ssn source=ssn advancedLayout formatTrigger=F_ssnFormatTrigger field section layout programUnits function name=F_ssn1FormatTrigger textSource [CDATA[ function F_ssn1FormatTrigger return boolean is begin SRW.SET_HYPERLINKEMP_DETAILS_ || LTRIMTO_CHAR:SSN || ; return TRUE; end; ]] textSource function function name=F_ssnFormatTrigger textSource [CDATA[ function F_ssnFormatTrigger return boolean is begin SRW.SET_LINKTAGEMP_DETAILS_ || LTRIMTO_CHAR:SSN || ; return TRUE; end; ]] textSource function programUnits report A CDATA tag is used around the PLSQL to distinguish it from the XML. Use the same tag sequence when you embed HTML in your XML file. In this example, the functions are referenced by name from the formatTrigger attribute of the advancedLayout tag.

22.2.6 Adding a New Query and Using the Result in a New Header Section

The example in this section demonstrates the use of XML to add a new query to a report and a new header section that makes use of the query result. report name=ref DTDVersion=9.0.2.0.0