Detect non-existent nodes in source message

Many times you would end-up in situations where there is an optional node in your source message and you would like to handle this situation. Maybe assign a default value if it doesn't exists.

All you need to do is use the 'Logical Existence' functoid coupled with logical functoids and value maping functoid. It can tell you whether a node/field exists in the source message.

Note that the schema should have Nillable=True and MinOccurs=0.

In this example, I have a message with optional 'Greeting' node. If the incoming message doesn't contain a 'Greeting' node then I put a default value ('Its Stranger').

Explanation
  1. 'Logical Existence' functoid takes only one input i.e. the source node and returns 'True' if the node exists.
  2. The '=' functoid has two parameters, one is the output of logical existence functoid and second constant value 'False'. The output is set to the first Value mapping functoid whose second parameter is "Its Stranger" i.e. the default value.
  3. The second value mapping functoid has two inputs viz. output of Logical Existence functoid and the original node.

Its a kind of If-then-else logic that is applied here. You can achieve the same results using other logical functoids too.



Fig 1 : Map





Fig 2 : Logical Existence functoid





Fig 3: Equal To Functoid to determine Non Existence



Fig 4: Value mapping functoid to assign default value





Fig 5 : Value mapping functoid to assign value from existing node



2 comments:

Nick Heppleston said...

Any chance we can have bigger graphics - and only focus on the functoids, rather than showing the whole screenshot?

Clement said...

Okay, just updated with bigger images