Home > Net >  XPath Case/IfElse function
XPath Case/IfElse function

Time:03-01

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

CodePudding user response:

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.

  • Related