I have a task where in I need to send a huge xml document to an external app. The external app has given the schema which we need to adhere to.
I am using XMLBeans to implement the same.
But the problem is since the size of xml to create is huge more than 150 xml elements. I need to invoke the setter methods for all them when i want to create the xml doc.
And since the xml doc is huge I would need to fetch the data from the mutiple database tables requiring a join.
I was thinking if there is some elegant solution for this scenario.
Like if i can combine 2-3 xml docs into one & then create a xml doc which adheres to external app schema.
Another option I was thinking is there any way of mapping the database columns to the xml tag elements.
Currently my work would involve invoking too much of resultset.get() & xmlbeans.setMethods
Is this the only way to go which at the moment i feel is cumbersome since i am doing this for the first time.
Or is there some neat solution for this problem
Do put your suggestions
I understand from your comment that there are lot of Setting to be done to bean .and you want a way around .
If you want to avoid this look at using JAXB(Java XML Binding) which converts your XML to java objects automatically and vice versa .
You can also look at open source tool called as Castor .
all you have to do is to get the Schema (XSD) feed to Castor to get the java objects generated .Then use castor to marshall the XML to java objects .
Thanks for your response. I have to create an xml from java. I have the java class respresenting the xsd which has all the setter methods which I have to invoke.
All this is fine.
Now I have to fetch the data which i get in a Resultset. Which I have to sift through.
I mean this a simple way. I was thinking if we have a more better way of doing this. Something like transparently sets all the attributes of the XMLBean generated class rather than I calling each getter/setter.
Are you using an ORM tool such as Hibernate?
You could use Hibernate to map your database to the same Java objects that your XML schema generated.
You might also want to investigate what tools your database offers - Oracle for example has lots of java and xml stuff bundled in with the latest versions and it sounds as though they might be what you are looking for.