Wednesday, December 28, 2011

Removing empty optional elements erroneously inserted by mapping

if a XQuery mapping, theoretically you should check for existence of an optional element in the source, and only if it exists you create it on the destination:

if ($myvar/customer/shoesize) then
<shoesize>
data($myvar/customer/shoesize)
</shoesize>


If the developer likes to take shortcuts (=is a lazy bum), and doesn't do the "if", you must clean the garbage afterwards.

You can use the action:
delete //*[not(node()) and not(.//@*)] from body

No comments: