cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to change only namespace in message

uma_nimma
Discoverer
0 Kudos


Hi All,

I want to change only namespace(Replace namespace) from outgoing message to receiver. Is it possible...

I checked Module: XMLAnonymizerBean, however it seems it can not replace namespace. It is only changing namespace prefix.. If any body have idea, please share..

XML generated in mapping:

<?xml version="1.0" encoding="UTF-8"?>

<ns1:Structure xmlns:ns1=http://abcxyz.com>

<Element1> content </Element1>

<Structure>

Receiver expecting like:::::::

<?xml version="1.0" encoding="UTF-8"?>

<ns1:Structure xmlns:ns1=http://pqrxyz>

<Element1> content </Element1>

<Structure>

Regards, Uma

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member181985
Active Contributor
0 Kudos

Hi Uma,

Try with Pattern2 of my blog concept:

Best Regards,

Praveen Gujjeti

uma_nimma
Discoverer
0 Kudos

Hi Praveen,

   In my case I am using xslt mapping. I need to changes namespace of xslt output.

Regards,

Uma

former_member181985
Active Contributor
0 Kudos

Hi Uma,

Well, I am not denying xslt option . What I have provided is just one another possibility and in my opinion it is bit easy solution compared to xslt

Best Regards,

Praveen Gujjeti

iaki_vila
Active Contributor
0 Kudos

Hi Urna,

You set two XSL, one after to another. Also if you share your XSL, it's possible to modify it for to get the output with your desired namespace directly.

Regards.

uma_nimma
Discoverer
0 Kudos


Hi Vila,

Result of my Mapping output xml is below

<?xml version="1.0" encoding="UTF-8"?>
<ns1:Structure xmlns:ns1="http://ABCXYZ.com">
<val1>value1</val1>
<val2>value1</val2>
<val3>value1</val3>
<val4>value1</val4>
</ns1:Structure>

But I am expecting like below


<?xml version="1.0" encoding="UTF-8"?>
<ns1:Structure xmlns:ns1="http://PQRABC.com">
<val1>value1</val1>
<val2>value1</val2>
<val3>value1</val3>
<val4>value1</val4>
</ns1:Structure>

So all my field names and values under root node remains same, but only namespace should get change.

What logic I can implement in xslt mapping...

Regards,

Former Member
0 Kudos

Hi Uma

Try the steps mentioned in the below blog

This should solve your problem.

Thanks,

Indrajit

iaki_vila
Active Contributor
0 Kudos

Hi Uma,

If you have this XML:


<?xml version="1.0" encoding="UTF-8"?>

<ns1:Structure xmlns:ns1="http://ABCXYZ.com">

    <val1>value1</val1>

    <val2>value1</val2>

    <val3>value1</val3>

    <val4>value1</val4>

</ns1:Structure>

If you apply the next XSL:


<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns2="http://ABCXYZ.com" xmlns:ns1="http://PQRABC.com" exclude-result-prefixes="ns2">

    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>

    <xsl:template match="/">

        <xsl:copy>

            <xsl:apply-templates select="node()"/>

        </xsl:copy>

    </xsl:template>

    <xsl:template match="ns2:Structure">

        <xsl:element name="ns1:{local-name()}">

            <xsl:apply-templates select="@* | node()"/>

        </xsl:element>

    </xsl:template>

    <xsl:template match="*">

        <xsl:element name="{local-name()}">

            <xsl:apply-templates select="@* | node()"/>

        </xsl:element>

    </xsl:template>

</xsl:stylesheet>

You will get this output:


<?xml version="1.0" encoding="UTF-8"?>

<ns1:Structure xmlns:ns1="http://PQRABC.com">

    <val1>value1</val1>

    <val2>value1</val2>

    <val3>value1</val3>

    <val4>value1</val4>

</ns1:Structure>

Hope this helps.

Regards.

suman_saha
Contributor
0 Kudos
suman_saha
Contributor
0 Kudos

Hi,

The best way is to use XSLT mapping for this and change the namespace in mapping.

Suman