Creating a script expression to style headings

You can create heading styles on template elements, which corresponds the values for data attributes or variables with certain formatting properties.

About this task

In Microsoft Word, PDF, and HTML outputs, you can create section titles and assign heading styles to those titles, creating an informational hierarchy in your document. Rational® Publishing Engine requires a numeric assignment for those titles that starts with 1 to align the heading style numbers with. Some data that you might want to assign heading styles to do not start with 1 or use string values instead of numeric ones. Complicating the standardization of these styles across all output formats, each output format uses different names for these heading styles. For example, in Microsoft Word, the largest heading style is named Heading 1. In HTML, the same heading style is named H1.

You can use the parseInt(attribute_or_variable_name) JavaScript expression to align attribute or variable values with numeric values starting with 1. Then, to create subheadings on child data, add one to the expression: parseInt(attribute_or_variable_name) + 1. This script expression allows the values to correspond incrementally to the heading styles in all of the Microsoft Word, PDF, and HTML outputs.

Procedure

  1. Drag a Text icon Text element into the template content editor.
  2. Select the text element.
  3. In the Properties view, select the General tab.
  4. In the Style name field, click the Configuration icon configuration icon.
  5. Select the Script Expression tab.
  6. Select a variable or attribute.
  7. Enter the JavaScript expression: parseInt(attribute_or_variable_name) + 1
  8. Click OK.

What to do next

A heading style is the most common styling to apply using script expressions. However, you might also try applying script expressions to font sizes, border sizes, or margin sizes as well.

Feedback