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.
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 boxNote: 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:
Property | Value |
---|---|
x | max/2 |
y | max/2 |
anchorx | 0.5 |
anchory | 0.5 |
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)
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.