‘IF ELSE’ condition in XML publisher

40 pts.
Tags:
Oracle
XML
How do I use the 'IF ELSE' condition in XML publisher?

Software/Hardware used:
oracle

Answer Wiki

Thanks. We'll let you know when a new response is added.

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. For example:

IF X=0 THEN
Y=2
ELSE
Y=3
END IF

You can also nest these statements as follows:

IF X=0 THEN
Y=2
ELSE
IF X=1 THEN
Y=10
ELSE Y=100
END IF

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 AMOUNT element value. If the value is greater than 1000, show the word “Higher”; if it is less than 1000, show the word “Lower”; if it is equal to 1000, show “Equal”:

<?xdofx:if AMOUNT > 1000 then 'Higher'
else
if AMOUNT < 1000 then 'Lower'
else
'Equal'
end if?>

Discuss This Question: 8  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Oracleapps03
    Thanks! Can you provide any meaningful documents for improving knowledge in XML publisher?
    40 pointsBadges:
    report
  • Softy
    Hi, How to avoid this printing in template if condition is false. The below things should be ignored during printing when the trx_number is null. If any trx_number is there, then these should be printed in the template. How to achieve this? Please help me. "REGISTERED ADDRESS: CP_REGD_ADDR Zip Code: CP_REGD_ZIP_CODE Tel. : CP_REGD_TEL_NUM Fax.: CP_REGD_FAX_NUM"
    10 pointsBadges:
    report
  • Michael Tidmarsh
    64,290 pointsBadges:
    report
  • DBBAIC
    This post got me closer than I was.  Using the syntax you provided, I was able to display text for 'DEBIT' or 'CREDIT'.  But the problem is, I don't want to display text 'DEBIT' or 'CREDIT', I want to display the actual amount.  But, when I change syntax to include the field name Monetary_Amount (with no quotes) the field doesn't display anything.

    Here's my syntax:
    <?xdofx:if Monetary_Amount > 0 then Monetary_Amount
    else
    if Monetary_Amount < 0 then Monetary_Amount
    else
    'GARBAGE'
    end if?>
    30 pointsBadges:
    report
  • ToddN2000
    @DBBAIC: Not sure what you are looking to accomplish other than show the value unless it's zero the use the 'GARBAGE" Is this a class assignment by chance?
    107,430 pointsBadges:
    report
  • DBBAIC
    I am trying to show the value in either a Debit or Credit column, since the Monetary_Amount field includes both debits and credits.  I included GARBAGE in the else statement, just so if the syntax didn't give either a DEBIT or CREDIT then I would see GARBAGE, which I did not (and didn't expect to see).

    In short, what I'm trying to do is show amounts greater than 0 in the Debit column and amounts less than 0 in the Credit column.

    Thanks for your help.
    30 pointsBadges:
    report
  • ToddN2000
    How are you going to determine which column the value goes into?
    107,430 pointsBadges:
    report
  • DBBAIC
    The report format includes 2 columns, one for Debits and one for Credits. I will use a different formula for each column. In the Debit column I want to display amounts that are greater than zero and in the Credit column I want to display amounts that are less than zero.
    30 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: