div() or divide() with Xpath denominators

  • 9 April 2024
  • 2 replies

Userlevel 5
Badge +1

Is is possible to pass values retrieved using xpath() into the div([value]) or divide([value]) Math formatters?


I want to do something like this in an XML Map connector


[xpath(ConsignmentNode/DefinitionOfGoods/TotalKilos)  | div(xpath(ConsignmentNode/DefinitionOfGoods/TotalFull)| add(xpath(ConsignmentNode/DefinitionOfGoods/TotalHalf)) | add(xpath(ConsignmentNode/DefinitionOfGoods/TotalOversize))))]!--endfragment>!--startfragment>



which in pseudo code is

    Weight = Total Kilos / (Full + Half + Oversize)


Things like “….| div(2)” work, but I can’t seem to get it to work with values from other parts of the message.


Even simplifying to 

[xpath(ConsignmentNode/DefinitionOfGoods/TotalKilos) | divide(xpath(ConsignmentNode/DefinitionOfGoods/TotalHalf))]

gets the same error:

Formatter divide failed in the evaluation of <weight>[xpath(ConsignmentNode/DefinitionOfGoods/TotalKilos) | divide(xpath(ConsignmentNode/DefinitionOfGoods/TotalHalf))]</weight>. The error was: Error parsing BigDecimal value [xpath(ConsignmentNode/DefinitionOfGoods/TotalHalf)]. Value: 2000




Best answer by russell-jerseypost 9 April 2024, 13:15

View original

2 replies

Userlevel 5
Badge +1

My syntax was wrong…..


Corrected to 

[xpath(ConsignmentNode/DefinitionOfGoods/TotalKilos) | div([xpath(ConsignmentNode/DefinitionOfGoods/TotalFull)| add ([xpath(ConsignmentNode/DefinitionOfGoods/TotalHalf) | add([xpath(ConsignmentNode/DefinitionOfGoods/TotalOversize)])])]) ]


Userlevel 2

Hi Russel,


Glad to hear you were able to resolve it yourself! If you have any more questions or need further assistance in the future, feel free to reach out.