Getting rid of Nilled elements in a message from a database poller in the OSB

Hugo Hendriks's picture

When you create a database poller in the OSB 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

  1. <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: http://www.oradevblog.nl/?p=229 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:

  1. declare function xf:is_nilled
  2. ( $element as element() ) as xs:boolean {
  3.  
  4. if (fn:exists($element/@xsi:nil)) then
  5. fn:exists($element[@xsi:nil=fn:true()])
  6. else
  7. fn:false()
  8. };