cancel
Showing results for 
Search instead for 
Did you mean: 

How to change the incoming xml to a different namespace

Former Member
0 Kudos
387

I have a xml file coming into XI (file ->XI)without namespace. I would like to change the root elment with ns tag add the namespace values with it.

ie.,

Coming in as

<Vendor>

.......

</Vendor>

I would like to change it to

<ns:Vendor xmlns:ns="urn:group01:legacy">

......

</ns:Vendor>

thanks

Accepted Solutions (0)

Answers (2)

Answers (2)

stefan_grube
Active Contributor
0 Kudos

I recommend using XSLT for this purpose.

Use the copy-of select function for the inside tags.

If you need further help, let me know, I could provide an example for you.

Regards

Stefan

MichalKrawczyk
Active Contributor
0 Kudos

Hi Dhandu,

if you create a message type:

<Vendor>

.......

</Vendor>

without the namespace

and one message type:

<ns:Vendor xmlns:ns="urn:group01:legacy">

......

</ns:Vendor>

with the namespace

and then a mapping from the one without to the one with the namespace

you'll have the namespace in your target message type - then you can do

whatever you want with it

is this what you're looking for?

Regards,

michal

Former Member
0 Kudos

Michal

I am using external definition, I am not using the datatypes or message types.

Is there a work around in this case?

thanks

Dhandu

MichalKrawczyk
Active Contributor
0 Kudos

but does you external definition requires this namespace?

you can always do 2 mappings one from something to message type with the namespace and the second one from this one to the second external definition ...

external - mapping - message type with namespace - mapping - external

but I don't know your scenario..

Regards,

michal

Former Member
0 Kudos

Michal

I did create all interface objects and mapping objects by adding "urn:" on the software component namespace table.

In that I did import external definition with no name space schema and did create message interface out of it.

Then in urn:group01:legacy namespace i did create message mapping between no namespace to with namespace and test it works great.

In the message interface it did allow me add the new source with no namespace and the target with interface with namespace. The source and target interface I add to on top of the exisiting vendor:group01:legacy to target CREMAS:CREMAS03. But I couldn't select to add the second mapping. The message mapping allows only one.

This is what I have

Interface Mapping

Source Interface -


TargetInterface

Vendorwithnospace -


Vendor_out

Vendor_out -


CREMAS:CREMAS03

Request

Source Message --- Mapping Program -


Target Message

Vendor -


<does not allow to add>--- Vendor

Vendor -


Vendor_CREMAS03 -


CREMAS:CREMAS03

I thought I can do the first mapping to add the namespace and have the output to feed it as input for the second mapping.

I know I can always use the configuration directory to output and make it as two jobs, but all I need is to add the namespace to the file root element.

Former Member
0 Kudos

Hi Dhandu,

Other way of doing this is using a Java Mapping, which writes in a particular line in your incoming msg & then you can go for your normal 'mapping' to target.

Incase you want to remove anything from msgs, then also, you can use Java mapping.

But you have to arrange the mapping sequence in the order In which you want them to execute.

so you can try these steps,

1) Java mapping which adds a tag

2) XSLT/Msg mapping (which can take in the msg after formatting)

Remember that when you play with namespace, the "mapping program" always refer the elements w.r.t the namespace, so there is "probably" a certain amount of risk for the elements not getting mapped properly.

Incase you go for XSLT

if required (when u dont get results in your mapping IDE - any external tool like stylus, xml spy )you may have to add the namespace in front of every element like /ns:xyz/ns:abc.

Best of luck

Hope this helps

Regards

Vishnu

Former Member
0 Kudos

Vishnu,Stefan & Sudhir

I did the change in namespace of a incoming xml (vendor without namespace)using the mapping of a external xsd with and without namespace (to a namespace of urn:group01.legacy) This works fine. (as Michal suggested). So, I have two mappings now, one for appending the namespace to the root element and another one to do the file to idoc mapping.

The issue is, how to I make this output from the first mapping of vendor as source target to CREMAS:CREMAS03 idoc using the same interface mapping. It is allowing only one map doesn't matter whether it is XSLT or Java or Message mapping.

Thanks

Former Member
0 Kudos

Hi Dhandu,

1) You can ADD mapping programs in required sequence in Interface Mapping object.

2) Since I normally, go by the Java XSLT way, I add my java class first in the sequence, which adds the tag & then the XSLT mapping.

3) The output of each seqeunce of mapping is automatically passed to the next in the sequence

Not sure if I completely answered your question, but it works like this for me.

Also, if you plan to use Java class (as above), make sure you read the namespace from a properties file. so you need not change/compile the Java code.

Hope this helps

Regards

Vishnu

Former Member
0 Kudos

Hi Vishu

I will try your java mapping, where I can download the package com.sap.aii.*. Is there a jar or zip file containing all sap java packages?

thanks

Dhandu

Former Member
0 Kudos

Hi Dhandu,

They are standard packages available in the XI server, so you need not download anything, you can simply add the "zip" & try.

Regards

Vishnu