0

I need to code a long Case function, is there such a function in XPath?

My code should look like that:

Case(Country, 
'USA', NY, 
'Mexico', MXC, 
'Canada', Quebec
...)

Should I instead use an IfElse function?

Thanks a lot! Benji

Ben ZERBIB
  • 25
  • 3
  • "Nested conditional if-else statements in XPath" [link](https://stackoverflow.com/questions/12977309/nested-conditional-if-else-statements-in-xpath). – urznow Feb 28 '22 at 11:25

1 Answers1

1

With XPath 2.0, you can do

if (Country='USA') then ...
else if (Country = 'Mexico') then ...
else ...

With XPath 1.0 there's no easy solution. The best option is to create a lookup document that maps old values to new values, and then translate by looking up the value in this document.

With XPath questions, please always say which version you're using, as many people are still using ancient XPath 1.0 processors.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164