When designing a template, it might be necessary to calculate
values or to make data attributes available in contexts where they
are normally unavailable. To do this, define variables and assign
them values. The values can be static data or data available in the
current context.
About this task
Variables can be used as placeholders for data calculated
at runtime (variable assignments) or can be provided in the document
specification. Unlike data attributes, you can also use variables
in master pages. The variables are of two types:
- User-defined variables: User-defined variables are defined by
the template designer. A user-defined variable can be internal or
external.
Specify a variable as internal to perform calculations
or to temporarily store information (such as a variable that is used
to bring data into the master pages). Internal variables are not displayed
in the document specification; therefore, you cannot provide them
with values.
Specify a variable as external when you provide
it with a value. External variables are displayed in the document
specification. See Assigning values in document specification file.
- Rational® Publishing Engine variables: Rational Publishing Engine variables are internal variables available for use in
the document template.
Variable |
Description |
_element_id |
Kept internally in the template and used for debugging. |
_element_level |
The recursive level of an element. |
_row_number |
The row number in a current table. If the element is not
a row the value is 0. |
_cell_number |
The cell number in a current row. If the element is not a
cell the value is 0. |
Procedure
- In the Outline view, click . The New Variable window opens.
- Enter the variable details in the following fields:
- Name: Enter the name of the variable.
- Description: Enter the description
for the variable.
- Default Value: Enter the value
for the variable.
- Access: Select whether the variable
is internal or external from the list.
Internal variables
are not displayed in the document specification; hence you cannot
provide them with values.
External variables are displayed in
the document specification and you can provide values to them.
- To assign a variable, in Document Studio, in the editor
area, right-click the element and click . The Assignment Editor
window opens, which lists the current assignments for the element
and allows you to define new assignments.
- Click Add. The Select
Variable window opens.
- Enter a new name and click OK.
- Click OK in the Assignment Editor
window.
Results
The selected variable is defined and assigned to the current
element.