batch xml generation
Posted: Tue Oct 07, 2014 4:54 am
I have a requirement where I read data from database and form list of objects. The count of the objects can go upto 500000. I want to serialize these objects into an xml file but also make sure the size of the file doesn't surpass certain size for example 10 MB. As soon as the size reaches around 10 mb i start serializing into another file.I have to also make sure the xml formed is welformed. Apart from these objects there are few tags in the xml which will be common between files. Below is a sample of what I want:
File1
File2
Constant1, constant2, constant3 are common between files but elements inside data are the actual objects from DB
Need help to see how can i achieve this using java.Also, which xml generation way would be ideal?Tree based, stream or JAXB.
Thankyou
File1
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<batch>
<constant1>one</constant1>
<constant2>two</constant2>
<constant3>three</constant3>
<data>
<d>aaaaaaaaaaa</d>
<d>aaaaaaaaaaa</d>
<d>aaaaaaaaaaa</d>
<d>aaaaaaaaaaa</d>
<d>aaaaaaaaaaa</d>
</data>
</batch>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<batch>
<constant1>one</constant1>
<constant2>two</constant2>
<constant3>three</constant3>
<data>
<d>aaaaaaaaaaa</d>
<d>aaaaaaaaaaa</d>
<d>aaaaaaaaaaa</d>
<d>aaaaaaaaaaa</d>
<d>aaaaaaaaaaa</d>
</data>
</batch>
Need help to see how can i achieve this using java.Also, which xml generation way would be ideal?Tree based, stream or JAXB.
Thankyou