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 and enter a value.
    • To use a data expression, click the Data expression tab and either:
      • Expand Variables and select a variable to use.
      • Expand Attributes and select a data attributes to use.
    • To use a script expression, click the Script expression tab.
      • Expand Variables, select a variable, and enter the JavaScript code that can use the variables in the current context.
      • Expand Attributes, select an attribute, and enter the JavaScript code that can use the data attributes in the current context.
      • If you copied the script from XHTML, you can select the XHTML Input option to allow the XHTML tags contained in the script to be edited.
      • If you are generating the template into XHTML output, you can select the XHTML Output option to parse the script and render the script as rich text.
      For example, to select the attributes as absolute number, name and value, enter 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 Name and Description properties. 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.
  3. Click OK to save the changes.

Feedback