NAME

xml_rdb - a perl script using the XML::RDB modules to create DDL from XML, load generated DDL and XML data, and able to extract the data back to XML. Tested with Postgreql 8.3, SQLite 3.6.16, and MySQL 5.0.51a.

INTRODUCTION

Xml_rdb takes a XML file or url as input for the XML::DOM::Parser, extracts information to build and write DDL. An attempt is made to recognise relations within the XML structure then translates it to the DDL. Loads that generated DDL, parsing the DOM tree a second time to extract and load the data. At the bottom of the DDL are select statements to help get a view of those relations found and XML data. Xml_rdb also dumps the data back to XML format.

Xml_rdb needs a database configuration, xml_rdb -t prints a template for this. Personally recommend a new sandbox or test database.

Locate a xml file or url, xml_rdb -c <database config> -x <XML file/url>. Generates DDL as <"XML base name".sql>, continues for a second pass to load the XML.

Look over the DDL file, grab the select statements from the bottom and run them for a look at the results. Possible to edit the DDL file's default CREATE TABLE .. "varchar(NN)" fields to something more suitable. Then using the -b and -l switches to reload the data with the newly edited field descriptions, like xml_rdb -b -c <database config> -x <XML file/url> -l.

Edit the data and export with the -n <new XML file>.

Pros: With the aid of Dia, Autodia and Xml_rdb. It's likely for someone to gain perspective of the XML data quickly.

Cons: The select statements do not detect mutually exclusive links, so your mileage may vary. MySQL truncates field width without warning; this could be due to debug settings, debug switches are extended from DBI and DBIx to the config file. XML files are loaded into memory, as long as you have memory it's ok... maybe. . Urls are saved as files before loading (wasn't obvious where tho, still looking). This is GREEN, un-employed and bored ... Grabbed this broken mod, fixed some stuff and whee, etc. XSD support isn't working, and may come back later for more fun.

Depend: xml_rdb as a perl script depends on XML::RDB, XML::DOM, DBIx, DBI for the bulk of the work.

USAGE

     xml_rdb -b -c dsn_config -x some.xml -d some.ddl
     xml_rdb -b -c dsn_conf -n new_some.xml
    
    Switch    Option
     -b               drop tables ( trys to do the right thing, but dont count on it )
     -c   <file>      dsn_config file  
    
     ( SQL generation )
     -x   <file/url>  XML file parsing to DDL
     -d   [file]      Create and Load DDL filename    (optional with XML file)
     -l               Load DDL file, do not generate.
    
     ( XML generation )
     -n   <file>      Output of tables to a new XML file
    
     ( experimental crap ) *ie still broken... you have been forewarned.
     -a   <dir>       Archive directory
     -y   <file>      XML's XSD file
     -z               Test experimental code, i.e. dis-functional.
    
     ( misc )
     -t               print xml_rdb dsn template config and exit.
     -D               Debug for xml_rdb script, 
                       *But the REAL debug modes for pumps are done in the config file.
     -v               version                  
     -h               Show this message