How to split XML into 2 separate docs in dell boomi?

1.1k views Asked by At

How to split XML into 2 separate docs as below?

Input:

<stocks>
<stock>
    <stockid>78</stockid>
    <desc>Apple</desc>
    <details>
        <element1>XYZ</element1>
        <element2>ABC</element2>
    </details>
</stock>
<stock>
    <stockid>78</stockid>
    <desc>Apple</desc>
    <details>
        <element1>qwe</element1>
        <element2>asd</element2>
    </details>
</stock>
<stock>
    <stockid>65</stockid>
    <desc>Tesla</desc>
    <details>
        <element1>GHJ</element1>
        <element2>JKL</element2>
    </details>
</stock>

Output:

Doc1 :

<stocks>
<stock>
    <stockid>78</stockid>
    <desc>Apple</desc>
    <details>
        <element1>XYZ</element1>
        <element2>ABC</element2>
    </details>
</stock>
<stock>
    <stockid>78</stockid>
    <desc>Apple</desc>
    <details>
        <element1>qwe</element1>
        <element2>asd</element2>
    </details>
</stock>

Doc 2:

<stock>
    <stockid>65</stockid>
    <desc>Tesla</desc>
    <details>
        <element1>GHJ</element1>
        <element2>JKL</element2>
    </details>
</stock>

I have tried it using Business rule shape and data process shape but failed. Anyone please assist. What I have done is that in the data process shape I tried splitting it on the basis of stockid but its result was not as expected. And I don't know groovy or javascript so I didn't try it with scripting.

1

There are 1 answers

0
Adam Bedenbaugh On

A possible solution would be to use a map to convert the single record to a flat file. This should output 3 documents from the 1st initial document. After the map, use a data process shape to combine the flat files, and then a 2nd entry to split the flat file. The split will be flat file, split on profile, the Profile is the flat file, and Link Element would be stockid. Then do another map to make the flat file to original xml profile.

Overview: Map (XML->FF) to Data Process (Combine and split) to Map (FF->XML).