0

I think the code below should work in a Word BI Publisher template, but it's not. When I use the BI Publisher Template Viewer app to test, it is showing Duplicate variable 'branch' definition. If only the matching <?when: ...?> block should be executed, how is the variable defined more than once?

I have experience in other programming languages, but XML/XSL/BIP, etc. is new to me. Can anyone shed some light on the below code?

Thanks!

<?variable:payco; xdoxslt:trim(Remit_to_Name_ID445)?>

<?choose:?>
<?when: $payco=”Company1”?>
<?variable@begin:branch;'CO1'?>
<?end when?>
<?when: $payco=’Company2’?>
<?variable@begin:branch;'CO2'?>
<?end when?>
<?when: $payco=’Company3’?>
<?variable@begin:branch;'CO3'?>
<?end when?>
<?end choose?>
eljefejb
  • 297
  • 3
  • 12
  • What is the ultimate goal? – EdHayes3 Jun 24 '21 at 15:41
  • I am trying to set the variable $branch so that in the template header, I can concatenate the value with the string "-logo.jpg" as the URL to the proper image logo. I was expecting that only 0 or 1 of the 'when' blocks would be executed, based on the value of the 'payco' variable, but it seems like more than one is being read, resulting in the duplicate definition error. – eljefejb Jun 25 '21 at 17:28

1 Answers1

1

I can think of a few options to solve your logo problem.

  1. Update the data definition SQL to do a decode/concatenation or something to get your logo filename or variable in the SQL as its own field that's extracted into the XML. That way you can use this when determining the image path:

    url:{concat('/logos/',branch,'-logo.jpg')}

  2. Use if statements or choose/when in your RTF to select an entire image section. This would mean you need to update the RTF every time you add a branch/brand, but it's doable.

EdHayes3
  • 1,777
  • 2
  • 16
  • 31