cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with mapping

Former Member
0 Kudos

Hello!

I have message type with structure like this:

<mt>

<element>

<priority>1</priority>

<key>xxx</key>

</element>

<element>

<priority>2</priority>

<key>yyy</key>

</element>

<element>

<priority>3</priority>

<key>zzz</key>

</element>

</mt>

The element occurence is ounbounded. The target structure is the same, but I need only one element with the highest prioruty - in my example - the first element with priority 1.

I need to compare prioritys of all elements.

How can I do this?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Do the mapping as


priority----->removeContext--->sort(Ascending)---->collapseContext--->Element
priority----->removeContext--->sort(Ascending)---->collapseContext--->priority
priority----->removeContext--\
                            --------->sortByKey---->collapseContext--->key
key----->removeContext----/.

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

You can compare and get the highest priority easly as mentioned by Suraj, but the problem will come when you map the key field.

To get the correct key associated with highest priority, you need to store the highest priority in some variable and when doing the mapping for key field just compare the variable value with highest priority and if it is true then only map the key value to target field.

Regards,

Sarvesh

Former Member
0 Kudos

Hi

You can use SORT API in mapping to define the priority based on asending or decending order

Thanks

Swarup

former_member181962
Active Contributor
0 Kudos

Hi Andrey,

Use sortByKey function followed by collapseContext function.

Regards,

Ravi

former_member187339
Active Contributor
0 Kudos

Hi,

Do like this

Priority (context element)> sort (ascending)>CollapseContext-->target field

Regards

Suraj

sunilchandra007
Active Contributor
0 Kudos

Hi,

You can apply sort function on priority element as explained in Stefan's blog.

/people/stefan.grube/blog/2005/12/29/new-functions-in-the-graphical-mapping-tool-xi-30-sp13

Regards,

Sunil Chandra