Skip to Content
0

Split XML fields into target XML file.

Dec 26, 2016 at 10:17 AM

74

avatar image

Dear experts,

My scenario is to split the XML fields of input payload to output payload.

here in input payload I've all the fields under one tag where as for output we need to split each group into another tag.

This below structure is just to understand the requirement:

<Input>
a

b

c

d

a

b

c

d
</input>


<Output>
<chunck>
a

b

c

d

</chunck>

<chunck>

a

a

c

d

</chunck>

</Output>

FYI:

When I try with normal mapping I get the output as below.
<Output>

<chunck>

a

a

b

b

c

c

d

d

</chunck>

</Output>

Please help me to resolve this.

I also tried finding the java code online to do this splitting.

Regards,

Vidhya Nizamkar

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Evgeniy Kolmakov Dec 28, 2016 at 01:24 AM
0

Hi Vidhya!

Regards, Evgeniy.


Show 1 Share
10 |10000 characters needed characters left characters exceeded

Dear Evgeniy,

Thanks a lot. It worked :-)

Regards,

Vidhya Nizamkar

0
Evgeniy Kolmakov Dec 27, 2016 at 07:05 AM
0

Hi Vidhya!

Just map each of your source fields to according field inside <chunk> element of target structure and use SplitByValue function to split your source queues.

Regards, Evgeniy.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Evgeniy,

Thanks for replying.

I tried the same by adding the splitbyvalue function but I'm receiving all fields in sequence.

Like all the <a> tag will be displayed first.
then all <b> tags.
then all <c> tags.

Let me give this example.

Input will be as below.
<input>

<a>hi</a><b>there</b>

<a>dsg</a><b>cxvzv</b>

<a>hi</a> <b>xzcxvz</b>

</input>

Output should be as below.

<input>

<subtag>

<a>hi</a><b>there</b>

</subtag>

<subtag>

<a>dsg</a><b>cxvzv</b>

</subtag>

<subtag>

<a>hi</a><b>xzcxvz</b>

</subtag>

</input>

If I use split by value my output is as below.

<input>

<subtag>

<a>hi</a><a>dsg</a><a>hi</a>

<b>there</b>><b>cxvzv</b><b>xzcxvz</b>

</subtag>

</input>

Regards,

Vidhya Nizamkar

0