Getting rid of Nilled elements in a message from a database adapter

When you create a database poller in the SOA Suite you will encounter that empty values in the database will appear in your request as xsi:nil=”true”.

When calling another service with values like:

<sch:voorvoegsel xsi:nil="true"/>

you will run into validation problems so you want to remove those elements.

You can use XQuery to filter them out but when I tried to use the fn:nilled function, it didn’t do what I expected it to do. When I looked around I found this blog:  which explains why it doesn’t work. Solution……you can define a is_nilled function of your own which does the trick. It looks like this:

declare function xf:is_nilled( $element as element() ) as xs:boolean {
    if (fn:exists($element/@xsi:nil)) then
       fn:exists($element[@xsi:nil=fn:true()])
    else
       fn:false()
};

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.