Xpath fails when parameter is null

0
Hi, My Xpath expression fails and returns runtime error when the xpath constraint parameter is null. Can you please tell me how can i overcome this behaviour.?. If the parameter value is null, can i pass any wildcard character.?   Thanks Rajesh.
asked
3 answers
2

Is your parameter an object or a variable? How is it used in the xpath?

It is possible to use empty values in an xpath. I do this a lot. That’s why I am wondering how you use it.

answered
0

The Parameter in xpath expression is a variable.

 

Here is the xpath expression:

[ENABLED_FLAG = 'Y']
[$Parameter_Company != empty and contains(SEGMENT1,$Parameter_Company)]

But it failed with below message:

 

InternalXPathTextGetRequest (depth = 0): //Fusion.GL_CODE_COMBINATIONS[ENABLED_FLAG = 'Y'] [NULL != empty and contains(SEGMENT1,NULL)]

Caused by: java.lang.RuntimeException: Unknown predicate function expression type of second parameter: NULL

 

answered
0

Hello

To handle null parameters in your XPath expression, use a conditional check like this

//Entity[Attribute = if ($parameter) then $parameter else '*']

This way, you avoid runtime errors and can provide a default or wildcard value when the parameter is null.

Yo can check https://forum.mendix.com/p/questions/Mulesoft Certification

 

Thank you.

answered