Setting how data is formatted and calculated

Define the content of a template element or its property values for formatting and calculating data.

About this task

You can define the content of a template using simple values, data expressions, or script expressions. A data expression is a value read from a data source while a scripted expression is a value calculated through a JavaScript. 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. The scripted expression box allows you to write JavaScript to calculate a value while the data expression box allows you to select only one property or one variable.

Procedure

  1. In the template content editor, double-click the text element. The Set content for current element window opens.
  2. Specify the content by using one of the following options:
    • To use a simple value, click the Simple value tab, type a value, and click OK.
    • To use a data expression, click the Data expression tab, expand Variables and, select the check box for the variable to use. Expand Attributes, select the check box data attributes, and click OK.
    • To use a script expression, click the Script expression tab, expand Variables, and enter the JavaScript code that can use the variables in the current context. Expand Attributes and enter the JavaScript code that can use the data attributes in the current context. Click OK. For example, to select the attributes as absolute number, name and value, type the JavaScript code as:
      "object:"+Absolute Number+
      "attribute"+name+
      "value"+_value
      Tip: If you have a fairly complex template, you can describe each block in the template using Properties > Metadata > Name and Description attributes. The name and description fields are empty by default, the name content displays in the template, and the description content can be displayed in the template element hint field. This can help others reuse the template.

Feedback