Tuesday, 24 December 2013

If-then-Else Statement in XML Publisher

XML Publisher supports the common programming construct "if-then-else". This is extremely useful when you need to test a condition and conditionally show a result.
Use the following syntax to construct an if-then-else statement in your RTF template:
<?xdofx:if element_condition then result1 else result2 end if?>
For example, the following statement tests the INVOICE_AMOUNT element value. If the value is greater than 5000, show the word "Higher"; if it is less than 3000, show the word "Lower"; else, show "Equal":
<?xdofx:if INVOICE_AMOUNT > 5000 then ’Higher’
else
if INVOICE_AMOUNT <3000 then ’Lower’
else
’Equal’
end if?>
Here we are using same RTF and RDF which we had used in IF statement
RTF looks like
Just give double click on Inv_Amt then we will get one pop window which is shown below
Provide proper text and Click on Add Help Text we will get another pop window which is shown below
There we have to write below code
 Which is shown below

Now we have to publish the report

Click on Template Builder => Preview => HTML/PDF/Excel/RTF (any format).
We can get below output
From the above output we can see that Inv Amt which got the result. In this way we can use IF THEN ELSE   statement

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hi Ragavan,
    Thanks for the excellent solution.
    Noor

    ReplyDelete