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:
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.
Or dynamically based on the user’s locale:
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:
My Company Plc, 01 Main Street, Any City, SE1 1AB
For enquires please contact us at XXXXX XXXXXX, quoting your Name and Reference Number.
My Company Plc, 02 Long Road, Any City, SE1 1YZ
For general enquires please contact us at XXXXX XXXXXX
You would call it in your main template like this:
When the report runs, the content of the subtemplate replaces this call command.
Benefits of Using Subtemplates
Reusability: Define common elements once and reuse them across multiple templates.
Maintainability: Update the subtemplate, and changes automatically propagate.
Consistency: Ensures uniform formatting and content across reports.
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.

