cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically Modifying Target XML Namespace

former_member273752
Participant
0 Kudos

Dear All,

We have a requirement of dynamically modifying the namespace of the target XML . The scenario is as follows:

There are multiple recipients of a message, and two of the recipients are using the same target structure, but with a different XML namespace. We are catering to the different receivers using different interfaces, but because these two recipients are using the same Target message type, hence they can only point to any one namespace (the XML namespace mentioned in this target message type). For example, the required target messages look like:

Message expected at recipient 1:

<ns0:root xmlns:ns0="http://target1.com">

<tagA/>

<tagB/>

<tagC/>

</ns0:root>

Message expected at recipient 2:

<ns0:root xmlns:ns0="http://target2.com">

<tagA/>

<tagB/>

<tagC/>

</ns0:root>

Obviously, we can only create one message type with name root, and that can point to only 1 namespace. However, we need 2 different namespaces, based on the input payload. For example, if a flag in the input has a value 1, we set the namespace as "http://target1.com"; if it has value 2, we set the namespace as "http://target2.com". We are thinking of dynamically deriving the namespace at the time of mapping, but can not figure out a way to do so. We are currently using Graphical Mapping for one of the recipients; do we have to employ XSLT/ABAP mapping to achieve this? Has anybody done a work around this kind of a problem?

Awaiting Answers.

Thanks and Sincere Regards,

Sid

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sid,

An XSLT map can replace the root element containing the namespace definition. You can parameterize the XSLT step as described in my blog: /people/peter.glas3/blog/2010/09/08/pi-parameterized-xslt--a-flexible-alternative .With the parameter, you can conditionally choose the root tag to be created, and take over all content appearing under the root tag.

kr,

Peter Glas

former_member273752
Participant
0 Kudos

Hi Peter,

Thanks for replying. Unfortunately, we are using PI 7.01 and not PI 7.1. Any other ideas?

Nice blog though!

P.S: Obviously, we could use 2 different interfaces pointing to the same message type, essentially creating two different communication channels towards the 2 receivers, and modify the payload within these channels using some Adapter Modules. However, this solution looks rather like firing a cannon to kill a fly, and I surely hope PI does have some other capabilities to achieve this using a single interface and single comm channel, which I do not know of (digging through help.sap right now), or can not think of right now.

Thanks and Regards,

Sid

Former Member
0 Kudos

Hi Sid,

I don't see why you couldn't use this solution with PI 7.01. Anyhow, I think the solution lies in XSLT (ABAP or imported archive) for you, as it disregards the XSD for your interface.

kr,

Peter

former_member273752
Participant
0 Kudos

Hi Peter,

Thanks for your inputs. We did the trick using XSLT mapping. Took a bit of help from your blog, and help.sap. Lesson learnt: sometimes we have to let go of the pre-conceived notions and try out new things.

Thanks and Regards,

Sid

Answers (0)