Skip to Content
0
Jun 29, 2016 at 08:05 AM

MapWithDefault for empty elements

1149 Views

Hello all,

I have a question regarding mapWithDefault function:

If I have an empty source field, the mapWithDefault does not seem to work. It only works if the source field is not existing. E.g:

Mapping:

source field a -> mapWithDefault('Test') -> target field a

Test for empty field:

Source:

<a></a>

Result:

<a></a>

Test with removed field:

Source:

Result:

<a>Test</a>

What I would like is to have the mapWithDefault value also for empty fields (so the first example above should also create <a>Test</a> as the output). What is the best way to achieve this? I know it works with an IF condition which checks for the empty value specifically, but maybe there is a better option?