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.
Variables in loops:
/*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)? >
< ?for-each:G1? >
/*increment the counter*/
< ?xdoxslt:set_variable($_XDOCTX, ‘counter’, xdoxslt:get_variable($_XDOCTX, ‘counter’) + 1)? >
< ?end for-each? >
< ?xdoxslt:get_variable($_XDOCTX, ‘counter’)? >
Storing tag values into variable and making calculation with other tags:
I have a variable 'd' with value '8' and I wanted to use that variable and other tags COL1, COL2 in calculating variable 'f' as shown below, Then calculated COL3 with variable 'f' to display results.
< ?xdoxslt:set_variable($_XDOCTX, ‘d’,8) ? >
< ?xdoxslt:set_variable($_XDOCTX, ‘f’, xdoxslt:get_variable($_XDOCTX, ‘d’) + COL1 - COL2 )? >
< ? COL3 div (xdoxslt:get_variable($_XDOCTX, ‘f’)) ? >
NOTE:
1. Make sure you have spaces between tag names and mathematical operators (ex: COL1 + COL2 - COL3).
2. You can use get_variable() to display results.
3. Always use xdoxslt: prefixed when using get_variable()(ex:( xdoxslt:get_variable($_XDOCTX, ‘f’) )
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.
Variables in loops:
/*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)? >
< ?for-each:G1? >
/*increment the counter*/
< ?xdoxslt:set_variable($_XDOCTX, ‘counter’, xdoxslt:get_variable($_XDOCTX, ‘counter’) + 1)? >
< ?end for-each? >
< ?xdoxslt:get_variable($_XDOCTX, ‘counter’)? >
Storing tag values into variable and making calculation with other tags:
I have a variable 'd' with value '8' and I wanted to use that variable and other tags COL1, COL2 in calculating variable 'f' as shown below, Then calculated COL3 with variable 'f' to display results.
< ?xdoxslt:set_variable($_XDOCTX, ‘d’,8) ? >
< ?xdoxslt:set_variable($_XDOCTX, ‘f’, xdoxslt:get_variable($_XDOCTX, ‘d’) + COL1 - COL2 )? >
< ? COL3 div (xdoxslt:get_variable($_XDOCTX, ‘f’)) ? >
NOTE:
1. Make sure you have spaces between tag names and mathematical operators (ex: COL1 + COL2 - COL3).
2. You can use get_variable() to display results.
3. Always use xdoxslt: prefixed when using get_variable()(ex:( xdoxslt:get_variable($_XDOCTX, ‘f’) )
No comments:
Post a Comment