XML Stylesheets (XSLT)
For BPEL and ESB you can use the XSLT solution to remove namespaces. The next example show you how to implement this in BPEL. First of all we need to create a XSLT file. The file shoudl looks like this:
TrX_RemoveNamespace.xsl
<?xml version="1.0" encoding="UTF-8" ?>The BPEL code to call this XSLT is as follows.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="xsl">
<xsl:template match="comment()|processing-instruction()|/">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:choose>
<xsl:when test="name() != 'xmlns'">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
<assign name="Transform_1">
<copy>
<from expression="ora:getContentAsString(
ora:processXSLT('TrX_RemoveNamespace.xsl'
, bpws:getVariableData('inputVariable','payload'))
)"/>
<to variable="outputVariable" part="payload"
query="/client:BPELRemoveNameSpaceProcessResponse/client:result"/>
</copy>
</assign>
The above example will remove the namespaces from the input payload, then it will convert it to a string and put the output into the result element.
XQuery
The solution for OSB can alo apply via XLST, but in OSB the XQuery technology is used.. Removing the namespace in XQuery is done via the following function.
You can call this function in your XQuery file as follows.
declare namespace xf = "http://tempuri.org/vijfhuizen/com/myMessage/";
declare function xf:strip-namespace($e as element())
as element()
{
element { xs:QName(local-name($e)) }
{
for $child in $e/(@*,node())
return
if ($child instance of element())
then xf:strip-namespace($child)
else $child
}
};
<ns0:Data>
{
concat('<?xml version="1.0" encoding="UTF-8"?>', fn-bea:serialize(xf:strip-namespace($varMessage)))
}
</ns0:Data>