Setting heading styles using script expression based on data source attributes
You can set some formatting properties of the Template elements based on the values of data attributes. For example, you can set the heading style for a paragraph element using a java script expression that produce a value based on a data source attribute value.
Use the Generic XML schema and the PR_Requirements.xml file located in the source/XML/examples folder in the installation directory of Rational® Publishing Engine.
The Generic XML schema has the level attribute of the PRRequirement query. For the paragraph used to display information of this query, set the style name value to a java script expression. This expression will use the parseInt java script function that will return the number value of the string representing an integer number passed as input parameter. Taking into account that the level attribute of the PRRequirement query can have also the “0” value use the parseInt(Level) + 1 java script expression to set the style name.
The template content has a container. The query Project/Requirements/PRRequirement is set to this container. In the container, create a paragraph to present the data from the data source. This paragraph contains a text element displaying the value of a data source attribute. The style name property of the paragraph is set to the parseInt(Level) + 1 value.
This is a fragment of the output document produced by Rational Publishing Engine using this template: The Heading style 1 is set to the Requirement of Level 0 and the Heading style 2 is set to the Requirements of Level 1.