Using the PXML expression language

Genero Report Writer provides the PXML Expression language to define the value of a property that is of the PXML (dimension) type.

Tip: The type of each property is listed in the Properties page of the Report Writer documentation.

A PXML expression always yields a Numeric value. The value is expressed in units of measurement. It is legal, for example, for the value to be 10in. If no unit is specified, the unit is presumed to be points. When you specify a value in units, it is converted internally to its equivalent value in points.

Units of Measure

The most commonly used units are:

  • point|pt
  • pica|pc
  • inch|in
  • cm
  • mm

For additional explanations and examples of the units that can be used, see Dimensions.

Variables

These variables can be used in any PXML expression to define the layout dynamically:

  • max - the maximum extent of the current parent box
  • min - the minimum extent of the current parent box
  • rest - the remainder of the current parent box
    Note:

    If the parent object is a propagating container and the child object does not fit in the remaining space for the parent object, the rest variable for the Y-Size property yields the same value as max (the child expands to the maximum extent of the parent). This forces the parent object to propagate and avoids overfullness.

For example, to center an element in its parent container you can use the max variable for these properties:

Table 1. Centering an element
Property Value
x max/2
y max/2
anchorx 0.5
anchory 0.5

To force a page break after the object, use the rest variable in the Y-Size or X-Size properties.

Functions

The PXML Expression language has a 4GL-like syntax. The most commonly used functions are:

  • max( valueA, valueB) - this is a function, not the variable listed in Variables!
  • min(valueA, valueB)
  • length(value)
  • width(value)
For example, this expression uses the functions max and width :
max(10cm,width("HELLO"))

In this example, the report engine first calculates the width of the string "HELLO", taking the current font metrics into account. It then determines which is larger (10cm or the calculated width of "HELLO") and returns the larger value.