Skip to Content

Solved: How to Fix RTF Output Problems with Multiple Groups in BI Publisher

  • The article explains how to fix the RTF output issue with multiple groups in BI Publisher, which occurs because of the XSL-FO limitation of not supporting nested tables.
  • The article provides a solution using the for-each@section and xdoxslt:grouping_field functions, which allow creating multiple tables without nesting them, and shows an example of the syntax and the output.
  • The article also gives some tips and best practices for creating RTF templates with multiple groups, such as using the split-by-page-breakcount, and sum functions, and optimizing the template for SEO.

If you use BI Publisher to create reports, you may have encountered a problem when trying to display multiple groups in an RTF template. The output may only show the first group, while the rest of the groups are missing or duplicated. This can be frustrating and confusing, especially if you need to present accurate and complete data to your clients or stakeholders.

In this article, we will explain why this problem occurs and how to fix it with a simple solution. We will also provide some tips and best practices for creating RTF templates with multiple groups. By the end of this article, you should be able to create reports that display all the groups correctly and avoid common pitfalls.

Why Does the RTF Output Issue Occur?

The RTF output issue with multiple groups occurs because of the way BI Publisher processes the XML data and the RTF template. BI Publisher uses XSL-FO (Extensible Stylesheet Language Formatting Objects) to transform the XML data into a formatted output. XSL-FO is a standard for describing how XML documents should be presented.

However, XSL-FO has some limitations when it comes to handling multiple groups in an RTF template. According to Oracle’s documentation, XSL-FO does not support nested tables, which means that you cannot have a table inside another table. This is a problem if you want to display multiple groups in an RTF template, because each group is usually represented by a table.

For example, let’s say you have an XML data source that contains two groups: G_1 and G_2. Each group has two fields: F_1 and F_2. You want to create an RTF template that displays both groups in separate tables, like this:

G_1.F_1 G_1.F_2
A B
C D
G_2.F_1 G_2.F_2
E F
G H

To achieve this, you may use the following syntax in your RTF template:

<?for-each-group:G_1;./G_1?>
<table>
<?for-each:current-group()?>
<tr>
<td><?G_1.F_1?></td>
<td><?G_1.F_2?></td>
</tr>
<?end for-each?>
</table>
<?end for-each-group?>

<?for-each-group:G_2;./G_2?>
<table>
<?for-each:current-group()?>
<tr>
<td><?G_2.F_1?></td>
<td><?G_2.F_2?></td>
</tr>
<?end for-each?>
</table>
<?end for-each-group?>

However, this syntax will not work as expected, because BI Publisher will treat the second table as a nested table inside the first table. As a result, the output will look like this:

G_1.F_1 G_1.F_2
A B
G_2.F_1 G_2.F_2
E F

| C | D |

| G | H |

As you can see, the output only shows the first row of each group, while the rest of the rows are pushed to the bottom of the page. This is not what we want.

How to Fix the RTF Output Issue with Multiple Groups?

The solution to fix the RTF output issue with multiple groups is to use a different syntax in your RTF template. Instead of using for-each-group, you can use for-each@section and xdoxslt:grouping_field functions. These functions are specific to BI Publisher and allow you to create multiple tables without nesting them.

The syntax for using these functions is as follows:

<?for-each@section:G?>
<table>
<?xdoxslt:set_variable($_XDOCTX,'V',xdoxslt:grouping_field(.//FIELD))?>
<tr>
<td><?FIELD?></td>
</tr>
<?end for-each?>
</table>
<?end for-each@section?>

In this syntax, G is the name of the group element in your XML data source, and FIELD is the name of the field element in your XML data source. The xdoxslt:set_variable function creates a variable named V that stores the value of the grouping field. The xdoxslt:grouping_field function returns the value of the field that defines the group.

Using this syntax, you can create an RTF template that displays both groups in separate tables, like this:

<?for-each@section:G_1?>
<table>
<?xdoxslt:set_variable($_XDOCTX,'V',xdoxslt:grouping_field(.//G_1.F_1))?>
<tr>
<td><?G_1.F_1?></td>
<td><?G_1.F_2?></td>
</tr>
<?end for-each?>
</table>
<?end for-each@section?>

<?for-each@section:G_2?>
<table>
<?xdoxslt:set_variable($_XDOCTX,'V',xdoxslt:grouping_field(.//G_2.F_1))?>
<tr>
<td><?G_2.F_1?></td>
<td><?G_2.F_2?></td>
</tr>
<?end for-each?>
</table>
<?end for-each@section?>

The output will look like this:

G_1.F_1 G_1.F_2
A B
C D
G_2.F_1 G_2.F_2
E F
G H

As you can see, the output shows all the rows of each group in separate tables, as we wanted.

Tips and Best Practices for Creating RTF Templates with Multiple Groups

Here are some tips and best practices for creating RTF templates with multiple groups:

  • Use the for-each@section and xdoxslt:grouping_field functions instead of the for-each-group function to avoid nested tables.
  • Make sure your XML data source has a clear and consistent structure for your groups and fields. For example, use the same element name for all groups and the same element name for all fields within a group.
  • Use the split-by-page-break command to insert a page break between each group. This will make your output more readable and organized. For example, you can use this syntax:
<?split-by-page-break:yes?>
<?for-each@section:G?>
<table>
<?xdoxslt:set_variable($_XDOCTX,'V',xdoxslt:grouping_field(.//FIELD))?>
<tr>
<td><?FIELD?></td>
</tr>
<?end for-each?>
</table>
<?end for-each@section?>
  • Use the count function to display the number of rows or records in each group. This will help you verify that your output is complete and accurate. For example, you can use this syntax:
<?for-each@section:G?>
<table>
<tr>
<td>Number of records: <?count(current-group())?></td>
</tr>
<?xdoxslt:set_variable($_XDOCTX,'V',xdoxslt:grouping_field(.//FIELD))?>
<tr>
<td><?FIELD?></td>
</tr>
<?end for-each?>
</table>
<?end for-each@section?>
  • Use the sum function to calculate the total or average of a numeric field in each group. This will help you provide useful statistics and insights to your audience. For example, you can use this syntax:
<?for-each@section:G?>
<table>
<tr>
<td>Total amount: <?sum(current-group()//AMOUNT)?></td>
</tr>
<?xdoxslt:set_variable($_XDOCTX,'V',xdoxslt:grouping_field(.//FIELD))?>
<tr>
<td><?FIELD?></td>
<td><?AMOUNT?></td>
</tr>
<?end for-each?>
</table>
<?end for-each@section?>

Frequently Asked Questions (FAQ)

Here are some frequently asked questions related to creating RTF templates with multiple groups in BI Publisher:

Question: What is BI Publisher?

Answer: BI Publisher is a reporting tool that allows you to create, manage, and deliver reports from various data sources. You can use BI Publisher to design templates in various formats, such as RTF, PDF, Excel, HTML, etc., and generate outputs in multiple languages and formats.

Question: What is an RTF template?

Answer: An RTF template is a template that uses Rich Text Format (RTF), a file format that supports text formatting, images, tables, etc. You can create an RTF template using Microsoft Word or any other word processor that supports RTF. You can use BI Publisher’s tags and functions to define how your data should be displayed in your RTF template.

Question: How do I create an RTF template in BI Publisher?

Answer: To create an RTF template in BI Publisher, you need to follow these steps:

  • Download and install the BI Publisher Desktop tool from Oracle’s website.
  • Open Microsoft Word and enable the BI Publisher tab.
  • Open or create an RTF file that will serve as your template.
  • Load your XML data source using the Data Source button on the BI Publisher tab.
  • Design your template using the Insert, Preview, and Properties buttons on the BI Publisher tab. You can use BI Publisher’s tags and functions to define how your data should be displayed in your template.
  • Save your RTF template and upload it to the BI Publisher server or use it locally.

Question: How do I display multiple groups in an RTF template?

Answer: To display multiple groups in an RTF template, you need to use the for-each@section and xdoxslt:grouping_field functions instead of the for-each-group function. These functions allow you to create multiple tables without nesting them, which avoids the RTF output issue with multiple groups. You can also use other BI Publisher’s functions, such as countsumsplit-by-page-break, etc., to enhance your template.

Question: How do I optimize my RTF template for SEO?

Answer: To optimize your RTF template for SEO (Search Engine Optimization), you need to follow these tips:

  • Use relevant keywords in your template title, headings, and content. Keywords are the words or phrases that users type in search engines to find your content. You can use tools like Google Keyword Planner or Bing Keyword Research Tool to find the best keywords for your topic.
  • Use descriptive and catchy meta tags in your template. Meta tags are snippets of text that describe the content of your template. They are not visible to users, but they are used by search engines to understand and rank your content. You can use tools like Meta Tag Generator or Meta Tags to create meta tags for your template.
  • Use clear and concise URLs for your template. URLs are the web addresses that link to your template. They should be easy to read and remember, and they should contain keywords that describe your content. You can use tools like URL Generator or URL Builder to create URLs for your template.
  • Use images and videos in your template. Images and videos can make your content more attractive and engaging, and they can also help you convey your message more effectively. However, you should also optimize your images and videos for SEO by using appropriate file names, alt texts, captions, etc. You can use tools like Image SEO Optimizer or Video SEO Tool to optimize your images and videos for SEO.

Disclaimer

The information provided in this article is for educational purposes only and does not constitute professional advice. The author is not responsible for any errors or omissions in this article, nor for any damages or losses arising from its use. The user should always consult a qualified expert before applying any of the techniques or solutions discussed in this article.

Conclusion

We hope this article has helped you understand how to fix the RTF output issue with multiple groups in BI Publisher. By using the for-each@section and xdoxslt:grouping_field functions, you can create RTF templates that display all the groups correctly and avoid nested tables. You can also use other BI Publisher’s functions and tips to enhance and optimize your RTF templates.

If you have any questions or feedback, please feel free to leave a comment below. We would love to hear from you!