Announcement Announcement Module
Collapse
No announcement yet.
XML reader query Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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 ???

      Comment

      Working...
      X