<?import:[template URI]?>then you can call a specific template within the main template:
<?call:Header?>What you may not know is that you can call the templates conditionally. Before we get to that thou, a note. You can not conditionally load the sub-template file i.e.
<?if:x=1?> <?import:[template URI]?> <end if?>
will not work. The import calls can not be executed at run time they are like pre-processor commands, like 'h' files in C.
With that said you can then conditionally call a template within that imported sub-template. There has been a question on the forum from Todd and I have had a similar conversation with Pat and the gang at Emulex recently.
Emulex have a good use case for conditional template calling. They have developed an RTF Purchase Order template that generates terms and conditions on the back of each page. They are now moving out of just using the PO for their domestic market and need it to work in an international arena. Translations aside, they just need a different set of terms and conditions for the international market version of the PO. They are already importing a T&Cs template - all they need to do is create a domestic and international T&C template within the sub-template. Their XML has a tag in it identifying what type of PO is being generated, so they can have something like:
<?import:file:///d:/temp/tctemplates.rtf?> <?choose:?> <?when: .//TYPE=1?> <?call:TC1?> <?end when?> <?when: .//TYPE=2?> <?call:TC2?> <?end when?> <?otherwise:?> <?call:TC3?> <?end otherwise?> <?end choose?>
This would handle 3 possible T&C templates in their sub-template.
Todd had a good comment, why are the 'call' statements not closed with an 'end call'. I did not have a good answer. Suffice to say, we handle it for you - a good if inconsistent, feature. If you want some example code, get it here.
Comments (13)
Hi Tim,
Found this very useful!
I had an issue that I wasn't able to resolve using the PeopleSoft front end to do with template control fields, but was able to do it using this method.
Cheers,
Andrew
Posted by Andrew | July 7, 2008 6:57 AM
Posted on July 7, 2008 06:57
Hi Andrew. I pleased to hear it - Im not just writing rubbish :0)
Posted by Tim Dexter | July 7, 2008 11:38 AM
Posted on July 7, 2008 11:38
Hello Tim,
Thanks so much for your technique on subtemplates. I proved your concept on a Packing Slip document and it worked quite nicely. However, I'm having some difficulty with the Purchase Order, which is the document that started our quest and has a more immediate need. I'm using the same method as in your email to Pat Moran that worked in the Packing Slip. Here goes:
Embedded file import of subtemplate from main template:
import:file:///H:\Apps\Oracle\XMLPub\PurchaseOrder\DynamicTC's\PO_TC.rtf?>
Selection criteria from even-page header in main template:
choose:?>
when: .//C_ORGANIZATION_ID=DOMESTIC?>
call:PO_DOMESTIC_TC?>
end when?>
when: .//C_ORGANIZATION_ID=GLOBAL?>
call:PO_GLOBAL_TC?>
end when?>
otherwise:?>
call:PO_DOMESTIC_TC?>
end otherwise?>
end choose?>
Tags in subtemplate (PO_TC.rtf):
template:PO_DOMESTIC_TC
1. DOMESTIC. This constitutes the DOMESTIC U.S. Terms and Conditions.
End Template
template:PO_GLOBAL_TC
1. GLOBAL. This constitutes the GLOBAL Terms and Conditions.
End Template
Finally, sample xml with value "DOMESTIC" in the tag:
xml version="1.0"?>
!-- Generated by Oracle Reports version 6.0.8.25.0 -->
EMPOXPRPOP_XML>
LIST_G_INIT_INFO>
G_INIT_INFO>
MANUAL_PO_NUM_TYPE>NUMERIC
C_COMPANY>EMULEX CORPORATION
C_ORGANIZATION_ID>DOMESTIC
The result is that only the "otherwise" condition is executed. It does not seem to evaluate the C_ORGANIZATION_ID tag at all, it simply falls to "otherwise". I suspect something is amiss with my xmlpath but I can't see where. Thanks as always for your efforts.
Regards,
Mike Q - with the Emulex Gang
Posted by Mike Quitugua | July 8, 2008 4:08 PM
Posted on July 8, 2008 16:08
Hi Mike
You need to wrap quotes around your when conditions:
when: .//C_ORGANIZATION_ID='DOMESTIC'?>
otherwise the values are not treated as string values for the comparison
Tim
Posted by Tim Dexter | July 9, 2008 12:38 PM
Posted on July 9, 2008 12:38
Thanks for your suggestion, Tim. Still didn't work but I have a feeling the reason is buried in my xml. I'll continue slogging it around awhile...
Regards,
MikeQ
Posted by Mike Quitugua | July 10, 2008 4:44 PM
Posted on July 10, 2008 16:44
Hello again,
The breakdown was on our side: We had a "choose" clause for an element from a higher grouping level. That element was never properly evaluated. Your dynamic subtemplate technique works great for us.
Regards,
Mike
Posted by Mike Quitugua | July 11, 2008 9:25 AM
Posted on July 11, 2008 09:25
Good news ... glad its working for you!
Posted by Tim | July 11, 2008 9:43 AM
Posted on July 11, 2008 09:43
Do annotations judge up you happy?
Posted by Robqlsla | February 17, 2009 7:42 AM
Posted on February 17, 2009 07:42
Hi Tim,
Is there a way to import a url statement containing a dynamic .rtf file...
OTN thread
http://forums.oracle.com/forums/thread.jspa?threadID=872089&stqc=true
Thanks,
Sudheer.
Posted by Sudheer | March 13, 2009 3:24 PM
Posted on March 13, 2009 15:24
Hi Tim,
Hopefully a simple question, but what is the syntax for when you want to check in your choose statement if the value is null? is double quotes sufficient?
Thanks!
Janel
Posted by Janel | May 12, 2009 2:12 PM
Posted on May 12, 2009 14:12
Hi Tim,
Is it possible to have the choose, condition and corresponding call to the sub-template in a repeating group.
The reason is - I have the AP remittance advice to be printed in two languages and the language is dependent on each supplier. So from the single print we could have more than one language as its from a payment batch which could contains many suppliers.
So all the data fields are fine - But if I have to translate the headings and some text - Do I have to position the if conditions in my single template around the headings and constant texts or can I use sub-templates for this requirement.
Thanks
Shasi
Posted by Shasikkumar | June 2, 2009 8:15 AM
Posted on June 2, 2009 08:15
Hi Tim,
I have converted the Remittance report to Xml. Everything worked fine even bursting also worked fine and also received the mail with pdf attachement.
Now problem is i have created a standard template and in the standard template i have called header template to show logo's based on the organization id.
when i run the report i am able to see the output with logo's but in the mail attachement output logo's are not showing.
How to solve this issue. PLease help.
Thanks
Rajesh
Posted by Rajesh | October 8, 2009 10:12 PM
Posted on October 8, 2009 22:12
Hi Tim,
Is it possible to store the subtemplate name to a database field and call the subtemplate via the field name or a variable in a BI Publisher rtf template ?
Thanks
Michael
Posted by Michael Vourakis | October 14, 2009 12:59 AM
Posted on October 14, 2009 00:59