« A subscripting welcome and sub templates Main | Conditional Check Signature Images »

More Subtemplates ...

I have seen a few questions around sub templates on the forum recently. Using subtemplates is a very powerful way of making your life as a template developer much easier, if you have a piece of formatting functionality that you intend to use across multiple templates then break it out as a sub template you can then benefit from write once - maintain in one place. This also applies to headers and footers, most if not all of you will have an 'organization' header and footer that you need to have on all of your documents - again just create a sub template and reference it from all your top level templates, you can even pass parameters to the header/footer formatting to 'personalize' the header for each template but still manage only a single sub template.

RTF or XSL


You can use either RTF or pure XSL as a subtemplate. RTF is great if you have some visual formatting you need to do - much easier to develop using MSWord than writing XSL. XSL has its place thou, if you have some heavy lifting to do on the data to format it i.e. calculations, etc then XSL is the way to go.

Templates and functions ...
Its a little confusing when starting out with XSL. The complete formatting file is called a 'template' and the formatting functions within a subtemplate are also called templates ... just think about them as functions. You pass the function some object and it returns the modified object.

A Quick Example ...
Lets assume we want a common header and footer for our report outputs, we have a logo, data stamp, etc and we want to put the report name into it too. The report name is going to have to be dynamic and passed to the sub-template at runtime, we can achieve this because XSL lets us pass parameters around in the template call.  

So we have a sub template looking like the following, I have put in the raw commands rather than formfields to make it easier to see whats going on:

HeaderFooter:

A you can see we have the template declaration:
<?template:Header?>
<?param:ReportName;string('My Report')?>

This declares a template called header and it is expecting a parameter called 'ReportName', if it is not populated at runtime then the default, 'My Report' will appear (this is not mandatory). The footer template is declared in a similar fashion.

In our calling template we will have something like:
  <?call@inlines:Header?>
   <?with-param:ReportName;string('Employee Report')?>
  <?end call?>

In the MSWord header of our template, this is calling the Header template and passing the parameter 'ReportName' with the value 'Employee Report', this could equally be an element name if you extracted the report name in the XML data. In the bdy of the template we need to declare that we want to use the sub template in this main template, so we will have a declaration:

<?import:file:///C:/temp/HeaderFooter.rtf?>

This brings up another interesting question for EBS template developers, how do I test my sub template without deploying it to the template manager. Well the import statement supports a URI reference so we can either use the file URI or a UR to reference our sub template. In this case the subtemplate is in the c:/temp directory. Very useful when you want to test. For EBS developers, remember to change this to the 'xdo:' URI format prior to deploying.  
So when we run the main template it will call the Header template and pass in the report name i.e. Employee Report to the subtemplate and the full header will be passed back to the calling template including the logo, timestamp, etc.

So sub templates need a little effort to set up but the benefits going forward far outweigh the cost. Write it once and deploy it everywhere and maintain it in one place going forward ... when management decide to change the company branding overnight you'll thank your lucky stars you used sub templates!

Comments (9)

Paul:

Hello all,
I have a xsl sub template I want to reference it from a template. But I only want the subtemplate on the BIP server not on the client. How can I do it?
thanks
Paul

manjiri:

Hi,

I have RTF template with multiple pages. It doesn't have header on first page. All remaining pages have same header. In page setup > Layout tab, I checked "Different on first page" option under Headers and footers. On preview, XMLP doesn't show any header. Can you please help me with this?
If I put tag at the start of second page, it's not showing first page. If I put seperate start/end tags for first and second page, it's giving error. So please suggest me the way to do this.
Thanks for your help.

Regards,
Manjiri

Lee Eggleston:

I think it's important to note users need to disable external references in order for this to work. I'm in the midst of creating a sub-template, but am not sure I can continue, as we are using BIP with EnterpriseOne as a standalone.

qi guan:

I try to write a test sample according to this article,but It doesn't work, can you give us a sample? thanks.

submits to esolidlyone for your say gab ups - there’s so numerous (this vocation got to the top of Digg and ambrosial) it’s primary to discern where to start.

Paulo Domingues:

Hi Tim.

I have done all you described above but I can not see the parameter values in the header.

I am using BI Publisher 10.1.3.4 Standalone in Windows Vista and Office 2007.

My subtemplate.rtf goes like this





Page 1

as to my report.rtf goes like this:
in the Header section of the page I have



in the body I have




the problem is that the ReportName does not appear and there is no error message.

The subtemplate is call since I put there a logo and it appears.

What am I doing wrong?
Any help would be appreciated.
Thanks in advance.

Paulo Domingues

TS:

Hi,
I am trying to use sub templating and I am getting error.
I am using 10.1.3.4 BIP Version.

Can you pls post the example code..

Thanks
TS

Frank Staheli:

I want to be able to pass two date variables from my PeopleSoft App Engine Table into the report's header (so that in my header, one line can use the two date variables to say something like "Students who Withdrew from School between 5/11/2009 and 5/30/2009".

How do I go about that?

David Weber:

Hi,

finally another article on subtemplates that explains exactly what I am trying to do since a while, but never succeed:

You say "For EBS developers, remember to change this to the 'xdo:' URI format prior to deploying."

BUT: What is the "XDO:" format syntax that I could use in XSL templates?! Nobody is able to explain how to refer to templates stored in the template manager, within XSL templates.

Every documentation is for RTF formats, nothing for XSLT :(

Any advices would be really helpful. Thanks,
David.

Btw: the blog is really great, some helpful articles. I'd love to see less RTF and more XSL. Same for the Oracle Documentation on BIP. XSL is falling behind in my opinion...

Post a comment