Call a Subtemplate from a Main Template

There're two entries that you must make to call a subtemplate from a main template.

To implement the subtemplate in a main template, you must make two entries in the main template:

First, import the subtemplate file to the main template. The import syntax tells the Publisher engine where to find the Sub Template in the catalog.

Second, enter a call command to render the contents of the subtemplate at the position desired.

Import the Subtemplate to the Main Template

Enter the import command anywhere in the main template prior to the call template command.

If you do not require a locale, enter the following:

<?import:xdoxsl:///path to subtemplate.xsb?>


path to subtemplate.xsb is the path to the subtemplate .xsb object in the catalog.

For example:


If the subtemplate resides in a personal folder under My Folders, the command to import the subtemplate is:

<?import:xdoxsl:///~username/path to subtemplate.xsb?>

where username is your user name.

For example, if user myuser uploads a subtemplate called Template1 to a folder called Subtemplates under My Folders, the correct import statement is:


Call the Subtemplate to Render Its Contents

You can also enter a call command to render the contents of the subtemplate at the position that you desire.

  • In the position in the main template where you want the subtemplate to render, enter the call-template command, as follows:


    template_name is the name you assigned to the contents in the template declaration statement within the subtemplate file (that is, the <?template:template_name?> statement).

The following figure illustrates the entries required in a main template:

Import a Localized Subtemplate

To designate the locale of the imported subtemplate, append the locale to the import statement as shown here.

<?import:xdoxsl:///{path to subtemplate.xsb}?loc={locale_name}?>


path to subtemplate.xsb is the path to the subtemplate .xsb object in the catalog


locale_name is the language-territory combination which comprises the locale. The locale designation is optional.

For example:


Note that you can also use ${_XDOLOCALE} to import a localized subtemplate based on the runtime user locale. For example:



In this example, your company address is a fixed string that is displayed in all your templates. Rather than reproduce the string in all the templates, you can place it in one subtemplate and reference it from all the others.

To place the string in a subtemplate and reference it:
  1. In an RTF file enter the following template declaration:
    My Company
    500 Main Street
    Any City, CA 98765
    <?end template?>
  2. Create a Sub Template in the catalog in the following location: Customer Reports/Templates.
  3. Upload this file to the Sub Template and save it as "Common Components" (Publisher assigns the object the .xsb extension).
  4. In the main template, enter the following import statement in a form field or directly in the template:
    <?import:xdoxsl:///Customer Reports/Templates/Common Components.xsb?>
  5. In the main template, in the location you want the address to appear, enter:

At runtime the contents of the MyAddress subtemplate are fetched and rendered in the layout of the main template.

This functionality isn't limited to just strings, you can insert any valid RTF template functionality in a subtemplate, and even pass parameters from one to the other. For examples, see When to Use RTF Subtemplates.