this gave me a bit of a headache I had a task where i needed to chop of the last character of one of the XML tags so I could use it in some of the logic statements further down in the code . this did the trick OptioPrinterName_ID180 is the name of the XML tag i wanted to chop the end off and store and 1 at the end is the number of characters to chop
<?xdoxslt:set_variable($_XDOCTX,
‘optioChar’,xdoxslt:right(OptioPrinterName_ID180,1))?>
Then further down in the code when i needed to reference the variable for my logic i Referenced it as follows
<?choose:?>
<?when:xdoxslt:get_variable($_XDOCTX, ‘optioChar’)=‘A‘?>Test<?end when?>
<?otherwise:?>Test2<?end otherwise?>
<?end choose?>
Survivors of a long and bitter JDE Transform installation (you cant imagine the horror man !! ) Mike , Jamie, Roger and Charlie are Four Developers working with the infinitely superior BI publisher to handle all our ERP produced documents. this blog is a place for us to post all of the fiddly bits foibles and general head scratching we have discovered along the way to help out our fellow code monkeys out there
Showing posts with label Variables. Show all posts
Showing posts with label Variables. Show all posts
Wednesday, 19 March 2014
Wednesday, 12 March 2014
Storing Values in Variables in your BI Publisher Template
Mike came up against an interesting issue the other day . he needed to access a value in the XML output from JDE on a different page . the trouble was the value was blank on the second page. after a bit of digging I came across this code which lets you store values in the XSL on your RTF template as variables
/*initialize a variable*/
<?xdoxslt:set_variable($_XDOCTX, ‘counter’, 0)?> or
<?xdoxslt:set_variable($_XDOCTX,‘test‘,“wibble")?>
/*get a variable*/
<?xdoxslt:get_variable($_XDOCTX,
‘test’)?>
/*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’)?>
Location:
Stubbins, Bury, Lancashire BL0, UK
Subscribe to:
Posts (Atom)