Formatting elements based on the source XML data

Top Previous Topic Next Topic  Print this topic

Overview:

Sometimes it is needed to highlight data from the input XML that meets certain conditions in order to make a point over some information.

 

Solution:

Elements from the XML data source inserted into the document can be formatted conditionally. However, there are different ways to conditionally display items based upon where they are located in the document and the display condition.

Items located in the document body displayed based on XML Data

Displaying items such as paragraphs or tables conditionally, based upon the xml data, can be done by applying conditions to objects.

 

1. First, the object must be selected and then the Conditional Formatting option located in the Formatting group under the Home tab.

 

2. Then the Show or Hide Object option can be enabled to set the visibility property to “hidden” and specify the condition, which represents an XPath expression.

To do this, firstly the user must assign a data source to the document.

 

conditional_values_tut0

 

3. Alternatively, a conditional section can be inserted by selecting the Conditional Section button located in the Dynamic Content group under the Insert tab.

 

conditional_values_tut1

 

Displaying Table Rows Conditionally

1. If the user inserts a table and wants to hide certain rows from displaying, then the user must set the condition on the table-row-repeat of the table (which can be selected from the Navigation bar located at the bottom of the window).

 

2. The Visibility property located in the Properties dialog bar under the Positioning group can be modified.

In order to do that, the right arrow button corresponding to Visibility must be selected, then the Conditional Values and Edit Conditions… options chosen.

 

3. Afterwards, the test condition can be added. For each condition either a static or dynamic value can be chosen (the default condition value must be static).

For the rows that will not be displayed, the collapse value must be chosen.

 

4. To check if data exists, the user must just put the element that will be checked in the expression box. For example, in the CD Catalog example provided, if the user desires to list only the products that have the price less than 10, the condition will be set like the following:

 

conditional_values_tut3

 

5. The items that have prices greater than 10 will not be displayed in the table.

 

6. Below the output result can be seen.

 

conditional_values_tut4

 

Items such as Headers and Footers, or Cover Pages Displayed Conditionally Based on Page Location

Displaying certain pages or conditional headers and footers based upon page location (first page, odd pages, even pages, etc) is done through pagination settings, not conditional formatting.

 

1. The Pagination dialog bar can be opened or hidden from the View tab. When it is open, the user will see two separate sections: Layouts and Pages. Essentially,  the user can create a separate Page Layout for each type of page that will be displayed (such as a cover page, pages with headers and footers). Then, the Page Layouts can be assigned to Page Sets.

 

2. To create a new Page Layout, the user must right click on the Layouts heading from the Pagination dialog bar and choose New Page Layout.

 

3. Then, name it (for example, “CoverPage”).

 

4. Next the user can set backgrounds, change the orientation, etc. for the CoverPage. A new Page Set can be added in a similar manner and assign to it the CoverPage, or use the existing Page Set (right click on the Page Set and select Properties).

 

5. When a Page Layout is assigned, the user can choose an occurrence condition. If the user only has one Page Set and uses multiple Page Layouts, then the ComplexMaster1 message will be displayed next to the Page Set name. The conditions can be edited using the Properties menu and the conditional options include: First Page, Last Page, Odd Pages, Even Pages, Blank Pages, Non Blank Pages, and All Others.

 

Because the text located in the document's body is described through XSL-FO attributes, in which contents can flow from one page to another, the location of certain objects in the body is not known until the document is rendered. Other than footnotes, which are well documented and supported in XSL-FO, displaying items in places other than first page, odd pages, even pages, last page, etc. conditionally based upon page numbers can be tricky.

 

For any questions, please contact support@ecrion.com.