1

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

4
  • 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? Commented Sep 10, 2012 at 11:08
  • Thank you for replying. It is a xhtml file and a xml file. Commented 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. Commented 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. Commented Sep 10, 2012 at 11:21

3 Answers 3

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

What about creating Stored Procedures vs JAXB??? Do you know any advantages/disadvantages?
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.
3

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

Thank you all for your answers so quickly! It looks like JAXB is a winner :)
2

You can use JAXP(Java API for XML parsing ) to create a XML structure.This is having all the features you wanted.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.