none
Batching XML based on a field value.... RRS feed

  • Question

  • Hi - I am looking for a right approach to solve this problem. I need to debatch the incoming file, and then read a certain value in all the records, map it and batch based on the value of that field. e.g. in the example below i need to batch all the records in one output xml where city is XXX. so, i should be getting two output xmls.

    Incoming File to BizTalk:

    <CustomerSchema>

    <Header>

    <Version>1.0</Version>

    <FileName>abc.xml</FileName>

    </Header>

    <Customers>

    <Customer>

    <FirstName>abc</FirstName>

    <LastName>xyz</LastName>

    <City>XXX</City>

    </Customer>

    <Customer>

    <FirstName>asd</FirstName>

    <LastName>jkl</LastName>

    <City>XXX</City>

    </Customer>

    <Customer>

    <FirstName>mn</FirstName>

    <LastName>zxc</LastName>

    <City>ZZZ</City>

    </Customer>

    </Customers>

    </CustomerSchema>

     

    Expected Output

    File 1

    <CustomerSchema_OUT>

    <Header>

    <Version>1.0</Version>

    <FileName>abc.xml</FileName>

    </Header>

    <Customer>

    <FullName>abc xyz</FullName>

    <City>XXX</City>

    </Customer>

    <Customer>

    <FullName>asd jkl</FullName>

    <City>XXX</City>

    </Customer>

    </CustomerSchema_OUT>

     

    File 2

    <CustomerSchema_OUT>

    <Header>

    <Version>1.0</Version>

    <FileName>abc.xml</FileName>

    </Header>

    <Customer>

    <FullName>mn zxc</FullName>

    <City>ZZZ</City>

    </Customer>

    </CustomerSchema_OUT>

    Thanks

    Monday, May 9, 2011 3:04 PM

Answers

  • My recomendation is to load the file into one table. Once you have the data loaded, you can export it based on whatever values you want. From experience, I found that breaking out a flat file is sometimes tricky. If you load it to a table, you can create all kinds of tracking and reporting based on the insert date. However, if you want to do it on the map, you need to set a condition at the header loop based on city. I found doing so is sometimes dificult which is why I recomend the earlier option.
    Please Indicate "Mark as Answer" if this Post has Answered the Question
    Tuesday, May 10, 2011 12:07 PM