When you reference the Sub-Template from the main template you need to specify an absolute path to the Sub-Template file with either the http or file option in the Import syntax. This is easy when you are developing your reports at your local machine or the development instance. However, sometimes you don’t know where the Sub-Template files will end up being located. For example, your production environment probably will be a different server and have a different directory (or folder) structure. So you don’t want to hard-code the http or file path to the Sub-Template, which you don’t know where it will be at for your deployment. Otherwise, you need to go visit each single RTF template file to update the location path.
There is a limitation that you cannot get a value from the XML data and assign it to the Import syntax. However, you can assign values from BI Publisher’s pre-defined properties or custom properties that you can create both at a server and a report level.
Today, I will go through the steps to make your File or HTTP path dynamic so that the Sub-Template implementation can be independent from any instance and be easier to maintain.
Here is the default ‘import’ syntax where you set the absolute path to the Sub-Template file as we saw yesterday.
<?import:http://knishida-lap.us.oracle.com:9704/bip/Header_Sub.rtf?>
Now, you don’t know where the Header_Sub.rtf file will be at a testing or production environment. Or you might need to change the above server location in future. So you want to make the above path dynamic.
This is where the custom property comes in to rescue. I will show you how to set the custom property later, but for now, let’s assume we have a custom property called, ‘HTTPSERVER’, and the value is ‘knishida-lap.us.oracle.com:9704/bip’.
You can use a dollar sign and surround the property name with curly brackets (e.g. ${HTTPSERVER}) and embed it into the path like below.
Example : <?import:http://${HTTPSERVER}/Header_Sub.rtf?> |
When a value of the property ‘HTTPSERVER’ is set to ‘knishida-lap.us.oracle.com:9704/bip’ the above ‘import’ syntax will be dynamically constructed as
<?import:http://knishida-lap.us.oracle.com:9704/bip/Header_Sub.rtf?>
at the report generation time.
Now how to set the custom property?
Here is a list of the step on how to set the custom properties at the BI Publisher server level.
1. Create a custom configuration file, xdo.cfg, if you don’t have it yet, and add the following line.
<config version="1.0.0" xmlns="http://xmlns.oracle.com/oxp/config/"> <!-- Properties --> <properties> <property name="xslt.HTTPSERVER">'knishida-lap.us.oracle.com:9704/bip'</property> </properties> </config> |
2. Place the xdo.cfg under %BIP_REPOSITORY_HOME%/Admin/Configuration
If your BI Publisher Repository root is ‘C:\OracleBI\xmlp\XMLP’ the xdo.cfg file should be located at
C:\OracleBI\xmlp\XMLP\Admin\Configuration
3. Restart the Application Server (e.g. OC4J) to take the property setting in effect.
Additionally, you can also set this property at the report level. In this case you can locate the xdo.cfg file at the same folder where the BI Publisher report definition file (.xdo) is located.
That’s it, now you are set with the custom property so try testing it!
When you need to deploy your reports to another instance like Testing or Production then you need to make sure that the custom property is set at the server level. Once the property is set then all the reports using the property in the Sub-Template import syntax should work without any hassle!
Lastly, there are some pre-defined properties that you can use in the import syntax. This can be useful especially when you have a different set of Sub-Template files for each language and you want to import an appropriate template based on the user’s session language setting.
Here is a list of the BI Publisher’s pre-defined properties.
- _XDOCALENDAR
- _XDOLOCALE
- _XDOTIMEZONE
- _XDODFOVERRIDE
- _XDOCURMASKS
- _XDONFSEPARATORS
- _XDOCHARTTYPE
- _XDOOUTPUTFORMAT
- _XDOSVGFONTEMBED
- _XDOCTX
All the locale related properties values are coming from the user’s preference setting at the BI Publisher Server.
That’s it for today. Happy Thanks Giving!