cancel
Showing results for 
Search instead for 
Did you mean: 

Change XML Namespace in XML

Former Member
0 Kudos

Hi gurus,

i have imported an XSD file as an external definition and use this for a mapping. After my mapping i have an xml file like:


  <?xml version="1.0" encoding="UTF-8" ?> 
- <ns1:Aviso xmlns:ns1="http://Post.AG/PartnerInterface/Schemas/PVSdeAt/Aviso_V1.0">
- <ns2:Header xmlns:ns2="http://PostAG.PartnerInterface.Schemas.PVS_deAt.AvisoHeader">
  <ns2:DebitorAuftraggeber>0022022315</ns2:DebitorAuftraggeber> 
  <ns2:Kundenname>WNT Deutschland GmbH</ns2:Kundenname> 
  <ns2:Erstellungsdatum>2009-06-26T16:12:25</ns2:Erstellungsdatum> 
  <ns2:Versanddatum>2009-06-26T16:12:25</ns2:Versanddatum> 
  </ns2:Header>
- <ns3:Absender xmlns:ns3="http://PostAG.PartnerInterface.Schemas.PVS_deAt.AvisoShipper">
  <ns3:Absendername1>WNT Deutschland GmbH</ns3:Absendername1> 
  <ns3:Absendername2 /> 
  <ns3:Absendername3 /> 
  <ns3:Absendername4 /> 

Now the question is how to change the namespace tags ns1 ns2 ns3? The target XML-File should view like this: (ns1 = ns0; ns2 = ns1; ns3 = ns2)


  <?xml version="1.0" encoding="UTF-8" ?> 
- <ns0:Aviso xmlns:ns1="http://Post.AG/PartnerInterface/Schemas/PVSdeAt/Aviso_V1.0">
- <ns1:Header xmlns:ns2="http://PostAG.PartnerInterface.Schemas.PVS_deAt.AvisoHeader">
  <ns1:DebitorAuftraggeber>0022022315</ns2:DebitorAuftraggeber> 
  <ns1:Kundenname>WNT Deutschland GmbH</ns2:Kundenname> 
  <ns1:Erstellungsdatum>2009-06-26T16:12:25</ns2:Erstellungsdatum> 
  <ns1:Versanddatum>2009-06-26T16:12:25</ns2:Versanddatum> 
  </ns1:Header>
- <ns2:Absender xmlns:ns3="http://PostAG.PartnerInterface.Schemas.PVS_deAt.AvisoShipper">
  <ns2:Absendername1>WNT Deutschland GmbH</ns3:Absendername1> 
  <ns2:Absendername2 /> 
  <ns2:Absendername3 /> 
  <ns2:Absendername4 /> 

Thanks a lot,

Max

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

you can use a XSLT mapping as step within you Interface mapping to change the namespace tags. Just make sure the produced message matches the XSD structure (external definition) of the destination message interface.

Check:

http://www.w3schools.com/xsl/

http://www.w3.org/TR/xslt

Regards,

Kai

stefan_grube
Active Contributor
0 Kudos

There is no need to change namespace prefixes. It does not make any difference, which namespace you use.

The prefix links the namespace to the nodes, that's all.

Regards

Stefan

Former Member
0 Kudos

Hi Max,

Please check stefans blog for this issue:

/people/stefan.grube/blog/2007/02/02/remove-namespace-prefix-or-change-xml-encoding-with-the-xmlanonymizerbean

Please try to give as mentioned in his example.

Regards,

---Satish

Former Member
0 Kudos

Hi all,

i found this link https://wiki.sdn.sap.com/wiki/display/XI/NAMESPACE with very helpfull ideas and now the problem is solved.

Thanks to all

Max