Example: Creating a script expression to style headings with Rational® RequisitePro®

This example uses RequisitePro.xsd Generic XML schema, which includes the Level attribute in the PRRequirement query.

Procedure

To create a report with heading styles applied to the FullTag:

  1. In the Launcher, create a document specification and configure the data source.
  2. In Document Studio, open a new template.
  3. Add the sample data source schema:
    1. In the Data Source Schemas view, click the Add Data Source Schema icon. The Data Source Schema wizard opens and you can click Next.
    2. In the Schema Type field, select Generic XML.
    3. Optional: Enter a custom name for the Data Source ID.
    4. Click Next. Review your selections and click Finish.
  4. Click Browse and select the RequisitePro.xsd sample data file installed with the product. Default location: %RPE_HOME%\source\XML\examples\RequisitePro.xsd. Click Open.
  5. Add elements to your template.
    1. Add a Container icon Container element.
    2. Insert a Paragraph icon Paragraph element into the container element.
    3. Insert a Text icon Text element into the paragraph element.
      Template example with elements
  6. Add queries to your elements.
    1. In the Data Source Schemas view, expand the project and requirements.
    2. Drag PRRequirement into the container element.
    3. Drag FullTag (string) into the text element.
    4. In the Select Context window, select Use as value.
    5. Select the PRRequirement container and click OK.
      Template example with the queries in the elements
  7. Create a style script expression for the paragraph element.
    1. Select the paragraph element.
    2. In the Properties view, select the General tab.
    3. In the Style name field, click the Configuration icon configuration icon.
    4. In the Set style name value window, select the Script Expression tab.
    5. Expand Attributes and the data source.
    6. Select Level.
    7. Enter parseInt(Level) + 1.
  8. Click Document Specification > Generate > Generate Document to generate the output.

Results

As the Level values increase by one, the heading styling increases by one as well. The Heading 1 style is set on the FullTag values for the requirements that have 0 as the Level value. The Heading 2 style is set on the FullTag values for the requirements that have 1 as the Level value.

The final output document created by the template in this example:
  • Displays the FullTag values as the section titles.
  • Displays a visible hierarchy of the requirements:
    • The requirements are the largest headings and use the Heading 1 style.
    • The child requirements are subheadings and use the Heading 2 style.
  • Creates the hierarchy on the values of the Level attribute.

Feedback