Description:
xml2sql is a collection of Perl scripts used to convert XML files into SQL
scripts for creating tables. xml2sql does no validation of the XML files.
If you have an xml document that conforms to the sql-structure.dtd included
with xml2sql, then the perl scripts will produce the appropriate output.
An extensive explanation of the dtd will be forthcoming as time permits.
Currently, the xml2mssql.pl script has auto_increment and foreign keys
disabled. This is because I needed my MSSql server to behave more like
MySQL.
Usage:
xml2mysql.pl < database.xml > database.sql
or
xml2mssql.pl < database.xml > database.sql
Sample Input:
A better sample will be forthcoming as soon as I have the opportunity to use
xml2sql in a personal project instead of at work.
<!DOCTYPE database SYSTEM "sql-structure.dtd">
<database>
<name>foo</name>
<description>A database for storing random stuff</description>
<version>1.0</version>
<table>
<name>bar</name>
<description>A table for storing random stuff</description>
<field>
<name>bar_id</name>
<description>unique identifier for each bar</description>
<type>int</type>
<option>not null</option>
<option>auto_increment</option>
</field>
<field>
<name>bar_name</name>
<description>name for each bar</description>
<type>varchar</type>
<length>255</length>
<option>not null</option>
</field>
<index>
<type>primary key</type>
<column>bar_id</column>
</index>
</table>
</database>
Sample Output:
From xml2mysql.pl:
### Generated: Sun Oct 22 20:41:37 2000
### Database: foo
### Description: A database for storing random stuff
### Version: 1.0
###
### Tables:
### bar - A table for storing random stuff
# Table: bar
#
# Columns:
# bar_id - unique identifier for each bar
# bar_name - name for each bar
CREATE TABLE bar (
bar_id int not_null auto_increment,
bar_name varchar(255) not_null,
PRIMARY KEY (bar_id)
);
From xml2mssql.pl:
CREATE TABLE bar (
bar_id int not_null auto_increment,
bar_name varchar(255) not_null,
PRIMARY KEY (bar_id)
)
GO
|