cancel
Showing results for 
Search instead for 
Did you mean: 

Sort the Nodes and remove duplicate nodes

Former Member
0 Kudos

Hello Experts,

I have a requirement to sort the nodes based on a key value.

e.g.

<Node>

<Key>2<Key>

<Value1>name1<Value1>

<Value2>email1<Value2>

</Node>

<Node>

<Key>1<Key>

<Value1>name2<Value1>

<Value2>email2<Value2>

</Node>

<Node>

<Key>2<Key>

<Value1>name3<Value1>

<Value2>email3<Value2>

</Node>

and the Output should be

<TNode>

<Key>1<Key>

<Value1>name2<Value1>

<Value2>email2<Value2>

</TNode>

<TNode>

<Key>2<Key>

<Value1>name3<Value1>

<Value2>email3<Value2>

</TNode>

I tried using SortByKey function for Node i.e.

Key --> SortByKey , Node --> TNode

But I dont get sorted value for Value1 and Value2.

Can anybody give solution for this?

I have around 25000 records as input and there are around 25 values in structure.

Please help.

Thanks in advance,

Beena.

Accepted Solutions (1)

Accepted Solutions (1)

VijayKonam
Active Contributor
0 Kudos

U have to generate the number of nodes required for the target TNODE first using node functions, then have to use the sort function on Key, Value and Value 1..

VJ

Edited by: VJ on Jan 11, 2008 4:59 PM

Former Member
0 Kudos

Thanks VJ,

That means I need to apply sortByKey function and then split by value on value changed to each of the fields in mapping.

As I specified earlier there are 25 fields in structure.

Is there any other way of doing this?

Thanks,

Beena.

Former Member
0 Kudos

Thanks Raj,

I was trying exactly same solution. Except for FormatByExample I used User Defined function as I need the last value from the context of Split by value (Value changed) and not the first value.

i.e. z,a,CC,y,b,CC,d,e,CC,f

should map to a,CC,b,CC,e,CC,f

However I was confused whether we can automatically adjust the field values if sorting is applied at root node.

So that we don't have to do mapping for individual fields.

I also don't want to apply xslt mappimng as message size is large (25000 to 40000 Records per day)

Thanks for the help.

Thanks VJ for your useful inputs.

Regards,

Beena.

Answers (0)