Tuesday, December 11, 2007

BI Publisher IF statement Logical OR syntax in RTF Template

A question came through today: what is the syntax for a logical OR in a BI/XML Publisher IF statement?

The standard BI Publisher "IF" statement doesn't seem to cut it.

Lets say I want a test:

if (a=1 or a=2) and b=3 then output_my_stuff end if

I don't want to have to repeat output/logic like:
if a=1 then
 if b=3 then
 end if
end if
if a=2 then
 if b=3 then
  output_my_stuff (again)
 end if
end if
A solution is to use form fields with an xsl if statement structure. So we have:
<xsl:if test="(A='1' or A='2') and B='3'">
If it works use it!


Democracy Lover said...

I've been creating letters using BIP and the if:a=b? is very useful. I find, however, that when I use if@inlines:a=b?, the section will print even when a != b. Does the xsl if have a similar logic that actually works?

Gareth said...


The inlines option is used to push fields onto one line, for example in a for-each group. With IF statements you need to be careful about placement, especially watch your spaces.

For a paragraph/section that you want to print or not print the structure should be:

Print this.

Note that the ifxxx and endifxxx are on their own lines, with no spaces. Then those lines won't render on your output, and you won't face problems with extraenous spaces.

If you have something like this:
"Do not print ifxxx this endifxxx."
it is not the same as:
"Do not printifxxx this endifxxx."
as there is a space after the word "print" and before the word "this", so you'll get a double space for the first option. The second is better.


rgkn said...

Hi there,

Have you tried:


N.B. or and and are case sensitive. The following does not work.




Tani said...

The method used here is very simple and easy to understand. The way of explaining is also good. As IF statement logical OR syntax looks easy but is not as simple to understand for everyone.

oracle ebs

Sridevi Koduru said...

Sridevi Koduru (Senior Oracle Apps Trainer Oracleappstechnical.com)
LinkedIn profile - https://in.linkedin.com/in/sridevi-koduru-9b876a8b

krishna anagam said...

Hi Sir,
I want some conditions for rtf templates to print different outputs in pdf in single rtf template ex taking the information of PO as approved in one page and another incomplete status in another page