You are here: BI Publisher RTF Template : Working with variables

RTF Template : Working with variables Featured

Rate this item
(14 votes)

 Let’s see how we can use the variables to store temporary data or use for calculation.  This is achieved using  “xdoxslt:” function. These are the BI Publisher extension of standard xslt functions.  

Use xdoxslt:set_variable () function to set /initialize the variable  and xdoxslt:get_variable() function to get the variable value.  $_XDOCTX is the System variables to set the XDO Context.



/*initialize a variables*/

<?xdoxslt:set_variable($_XDOCTX, ‘counter’, 0)?>

/*update the variable’s value by adding the current value to MY_CNT, which is XML element */

<?xdoxslt:set_variable($_XDOCTX, ‘counter’, xdoxslt:get_variable($_XDOCTX, ‘counter’) + MY_CNT)?>

/* accessing the variables */

<?xdoxslt:get_variable($_XDOCTX, ‘counter’)?>


/*Working in a loop*/

<?xdoxslt:set_variable($_XDOCTX, ‘counter’, 0)?>


/*increment the counter*/

<?xdoxslt:set_variable($_XDOCTX, ‘counter’, xdoxslt:get_variable($_XDOCTX, ‘counter’) + 1)?>

<?end for-each?>

<?xdoxslt:get_variable($_XDOCTX, ‘counter’)?>


Hope this help in understanding variable gimmicks.

Need help on RTF template design or BI Publisher implementation, please contact This e-mail address is being protected from spambots. You need JavaScript enabled to view it



Read 52436 times


  • Comment Link Priyak Parekh Tuesday, 12 February 2013 02:58 posted by Priyak Parekh


    I am trying to print conditional line based on temporary variable calculation, but I am not sure why it is not getting printed on ourput.
    If required I can email RTF template and XML file.
    Can you please help me on this.

  • Comment Link Ramana Tuesday, 22 January 2013 14:27 posted by Ramana

    hi ,
    can any one help me out for my requirement.
    A 1
    B 5
    C 0
    D 3
    Total 9

    can you pls tell me how to do the total in RTF.

    Thanks in advance!!!



Leave a comment

Make sure you enter the (*) required information where indicated.
Basic HTML code is allowed.