• Welcome to the upgraded JDELIST forum and thank you for your patience.
    Please restrict discussions and issues regarding the new forum software to the Off Topic forum. We will be monitoring that forum for issues.
    If you have trouble logging in, please reset your password using the forgotten password form: https://www.jdelist.com/community/index.php?lost-password/
    If you are unable to successfully reset your password, please contact us: Click here!
    We hope that you enjoy the upgraded forum.
  • Introducing Dark Mode! Switch by clicking on the lightbulb icon next to Search or by clicking on Default style at the bottom left of the page!

multiple copies and watermarks


Hi There,
I've got multiple copies of a SO Invoice thanks to eewon(Dave) and watermark thans to Tim Dexters nice little solution.
But I cant get the watermark value to change for each copy.
I need 3 copies of an invoice each with its own watermark.

In the Word Header I have the following:

This does the looping.

I've added a word watermark; in the text I put <?$wMark?>.

In the body I adde a field and then added the following to this field.
<xsl:variable name="wMark" select="xdoxslt:ifelse(position()='1’,'Canceled','Approved')"/>

position() gives me the counter of the loop. Displaying this I can see it goes 1,2,3,1,2,3,1,2,3.

But the watermark is Canceled on all pages. I should seeCancelled,Approved,Approved, Cancelled,Approved,Approved etc.
When I change the value from 1 to 2, I get Approved on all pages.

Can anybody help? I think I need to make the wMark variable local to eacy copy interation. But not sure and not sure how to do it either.

Any ideas Welcome!
I believe the issue here is the use of an xsl variable. Quoting from XSLT tutorials, 'once the value of an xsl variable is set it cannot be changed'. Making the variable 'local' to a template and then calling the 'template' to do your work might resolve the issue. However, I don't think that is a possibility here.

Try the following :

In the text of the word watermark , <?xdoxslt:get_variable($_XDOCTX,'wMark')?>

In the body, add a field and in the field add

I think this should work.
Sorry, my bad. I posted an incorrect solution using the xdoxslt get & set variable - assuming this would get around the xsl variable problem. However, it does not. In fact you will end up with no watermark at all.

Should have tested first ! so ...
I tried several other methods, all with no success. It seems to me that the watermark 'code' is executed only once at the beginning of the BI process and is 'static'. I tried a number of things becasue we need similar functionality - however, I was never able to find any way to make the watermark change from page to page.

my apologies for the misdirection.


Hey there,
Thanks for trying to help!
So what happened last night;
Windows Update happened on my work laptop and BI didnt work anymore. Downloaded; had a few issues; deleted some EXD files; and am now working again.
Except the code that worked yesterday dont work no more!
the code in question was <xsl:variable name="wMark" select="xdoxslt:ifelse(position()='1’,'Canceled','Approved')"/>
inside my form field. it was the ifealse bit that didnt work.
So I tried the sub-template (following your suggestion) as follows:
<?call@inlines:WTM?><?with-param:pCurrentCopy;position()?><?end call?>

<?xdoxslt:set_variable($_XDOCTX, 'wMark', ‘TEST’)?>
<?end when?>
<?xdoxslt:set_variable($_XDOCTX, 'wMark', ‘POD’)?>
<?end otherwise?>
<?end choose?>

<?end template?>

And changed the text in the Watermark to <?xdoxslt:get_variable($_XDOCTX, 'wMark')?>

Result is I get a watermark but it is always 'POD'; the initial When test always fails. I've tested this against 0-3 and it always fails.

Any ideas?? Thanks J


Hey Roland,
I have the solution

Same as in my last post except the sub-template is now
<?xdoxslt:set_variable($_XDOCTX, ‘wMark’, ‘CUSTOMER COPY’)?>
<?end when?>
<?xdoxslt:set_variable($_XDOCTX, 'wMark', ‘POD’)?>
<?end when?>
<?xdoxslt:set_variable($_XDOCTX, 'wMark', ‘’)?>
<?end otherwise?>
<?end choose?>
<?end template?>

So on loop 1, I'm setting the watermark for 2nd copy (CUSTOMER COPY).
On loop 2, I'm setting the watermark for 3rd copy (POD)
On loop 3, watermark is set for 1st copy of next invoice (BLANK).

Hope that works for you too.
Hey JazNX ;

ok ... so after putting my foot in my mouth yesterday, I've managed to pull it out today with no real damage except a bruise to my ego. Oh well, I'll get over it. Anyway, I found a couple of solutions that really are quite simple. The first does not involve any variables. Just put the following in the text watermark :


If you want to use a variable, then try putting the following immediately after the for-each:mad:section:xdoxslt:foreach_number ....


... and put the following in the text watermark :


I tested both with all of my 'code' in the document body (nothing in the word header) and it works great. You may get a different result if your looping 'code' is in the word header. Not sure ...

Anyway, with the 'code' in the document body, both of the methods will work and produce 3 copies for each occurance of the group section. The watermark on the first copy will be 'Canceled' and the other 2 copies 'Approved'.

There ... I feel a bit better now.

Cheers !
Just to let you know, I tested the same with the 'code' in the header and it works too. Here is the 'code' I have in the header :


and then, the text in the watermark can be :


and it works great. The only thing is, if you don't have a working 'ifelse' then you will have to find another way of setting the wMark variable.



Hi Roland
I added the code to the watermark (using ifelse which appears to be ok now); nice I like it.
It works better as well as it works on the current page; not setting it for the next page as mine did.
I can also anchor the totals to the bottom of the page which I couldnt do before without screwing it up.
So nice! Thanks


ashwin E1

Hi The solution above is working perfectly, but just instead of constant "Cancelled" or "Approved", I'm trying to use a Variable as shown below:

<?for-each@section:xdoxslt:foreach_number($_XDOCTX,1,3, 1)?>
<?end for-each?>
<?variable@incontext:wMark;xdoxslt:ifelse(position()=2,’DocumentOrder_ID37’, xdoxslt:ifelse(position()=3,’DocumentOrder_ID37’,’BPREX_ORDER_NO_ID335’))?>

but this makes the variable wMark as blank.
I dont understand why this code wont accept variable instead of costant, the same code I replace variables with any constant and it works fine.
Please help if anyone has seen such issue.