cancel
Showing results for 
Search instead for 
Did you mean: 

Removal of Namespace from the XML file

santosh_k3
Active Participant
0 Kudos

Hi All,

I have a scenario where i need to remove the name-space from XML file.

I have an existing scenario where the output of xml file is as shown below.

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

<ns0:abc xmlns:ns0="xyz">

-   <Data>
<123>000000000000500193</123>
<345>2012</345>
<567>0.000</567>
</Data>

</ns0:abc>

but my output file is as

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

- <ns1:abc xmlns:ns1="xyz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Data>

<123>000000000000</123>

<345>2011</345>

<567>0</567>

</Data>

</ns1:abc>

   So how to remove namespace http://www.w3.org/2001/XMLSchema-instance from XML file.

i have configured the CC the same way as the existing CC but this name space is appearing in XML file

why is it so?

   i have seen that the existing scenarios receiver CC there is no XML Anonymizer Bean configured in Module tab.
   what are the changes that i need to do to remove the namespace from the XML file.
   is there any other way that i can remove namespace without configuring XML Anonymizer Bean in Module tab?
  and one thing why the first XML file the prefix is "ns0" and the second is "ns1" why they are not same in both the files?
  please anybody clarify the above points and provide me a solution.

Thanks
       Sai

Accepted Solutions (1)

Accepted Solutions (1)

former_member184681
Active Contributor
0 Kudos

Hi Sai,

Most probably your target structure definition has been downloaded as an external definition, having this namespace http://www.w3.org/2001/XMLSchema-instance already included, am I right?

Anyway, you do not have to worry about that, simply use the XML Anonymizer Bean to remove that namespace from the XML file. Use module name: AF_Modules/XMLAnonymizerBean and one additional parameter anonymizer.acceptNamespaces with value xyz ns0, as the anonymizer bean removes namespaces that are NOT included here. See more details here if required:
http://help.sap.com/saphelp_nw04/helpdata/en/45/d169186a29570ae10000000a114a6b/content.htm

Also a nice example with screenshots here:
http://www.saptechnical.com/Tutorials/XI/XMLPayload/Index.htm

Hope this helps,
Greg

Answers (4)

Answers (4)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>  So how to remove namespace http://www.w3.org/2001/XMLSchema-instance from XML file.

If you want to remove  namespace or namespace prefixes you can use XMLAnonymizerBean module. If you want to add namespace then one of the possible way is to use XSLT mapping or Java mapping.

In the above example ns1 or xsi is the namespace prefix.

Please refer sap help document for XMLAnonymizerBean

Message was edited by: Baskar Gopalakrishnan

Former Member
0 Kudos

pls check the msg types of the 2 scenarios and see XML namespaces mentioned there.

deepak_shah
Contributor
0 Kudos

Hi,

You can remove the XML namespaces from the message types so that this wont appear in the xml output.

-Deepak

deepak_shah
Contributor
0 Kudos

Hi check this XML namespace of the Message type which you are using. If you dont need the namespace, you can remove it.

-Deepak

iaki_vila
Active Contributor
0 Kudos

Have you try to concatenate a XSL mapping?

Remove all namespaces

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" version="1.0" encoding="UTF-8" />

         <xsl:template match="*">

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

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

                 </xsl:element>

         </xsl:template>

</xsl:stylesheet>

Remove all except the namespace xyz

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" version="1.0" encoding="UTF-8" />

         <xsl:template match="*">

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

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

                 </xsl:element>

         </xsl:template>

</xsl:stylesheet>

Regards.