Tutorial :Convert database table structure to XSD format



Question:

Is there any way i can convert a table struture in a MySQL or Oracle database to XSD (XML Schema Definition) format ?.

Thank You.


Solution:1

use XML Spy. http://williamjxj.wordpress.com/2011/05/25/1004/


Solution:2

Yes, but it's fairly complicated. You'll want to run the query SHOW CREATE TABLE <tablename> and it will return the full table creation statement (in tidy CREATE TABLE syntax).

Then you'll want to parse each line of the create table syntax using your language. Thankfully the fields are neatly separated by newlines.

The types should be fairly easy to map to XSD types.

Where it gets complicated is when you're parsing foreign key relationships - then you'll need to define custom types in your XSD and reference them accordingly.

It really comes down to your implementation. If you're looking for a portable data format that you can easily import/export from your database then there are a number of other solutions.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »