Skip to main content

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

 

mxpath(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 

nxpath(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

 

 

My syntax was wrong…..

 

Corrected to 

mxpath(ConsignmentNode/DefinitionOfGoods/TotalKilos) | div(dxpath(ConsignmentNode/DefinitionOfGoods/TotalFull)| add (dxpath(ConsignmentNode/DefinitionOfGoods/TotalHalf) | add(axpath(ConsignmentNode/DefinitionOfGoods/TotalOversize)])])]) ]

 


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.


Reply