Wednesday 4 April 2012

"if-then-else"

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?>

No comments:

Post a Comment