cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in mapping with optional tag

Former Member
0 Kudos

Hi all,

I have to map the following messages:

Source:

<POITEM> (occurrence 0...unbounded)

<TipoRecord></TipoRecord>

<PO_ITEM></PO_ITEM>

<DELETE_IND></DELETE_IND>

</POITEM>

<POITEM>

<TipoRecord></TipoRecord>

<PO_ITEM></PO_ITEM>

<DELETE_IND></DELETE_IND>

</POITEM>

Target:

<POITEM_B> (occurrence 0 1)

<item> (occurrence 0...unbounded)

<TipoRecord></TipoRecord>

<PO_ITEM></PO_ITEM>

<DELETE_IND></DELETE_IND>

</item>

<item>

<TipoRecord></TipoRecord>

<PO_ITEM></PO_ITEM>

<DELETE_IND></DELETE_IND>

</item>

</POITEM_B>

To do this mapping I have mapped "POITEM" of the source message with "item" of the target one and in that way the cardinality is ok.

Since POITEM_B is optional, even if there are in the source message <POITEM> elements, the tag <POITEM_B> is not created (nor its children).

So I mapped <POITEM> to <POITEM_B>:

the result is ok only for the first <POITEM> element; the second <POITEM> element generates the tag <POITEM_B> without any tag <item> below!

I have tried in several ways (like changing context, and others), but the only way I have found to get all the correct <item> tags below <POITEM>, is to map <POITEM_B> with a Constant!!!

Someone can suggest me a better solution?

ThankS!

Luciana

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Luciana,

when I understand you correct you just want to create the <POITEM_B> and <item> nodes of the target structure if <POITEM> exists. If not, you don't want to create <POITEM_B> and all nodes below, correct?

If so, please try the following:

<POITEM> --> NodeFunction Exists --> NodeFunction collapseContexts --> NodeFunction createIf --> <POITEM_B>

--> This should generate exactly one <POITEM_B> if 1..n <POITEM> elements exist.

<POITEM> --> <item>

--> This should generate the same number <item> nodes you've <POITEM> nodes

Best regards

Lars

Former Member
0 Kudos

Hi Lars,

your hint was very useful!

I tried as you suggested but it was not working yet...I added at the end the node function

SplitByValue(Each value) to create the right contexts.

To resume the mapping is:

<POITEM> --> NodeFunction Exists --> NodeFunction collapseContexts --> NodeFunction createIf --> NodeFunction SplitByValue --><POITEM_B>

Thank you very much for your help!

Luciana

Former Member
0 Kudos

Luciana,

<b>First thing first....you should be very clear what type of structure you required as per the business context..

</b>

If i am not wrong then you want to have this thing...:

1. you want to accept multiple POITEM in one message as occurrence of POITEM is 0...unbounded

Kindly let us know how you want the scenario to work as per that only we can guide you in designing the source and target structures...and later on mapping..( like here i am not getting which purpose you are using item tag in target structure..)

Hope i am clear..

Regards,