No viable alternative at input error

0
I have the following XPath constarint:   [$NumberOfAdults > 0 and AdultsCapacity >= $NumberOfAdults and (AdultsCapacity + ChildrenCapacity >= $NumberOfAdults + $NumberOfChildren)]   But I’m having the error no viable alternative at input ‘AdultsCapacity’ at the second ‘AdultsCapacity’.   My entity is Room and both AdultsCapacity and ChildrenCapacity are attributes of my entity.
asked
3 answers
0

Hi Ndilokelwa,

XPath can only deal with certain amount of operators but not with ‘+’.

So you will need to create variables (ie. totalGroup & totalCapacity) before the retrieve and doing your necessary calculation beforehand.. Then in the xpath you can use $totalGroup and $totalCapacity.

answered
0

Hi Sjors,

 

However, that solution won’t work because I want to put a constraint on the database and not create a variable.

I tried making a third database attribute, RoomCapacity = AdultsCapacity + ChildrenCapacity, made with a microflow. Still, it did not appear as an option on the XPath of the retrieve on the microflow I am trying to achieve.

 

answered
-1

Hi Ndilokelwa,

as Sjors wrote, you can’t use arithmetic operators within XPath query constraints. It’s allowed to use logical operators only, arithmetic ones are supported in Java code only, please check out the documentation.

 

answered