Setting how data is formatted and calculated
About this task
You can define the content of a template using simple values, data expressions, or script expressions.
- Simple value: A simple value allows you to enter static text or make a selection from a list. For example, look at the properties for a text element. For the Content property, in the Simple value tab, you enter static text that displays in the output. In the Bold property, in the Simple value tab, you can select true or false.
- Data expression: A data expression allows you to enter the variables and attributes that are available in the current context. When you have a variable or attribute available in your template, you can select a single attribute or a single variable.
- Script expression: A script expression
allows you to enter calculated values through a JavaScript. Create JavaScript snippets to process the data
attributes. Script expressions can combine data attributes, trim white
space, and transform numeric values into textual descriptions. The
script can use any number or combination of variables and data source
properties. Only JavaScript is
supported in the script expression box by Rational® Publishing Engine.
Tip: You can adjust the width of the Variables and Attributes column in the Script expression tab to provide more space to edit your scripts. Hover the mouse over the sash between the two sections. When your cursor changes to a double-arrow, hold down the mouse and drag the sash to the desired width.
| Variable | Description |
|---|---|
| _cell_number | The cell number in a current row. If the element is not a cell, the value is 0. You can use _cell_number from either the Data expression or the Script expression tab. |
| _element_id | The element number within the template. Kept internally in the template and used for debugging. You can use _element_id from either the Data expression or the Script expression tab. |
| _element_level | The recursive level of an element. If there is not a value set for the element in the Recursive Level property in the Data tab, the value is 1. You can use _element_level from either the Data expression or the Script expression tab. |
| _row_number | The row number in a current table. If the element is not contained by a row element, the value is 0. You can use _row_number from either the Data expression or the Script expression tab. |
| _sessionInfo | Run time property information from
the template or document specification. In the Script expression tab,
select the _sessionInfo variable and enter
the script. Use empty quotation marks without a value inside to generate
the default value for the property in the output. Script examples: _sessionInfo.getDocspecProperty("property", ""); For the getDocspecProperty, you can use existing document specification properties or create custom metadata properties. |
| _sessionLogger | For debugging purposes, you can display
customized information, error, warning, or debugging messages in the TEMP\rpe\rpe.log file, Console view,
or Problems view. The messages display in the
location that is defined in the log4j.properties file. The default setting is to display information messages in the Console view, but not in the rpe.log file. In
the Script expression tab, select the _sessionLogger variable
and enter the script. You can generate log entries with one of the
following methods:
When deciding what to enter as the message in your script, consider using a visual callout, like your initials or user name, and using variables from your template to make meaningful messages. |
| _sessionUtils | In the Script expression tab, you can
use this variable to run a function on the script called tidyXHTML.
This variable is useful when you notice blocks of white space in the
output that is created by improper XHTML coding. With the _sessionUtils variable,
a string argument is processed and the XHTML is cleaned up so that
the extra white space does not display in the output. Example: _sessionUtils.tidyXHTML(text); When
you use the _sessionUtils variable, also select
the XHTML Input and XHTML Output options
in the Script expression tab.
Note: Templates that include this variable
can be loaded into older versions of Rational Publishing Engine,
but the scripts cannot be evaluated correctly.
|
Procedure
Example
- Drag a table element into the editor.
- Enter the 3 rows and 3 columns for the table and click OK.
- Drag a text element into each cell.
- Select the first cell in the first row.
- In the Properties view, select the Content tab
and click
. Double-clicking the element also opens the same
window. - Click the Data expression tab and select _row_number. Then click OK.
- Repeat for the first cell in the second row and the third row.
- Optional: Remove the borders from the row number cells:
- Hold the CTRL key and select the first cell in each row. When you have multiple elements selected, you can edit the properties for all of them at the same time.
- In the properties view, select the Border tab.
- For the Style property, select none.
- Save the template.
- Test the template by generating the output. The first cell includes
the row number and does not have borders around it:

- In the template, finish adding attributes from your data source schema to the remaining cells to complete the table.