Hi Ashwin,
This issue beacause variables are not able to get the scope/context because of 2 for-each@section in the code. We need to use xpath for this.
XPATH: -
https://www.w3schools.com/xml/xpath_syntax.asp
Please try the below methods.
1. Remove the single quotes(') from variables and prefix your variables with "//".
e.g. <?variable@incontext:wMark;xdoxslt:ifelse(positi on ()=2,//DocumentOrder_ID37, xdoxslt:ifelse(position()=3,//DocumentOrder_ID37,//BPREX_ORDER_NO_ID330))? >
But there is issue with this method, suppose we have multiple sections(in this case we have "On_Payment_Terms_S3") variables will always refer to context of first parent section and always print the same values.
2. To overcome the above issue,we need to create a variable to get the current context which will tell our variables to refer which parent node.
<?for-each@section:xdoxslt:foreach_number($_XDOCTX,1,3, 1)?>
<?end for-each?>
<?for-each@section:/Absolute Path/On_Payment_Terms_S3?>
<?variable@incontext:c;.?>
<?variable@incontext:wMark;xdoxslt:ifelse(positi on ()=2,$c/DocumentOrder_ID37, xdoxslt:ifelse(position()=3,$c/DocumentOrder_ID37,$c/BPREX_ORDER_NO_ID330))? >
<?template?>
<?end for-each?>
Then in Heading
<?$wMark?>
Hope above solution works for you.
Thanks
Gurpreet