File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Retrieve database records as xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Retrieve database records as xml" Watch "Retrieve database records as xml" New topic
Author

Retrieve database records as xml

Ameer Joseph
Greenhorn

Joined: Apr 24, 2008
Posts: 8
Hi,
I have to implement a method (web service) which returns an xml schema.
In other words the response object of web service will be of type "xml schema".
The records are stored in an Oracle database.

What should be the best way to implement this-

# Option 1. To retrieve the records from oracle simply by calling stored procedures-and then storing in some object- and then converting that object to xml schema. (Not sure exactly how this will work)
# Option 2. Query databse so that it returns xml schema
#Any other option- you can suggest

Thanks in advance for help,
Ameer
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
How about query database so it returns plain text that happens to be formatted as an XML document?

Bill
Ameer Joseph
Greenhorn

Joined: Apr 24, 2008
Posts: 8
Bill,
Thanks for replying. Can you shed more light on this.

Thanks,
Ameer.
Ameer Joseph
Greenhorn

Joined: Apr 24, 2008
Posts: 8
Bill,
Thanks for replying. Can you shed more light on this.

Thanks,
Ameer.
Ameer Joseph
Greenhorn

Joined: Apr 24, 2008
Posts: 8
Hey Bill,
I really appreciate your help. Can you please tell how can we retrieve from database as plain text formatted as xml.
Please provide link/references.

Thanks,
Ameer.
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

Ameer:Can you please tell how can we retrieve from database as plain text formatted as xml.

For that you first have to tell us, what format is the data stored in the database.
Nothing will magically change the data in the database to an xml document. There needs to be some piece of code, either yours or third party that will help you do it.


apigee, a better way to API!
Ameer Joseph
Greenhorn

Joined: Apr 24, 2008
Posts: 8
Hey Nitesh,

Thanks for replying. The records are stored in an Oracle database in the 'usual data'format like varchar, number and timestamp for date. I am not sure what we call this format.
Please read my original post which explaines what I want to do.
I appreciate your help. I could not figure out what Java Code/XML Code /Third party code can be used for it. It will be great if you provide some references and Also if this is the best way to do it.

Thanks a ton,
Ameer.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
We appear to finally have established that you have a database with a variety of fields and want to do a query that outputs an XML formatted text stream.

Your use of the term "return an xml schema" had me confused, I am now assuming you mean that the output XML must conform to a schema rather that write a schema document. If you really want to write a schema document than the following will not help.

The ServingXML toolkit is supposed to be able to make turning SQL queries to XML easy.

Bill
[ April 26, 2008: Message edited by: William Brogden ]
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
The Hibernate Framework has a function that will extract relational data and create an XML-based representation of it. Below is a code fragment that extracts a User record and returns an XML data set.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retrieve database records as xml