Modifying namespaces in the Oracle Service Bus

07 May

The scenario here is that we have an Async JMS service and the original publisher is a legacy application. This pubishes it’s message in an XML-format. Which is cool, however there are no XSD’s available and the message contains no namespaces.


With the help of a professional tool (Liquid XML Studio) we are able to generate an XSD from large numbers of the XMLs we received from the legacy application. Next step is creating a decent service contract (WSDL/XSD). When finished the primary subscriber of our async. service receives the WSDL/XSD datamodel from us which it imports.

However our subscriber requires a exposed namespace in the message it receives. (we tried using configuring hidden/local namespace qualification in the XSD but these fail during import). So the message would need to look something more like this:

<e08:EDI xmlns:e08="">

We want to use Oracle Service Bus as passive intermediate as much as possible. So we use a simple Rename Action of the Oracle Service Bus.

This does the trick because all elements ( //* ) in variable body are now renamed to the new namespace we require.

update May 9th: not adding namespace, but removing them

If you need to do it the other way around, like removing the namespaces from an XML message. I haven’t been able to find a way to this with the Rename Action of the Oracle Service Bus. However there is a simple XSLT stylesheet you can use. (this code is not mine but found it on the web once upon a lifetime in a galaxy far far far away. I’ve been using it for some time, but sadly don’t know who to give credits)

<xsl:stylesheet version="1.0" xmlns:xsl=""&gt;
<xsl:output method="xml" indent="no"/>

<xsl:template match="/|comment()|processing-instruction()">

<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*|node()"/>

<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>

Use a replace action on the message $body and your namespaces will disappear like ninjas in the night. ;)


Posted by on 07-05-2012 in Oracle, OSB


Tags: ,

6 responses to “Modifying namespaces in the Oracle Service Bus

  1. Maverik

    04-12-2012 at 23:09

    Nice Post, it really saved my time

  2. KK

    14-02-2013 at 19:14

    Lifesaver…Thank you!!!

    • ad

      23-05-2013 at 21:38

      Cant’ agree less!!

  3. Dipayan

    02-04-2014 at 13:01

    can you let me know how to Remove newline character/white space from xml using xslt or xquery transformation,Means all the elements will come in a single line.

  4. alhenk

    16-10-2014 at 09:56

    ./descendant-or-self::* instead of .//*
    would be better


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 403 other followers

%d bloggers like this: