Understanding the Report Object Model
About the ROM specification
The ROM specification defines a set of XML elements that describe the visual and non-visual components of a report. Visual components, known as report items, appear in a report, for example, data items, labels, and tables. ROM provides the framework for extended report items such as charts and cross tabs. Non-visual components support report items, but do not appear in a report, for example, data cubes, data sets, data sources, report parameters, and styles. The XML file that BIRT Report Designer generates to describe a report consists entirely of ROM elements. The ROM specification defines the elements, their properties, and an element’s relationship to other elements. ROM elements describe:
- The data source and query with which to populate a report
- The placement, size, style, and structure of report items
- The report page layout
The report design file contains XML elements that describe the ROM elements that make up the report design. The BIRT design engine interprets the ROM elements using the ROM specification and the design.xsd file. This file is located at http://www.eclipse.org/birt/2005/design and also in the plug-in, org.eclipse.birt.report.model. BIRT Report Designer displays the elements that the design engine interprets. Visual report items appear in the layout window. Data-related items such as cubes, data sets, and report parameters appear in the data explorer. All elements in the report design appear in the Outline view.
ROM elements can have properties and every property has a type. Property types are similar to variable types in programming or data types in database terminology. Like variables and data types, ROM property types can be simple or complex. Simple types include string, number, dimension, color, and so forth. Complex types include structure and list. A complex type contains more than one component. For example, a text type contains both the text and a resource key used for internationalizing the text.
The components of a ROM property are:
Most elements have simple properties that are defined by a name-value pair. There are several property types, described later in this section.
User-defined property definitions
The userProperties array provides a way for users to define custom properties. Each item in the array is a UserProperty object.
The methods array is an associative array of method names. The method name is the key into the array. The return value is a string that contains the method text.
The property types defined in ROM include:
This property type is the simplest and most common property type. A property definition of this type has the following syntax:
This property type defines a set of properties, such as custom colors. A property definition of the property-list type has the following syntax:
<property-list name="propName"> [ <structure> ... </structure> ] * </property-list>
This property type defines custom XML. A property definition of the xml-property type has the following syntax:
The value for this property type is an expression. A property definition of the expression type has the following syntax:
This property is a collection of two or more properties. A property definition of the structure type has the following syntax:
<structure name="propName"> <property name="member1">value1</property> <property name="member2">value2</property> </structure>
A ROM slot is a collection of identically typed elements. For example, a report element has a slot of style elements that comprise all the styles available to the report.
Report items can have four events: onPrepare, onCreate, onPageBreak, and onRender. Each of these events fires during different phases of report creation. The onPrepare event fires in the preparation phase. The onCreate event fires during the generation phase. The onRender and onPageBreak events fire during the presentation phase.
The ROM style system is based on cascading style sheets (CSS), where a style set in a container cascades to its contents. The Report element contains all other elements, so the style property of the Report element defines the default style for the entire report. An element within the report can override the default style. A report developer can either choose a style from a defined set of styles or create a new style. Typical style attributes include color, text size, alignment, background image, and so forth. For more information about the styles, see the ROM reference in the BIRT online help.