Recently, we came across a requirement , where we need to remove name space of XML before we send to MQ. this case IBM I Series application is receiving data from processing .
This is very common requirements specially when we are integrating with legacy system. In order to achieve functionality, I use below X-Query function.
Name -RemoveNamespace
xquery version "1.0" encoding "Cp1252";
(:: pragma parameter="$anyType1" type="xs:anyType" ::)
(:: pragma type="xs:anyType" ::)
declare namespace xf = "http://www.officedepot.org/Order/Remove_Namespace/";
declare function xf:removeNamespace($e as element())as element()
{element { xs:QName(local-name($e)) }
{ for $child in $e/(@*,node())
return
if ($child instance of element())
then xf:removeNamespace($child)
else $child
}
};
declare variable $e as element() external;
xf:removeNamespace($e)
Now, we need to use replace action in proxy message flow to execute this XQuery,
In side Proxy Flow, add replace action
Select "Replace node contents" radio button
XQuery Bind Variables should be $body . Please note , it is not $body/* .
This will remove namespace elements from XML . Happy codding. :)