Customization Overview Oracle Fusion Middleware Online Documentation Library

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 22-8 Publishing Reports to the Web with Oracle Reports Services data dataSource name=Q_summary selectselect portid ports, locname locations from portdescselect dataSource data layout section name=header tabular name=M_summary template=BLAFbeige.tdf labelAttribute font=Arial fontSize=10 fontStyle=bold textColor=white field name=F_ports source=ports label=Port IDs font=Arial fontSize=10 field name=F_locations source=locations label=Port Names font=Arial fontSize=10 tabular section layout report This example XML can be run by itself because it has both a data model and a complete layout. Use aliases in your SELECT statements to ensure the uniqueness of your column names. If you do not use an alias, then the default name of the report column is used and could be something different from the name you expect for example, portid1 instead of portid. This becomes important when you must specify the source attribute of the field tag, which requires you to supply the correct name of the source column the field. The labelAttribute element defines the formatting for the field labels in the layout. Because it lies outside of the open and close field tag, it applies to all the labels in the tabular layout. If you wanted it to pertain to only one of the fields, then you place it inside the fieldfield tag pair. If there is both a global and local labelAttribute element one outside and one inside the fieldfield tag pair, the local overrides the global.

22.2.7 Encoding the URL

To ensure that spaces and control characters are passed correctly, you may need to turn URL encoding on or off for the fields in your report. You can turn URL encoding on or off with the RW:FIELD tag in a report: rw:field ... urlEncode=yes|no ... The default value for urlEncode is no.

22.3 Creating XML Data Models

Oracle Reports Services introduces a greater level of sophistication in the types of data models you can create using Oracle Reports XML tags. Use XML for: ■ Creating Multiple Data Sources ■ Linking Between Data Sources ■ Creating Group Hierarchies Within Each Data Source