Split XML file into different files.



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Split XML file into different files.

Postby Surabhi » Wed Sep 06, 2017 1:38 am

Hi all,

I have a requirement to split xml file into different files based on condition .
The HEADER and INFORMATION should be there in all files along with the condition.

Input file:-
<?xml version="1.0" encoding="UTF-8"?>
<TRANSACTION>
<HEADER>
<NAME>ALEX</NAME>
</HEADER>
<INFORMATION>
<LASTNAME>CRISTOPER</CRISTOPER>
</INFORMATION>
<RESIDENCE>
<PLACE>DENMARK</PLACE>
</RESIDENCE>
<NUMBER>
<LOCAL>123456789</LOCAL>
</NUMBER>
<TRANSACTION>

Expected Output:-
File1:-
condition:: (if 8,7,ch,eq,c'DENMARK')

<?xml version="1.0" encoding="UTF-8"?>
<TRANSACTION>
<HEADER>
<NAME>ALEX</NAME>
</HEADER>
<INFORMATION>
<LASTNAME>CRISTOPER</CRISTOPER>
</INFORMATION>
<RESIDENCE>
<PLACE>DENMARK</PLACE>
<RESIDENCE>

File2:-
condition:: (if 8,9,eq,ch,c'12346789')
<?xml version="1.0" encoding="UTF-8"?>
<TRANSACTION>
<HEADER>
<NAME>ALEX</NAME>
</HEADER>
<INFORMATION>
<LASTNAME>CRISTOPER</CRISTOPER>
</INFORMATION>
<NUMBER>
<LOCAL>123456789</LOCAL>
</NUMBER>

i have tried using WHEN=GROUP option:-
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(8,7,CH,EQ,C'DENMARK'),PUSH=(81:8,7)),
IFTHEN=(WHEN=GROUP,
BEGIN=(8,9,CH,EQ,C'123456789'),PUSH=(81:8,9))
OPTION COPY

But not able to proceed further.
Can anyone please help me out with this.

Thanks.
Surabhi
 
Posts: 49
Joined: Thu Sep 10, 2015 7:51 pm
Has thanked: 4 times
Been thanked: 0 time

Re: Split XML file into different files.

Postby Aki88 » Wed Sep 06, 2017 8:01 pm

Hello,

Going by the requirement you've stated, logically it appears that you want the RESIDENCE (sic), NUMBER (sic) tag data to be written to two different datasets along with the rest of the tags.

This raises a curious question, your post states that you're testing for DENMARK (sic) and c'12346789', what if other values are received for these fields; where do you want them written?

Aside, quick solution would be to use OUTFIL coupled with IFTHEN; in IFTHEN, for one case OMIT the tags within the BEGIN/END range of RESIDENCE (sic), while in the other OMIT the range within NUMBER (sic); write rest of the data as-is - basically an OPTION COPY.
Aki88
 
Posts: 381
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 36 times

Re: Split XML file into different files.

Postby Surabhi » Tue Sep 12, 2017 6:14 pm

Hi Aki88,

Thank you for the response.
to answer your question, we would not receive any other values for these fields other than DENMARK (sic) and c'12346789'.

This solution works when we have only one <TRANSACTION> with all this information.
Any idea how to handle mutliple <TRANSACTION> in same XML file?

Thanks.
Surabhi
 
Posts: 49
Joined: Thu Sep 10, 2015 7:51 pm
Has thanked: 4 times
Been thanked: 0 time

Re: Split XML file into different files.

Postby Aki88 » Tue Sep 12, 2017 6:20 pm

Hello,

Surabhi wrote:...
This solution works when we have only one <TRANSACTION> with all this information.
Any idea how to handle mutliple <TRANSACTION> in same XML file? ...


Can you please show representational input and corresponding expected output for the above scenario?

These users thanked the author Aki88 for the post:
Surabhi (Tue Sep 12, 2017 8:58 pm)
Aki88
 
Posts: 381
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 36 times

Re: Split XML file into different files.

Postby Surabhi » Tue Sep 12, 2017 8:57 pm

Hello,
Thanks for the quick response.
We have got some additional requirements to this, so i think i better go with cobol code to handel everything rather than a sort.

Thank you so much for your inputs :)

Thanks.
Surabhi
 
Posts: 49
Joined: Thu Sep 10, 2015 7:51 pm
Has thanked: 4 times
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post