22 Customizing Reports with XML

Extensible Markup Language (XML) is designed to improve the functionality of the Web by providing a method to promote detailed information identification. It is actually a metalanguage (a language used for describing other languages) and can be used to design customized markup languages for different type of documents.

XML documents are composed of both markup and content:

  • Elements are the building blocks of XML. An element instance is a structure that contains tags (a main tag and appropriate nested tags), attributes, and the element's content nested between the tags.

  • Tags are used to define the element and the content within it.

  • Attributes provide extra information for each tag.

XML customizations enable you to modify reports at runtime without changing the original report. With the addition of the CUSTOMIZE keyword to your runtime command line, you can call a customization file to add to or change a report's layout or data model. One XML customization file can perform all of these tasks or any combination of them. You can even use XML to build a report data model for inclusion in a custom JSP-based report.

By creating and applying different XML customizations, you can alter the report output on a per user or per user group basis. You can use the same report to generate different output depending upon the audience.

When you apply an XML customization to a report, you have the option of saving the combined definition to a file. As a result, you can use XML customizations to make batch updates to existing reports. You can quickly update a large number of reports without having to open each file in Oracle Reports Builder.

Oracle Reports Services extends the possible types of Oracle Reports XML customizations by enabling you to create an entire reports data model in XML. This includes the creation of multiple data sources, linking between data sources, and group hierarchies within each data source. Data model support through Oracle Reports XML customization means that any data model that can be created with Oracle Reports Builder can now be created by specifying XML. Additionally, all properties that can be set against data model objects can now be set using XML.

This chapter discusses the ways you can use XML to customize reports on the fly and to build data models. It includes the following sections:

This chapter lists and provides examples of the supported elements in the reports.dtd file. However, only some of the attributes of these elements are listed.

For more information, either on the additional attributes or on the Oracle Reports XML elements, tags, and attributes, refer to the following sources:

  • The reports.dtd file lists all the Oracle Reports XML elements, tags, and attributes and, where present, the attributes' default values. The reports.dtd file is located in ORACLE_HOME\reports\dtd\ on both Windows and UNIX platforms. Many of the sub-elements include symbols that denote usage rules. For example:

    • A plus sign (+) means you can have one or more of this type of element in your XML file.

    • An asterisk (*) means you can have from zero to many of this type of element in your XML file.

    • A question mark (?) means you can have either zero or one of this type of element in your XML file.

    • No mark means the element is required, and you can have one and only one of this type of element in your XML file.

    If multiple sub-elements are enclosed in parentheses and followed by a symbol, the symbol applies to all enclosed sub-elements.

  • For descriptions of selected Oracle Reports XML tags, see topic "Oracle Reports XML tags" in the Reference section of the Oracle Reports online Help.

  • Build a report that includes the type of customization you are trying to build, save the report as XML, and view the saved file in a text editor. This provides an excellent means of seeing Oracle Reports XML in action and provides you with examples of the more complex models you may wish to build.

    Note:

    For reports developed in a release prior to Oracle Reports 10g Release 2 (10.1.2) patch 2, you may find the PL/SQL 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" and/or 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>