cancel
Showing results for 
Search instead for 
Did you mean: 

Java Mapping with an xml array as input

Former Member
0 Kudos

Hi Gurus,

I have to perform a java mapping to map some input xml contained in an array with a target message type. I have found a good java mapping example here:

but my mapping input is not a single XML, but an XML array, thus I have a doubt...

How can I map multiple XML contained in an array with a target XML? I have to solve this problem into a Java mapping prospective.

Thanks to all!

Message was edited by:

Gabriele Morgante

Accepted Solutions (0)

Answers (1)

Answers (1)

stefan_grube
Active Contributor
0 Kudos

Could you give an example for this XML array?

I have no idea how it looks like.

Regards

Stefan

henrique_pinto
Active Contributor
0 Kudos

Hey Stefan, I think he is refering to a n:1 multimapping.

If that is indeed the case, Gabriele, you will have to consider the initial tags inserted by mapping runtime to treat multimappings.

Suppose your XML message is like


<myMT xmlns="urn:mynamespace">
  <value>xpto</value>
</myMT>

Then, if your source message interface occurrence is defined as unbounded in your interface mapping, your mapping program (message mapping, xslt, java mapping, whatever) will receive, from mapping runtime, a message like this:


<Messages xmlns="http://sap.com/xi/XI/SplitAndMerge">
  <Message1>
    <myMT xmlns="urn:mynamespace">
      <value>xpto1</value>
    </myMT>
    <myMT xmlns="urn:mynamespace">
      <value>xpto2</value>
    </myMT>
    <myMT xmlns="urn:mynamespace">
      <value>xpto3</value>
    </myMT>
  </Message1>
</Messages>

Also, if you have more than 1 message type as source of your interface mapping, your mapping program will receive the other message types in <Message2>, <Message3>... tags.

The <Messages> and <MessageX> tags will always be automatically generated by mapping runtime when dealing with multimappings, which are mappings from m XML messages to n XML messages, with either m, n or both different of 1 (note that this definition includes mappings from 1 type to 1 type, when either source, target or both message types have max occurrence = ubounded).

Finally, remember that the output that your mapping program generates will also have to include these <Messages> and <MessageX> tags (with proper namespace), since mapping runtime will be expecting them. Message mappings treat those by default, but your xslt and java multimappings will have to explicitely include these tags in the output.

Regards,

Henrique.