Results 1 to 3 of 3

Thread: XML reader query

  1. #1

    Default XML reader query

    Hello All,

    I have the following input file for xml:

    Code:
    <Cars location="INDIA" marketTime="CLOSE" Date="2011-05-20">
    	<Car name="SKODA" make="2006" price="15000"/>
    	<Car name="AUDI" make="2008" price="18000"/>
    	<Car name="BMW" make="2005" price="16000"/>
    </Cars>
    POJO will have the following properties: Name, Make, Price, Date.

    Question1: How can I read such a file using spring batch?
    Question2: How to include date also in the POJO which is an attribute of the Main tag? Question3: Each tag is an object with attributes as properties. How to read it?

    Thanks!!
    Nikunj

  2. #2
    Join Date
    Jul 2011
    Posts
    16

    Default

    This should be pretty easy to do with JAXB marshaller. I would suggest you create a composite reader which will have a header reader (which should be read only once) and an item reader. For header reader you will have to create a POJO with the location, marketTime and date attributes. fragmentRootElement for the header is "Cars". For item reader you will have a separate POJO which will have the fields name, make and price. fragmentRootElement for the item reader is "Car"

    Once you have read all the fields, combining them into one POJO can be done in the composite reader or even in a processor if you prefer.

  3. #3

    Default

    Quote Originally Posted by symanco View Post
    This should be pretty easy to do with JAXB marshaller. I would suggest you create a composite reader which will have a header reader (which should be read only once) and an item reader. For header reader you will have to create a POJO with the location, marketTime and date attributes. fragmentRootElement for the header is "Cars". For item reader you will have a separate POJO which will have the fields name, make and price. fragmentRootElement for the item reader is "Car"

    Once you have read all the fields, combining them into one POJO can be done in the composite reader or even in a processor if you prefer.
    Hello Symanco,

    Thanks for your reply...

    Is it possible to do this castor's mapping.xml ???

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •