5 August 2023

Calling a Subtemplate from a BI Publisher Template

Advised Solutions - Business Analytics Series

How to Call a Subtemplate from a Main Template in Oracle BI Publisher

Oracle BI Publisher allows report developers to create modular and reusable templates by using subtemplates within a main template. This approach improves maintainability, reduces duplication, and helps standardise common elements like company headers, footers, logos, or disclaimers across multiple reports.

Two Key Steps to Use a Subtemplate

To implement a subtemplate within your main template, there are two essential steps:

01.

Import the Subtemplate File

Include an import command in your main template that points to the location of the subtemplate file (in the BI Publisher catalog). This tells the BI Publisher engine where to find the reusable subtemplate content.

Example import syntax without locale specification:

				
					<?import:xdoxsl:///Custom/Financials/Payments/Footers.xsb?>
				
			

Using Localized Subtemplates

You can also import localized versions of a subtemplate by appending the loc parameter to the import statement, which is especially useful for reports distributed in multiple languages.

				
					<?import:xdoxsl:///Custom/Financials/Payments/Footers.xsb?loc=en-US?>
				
			

Or dynamically based on the user’s locale:

				
					<?import:xdoxsl:///Custom/Financials/Payments/Footers.xsb?loc=${_XDOLOCALE}?>
				
			

02.

Call the Subtemplate to Render Its Contents

At the position in your main template where you want the subtemplate to appear, use the call-template command with the name defined in the subtemplate’s <?template:template_name?> declaration.

Example:

If your subtemplate declares its main content with:

				
					<?template:HEAD_QUATERS?>
 My Company Plc, 01 Main Street, Any City, SE1 1AB
For enquires please contact us at XXXXX XXXXXX, quoting your Name and Reference Number.
<?end template?>

<?template:REGISTERED_OFFCICE?>
 My Company Plc, 02 Long Road, Any City, SE1 1YZ
For general enquires please contact us at XXXXX XXXXXX 
<?end template?>

				
			

You would call it in your main template like this:

				
					<?call-template:HEAD_QUATERS?>
				
			

When the report runs, the content of the subtemplate replaces this call command.

Benefits of Using Subtemplates

  1. Reusability: Define common elements once and reuse them across multiple templates.

  2. Maintainability: Update the subtemplate, and changes automatically propagate.

  3. Consistency: Ensures uniform formatting and content across reports.

  4. Modularity: Organise complex reports into manageable components.

Need some assistance?

Ready to bring clarity to customer, supplier and employee communications? With BI Publisher, we specialise in customising customer, supplier, and employee-facing documents such as invoices, purchase orders, payslips, and statements to meet your exact branding, compliance, and operational needs. From layout design to data logic enhancements, we help you deliver clear, consistent, and impactful outputs across your organization. Contact us today to discover how our expertise in BI Publisher can streamline your document processes and elevate your business communications.