BLOG CATEGORIES



Setting Heading Styles using Script expression based on data source attributes

There are some situations when we want to set some formatting properties of the Template elements based on the values of data attributes. For example we 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.

To exemplify this idea we will use the Generic XML schema and the PR_Requirements.xml file located in the source/XML/examples folder in the installation directory of RPE.

In the Generic XML schema we have the level attribute of the PRRequirement query. For the Paragraph used to display information of this query we will 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 we will use the following java script expression to set the style name: “parseInt(Level) + 1”.

Figure 1. Template content

The template content that will prove this concept is presented in the Figure 1. We have a Container. The query Project/Requirements/PRRequirement is set to this Container. In the Container we create a Paragraph to present the data from the data source. Inside this Paragraph we have a Text element displaying the value of a data source attribute. The style name property of the Paragraph will be set to the “parseInt(Level) + 1” value.

Figure2. . The style name Script Expression value

A fragment of the output document produced by RPE 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.

Figure3. Output Word Document

Leave a Reply

(required)

(required)