Defining PXML expressions

If a property is of type Measure of Distance, Ratio, or PXML String expression, its value is defined using the PXML expression language.

PXML expressions are interpreted by the PXML layouter during runtime. There are two types of PXML expression: Numeric and String.

PXML Numeric expressions

A PXML Numeric expression yields a value that is expressed as either a measure of distance or a ratio .

A measure of distance (such as X-Size or Border Width) is expressed in units of measurement, for example, 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. The most commonly used units are:

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

For additional examples of units, see Unit Names.

A ratio (such as Scale X or Proportional Width) specifies the value as a proportion of another value. Ratio properties should not include units of measurement.

Properties of type PXML Numeric expression are typically used to define the layout of report elements. For example, many of the properties that modify margins, borders, and padding are of type PXML Numeric expression.

PXML String expressions

A PXML String expression yields a string value. For example, properties of type PXML String expression can be used to create a page number string.

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
Note: In previous versions of Genero Studio, to force a page break after the object, you would use the rest variable in the Y-Size or X-Size properties. This is no longer required; you can now force a page break using the Break element.

Functions

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.