I have to generate huge and quite complex xml files by Java. I have to fetch the data from a Oracle database. What I really don't know is a proper and reliable way to this? I could of course create a String and concatenate all the tags, attributes and data but it doesn't feel right. I guess this is a quite common task and there are many established ways to this by Java. My question is what is the best way to this? What is your suggestion? Thank you for any clues...
-
What does it mean "huge"? Can you do it in memory or you have read from database and write data to file continuously to minimize used memory?Gaim– Gaim2012-09-10 11:08:47 +00:00Commented Sep 10, 2012 at 11:08
-
Thank you for replying. It is a xhtml file and a xml file.Madeline– Madeline2012-09-10 11:14:03 +00:00Commented Sep 10, 2012 at 11:14
-
By huge I mean it is lots huge amount of data being fetched from database and as a result the xml/xhtml file to write to will be huge.Madeline– Madeline2012-09-10 11:16:12 +00:00Commented Sep 10, 2012 at 11:16
-
@Shivan - I haven't tried anything yet. It is the first time I am creating xml files. I have been googling some and realized that there many ways to this and I am kind of confused over what is a reliable, nice and common way to this.Madeline– Madeline2012-09-10 11:21:54 +00:00Commented Sep 10, 2012 at 11:21
Add a comment
|
3 Answers
You could use JAXB for building XML out of structured objects that are a result of querying your data store.
If your object hierarchy is not complex, you can use Oracle's capability to generate results in XML.
2 Comments
Madeline
What about creating Stored Procedures vs JAXB??? Do you know any advantages/disadvantages?
Vikdor
You mean generating xml in stored procedures? I wouldn't do that. I just updated my response about Oracle's ability to generate results as XML. you may want to check that as well.
There are several options for object to xml transformation.
I would personally suggest JAXB for easy of use and saxparser for performance centric application.
1 Comment
Madeline
Thank you all for your answers so quickly! It looks like JAXB is a winner :)